Permalink
Browse files

added option to prevent stacking of models, based on patch #2919630 f…

…rom RAZOR, but on a per-model basis. Thanks RAZOR (I can't find your real name).
  • Loading branch information...
1 parent e5a483c commit 08e31b0e77626596888df30c31683d8512e9c9db rtv committed Jan 19, 2010
Showing with 26 additions and 16 deletions.
  1. +3 −3 CMakeLists.txt
  2. +4 −4 libstage/block.cc
  3. +9 −0 libstage/model.cc
  4. +1 −1 libstage/model_draw.cc
  5. +2 −2 libstage/model_getset.cc
  6. +3 −0 libstage/model_load.cc
  7. +4 −5 libstage/stage.hh
  8. +0 −1 worlds/pioneer.inc
View
@@ -212,9 +212,9 @@ ADD_SUBDIRECTORY(examples)
ADD_SUBDIRECTORY(assets)
ADD_SUBDIRECTORY(worlds)
-if( WEBSIM_FOUND )
-ADD_SUBDIRECTORY(webstage)
-endif( WEBSIM_FOUND )
+# if( WEBSIM_FOUND )
+# ADD_SUBDIRECTORY(webstage)
+# endif( WEBSIM_FOUND )
IF ( BUILD_PLAYER_PLUGIN AND PLAYER_FOUND )
ADD_SUBDIRECTORY(libstageplugin)
View
@@ -24,7 +24,6 @@ Block::Block( Model* mod,
local_z( zmin, zmax ),
color( color ),
inherit_color( inherit_color ),
- glow( 0.0 ),
rendered_cells( new CellPtrVec ),
candidate_cells( new CellPtrVec ),
gpts()
@@ -460,11 +459,12 @@ void Block::Load( Worldfile* wf, int entity )
inherit_color = false;
}
else
- inherit_color = true;
-
- glow = wf->ReadFloat( entity, "glow", glow );
+ inherit_color = true;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// utility functions to ensure block winding is consistent and matches OpenGL's default
+
static
/// util; puts angle into [0, 2pi)
void positivize(stg_radians_t& angle)
View
@@ -45,6 +45,8 @@
map_resolution 0.1
say ""
alwayson 0
+
+ stack_children 1
)
@endverbatim
@@ -124,6 +126,12 @@
- gui_move <int>\n if 1, the model can be moved by the mouse in
the GUI window
+
+ - stack_children <int>\n If non-zero (the default), the coordinate
+ system of child models is offset in z so that its origin is on
+ _top_ of this model, making it easy to stack models together. If
+ zero, the child coordinate system is not offset in z, making it
+ easy to define objects in a single local coordinate system.
*/
// todo
@@ -278,6 +286,7 @@ Model::Model( World* world,
rastervis(),
rebuild_displaylist(true),
say_string(),
+ stack_children( true ),
stall(false),
subs(0),
thread_safe( false ),
View
@@ -233,7 +233,7 @@ void Model::PushLocalCoords()
{
glPushMatrix();
- if( parent )
+ if( parent && parent->stack_children )
glTranslatef( 0,0, parent->geom.size.z );
Gl::pose_shift( pose );
View
@@ -192,8 +192,8 @@ Pose Model::GetGlobalPose() const
// otherwise
Pose global_pose = parent->GetGlobalPose() + pose;
- // we are on top of our parent
- global_pose.z += parent->geom.size.z;
+ if ( parent->stack_children ) // should we be on top of our parent?
+ global_pose.z += parent->geom.size.z;
return global_pose;
}
View
@@ -167,6 +167,9 @@ void Model::Load()
}
}
+ this->stack_children =
+ wf->ReadInt( wf_entity, "stack_children", this->stack_children );
+
stg_kg_t m = wf->ReadFloat(wf_entity, "mass", this->mass );
if( m != this->mass )
SetMass( m );
View
@@ -824,7 +824,7 @@ namespace Stg
pthread_cond_t threads_done_cond; ///< signalled by last worker thread to unblock main thread
int total_subs; ///< the total number of subscriptions to all models
unsigned int worker_threads; ///< the number of worker threads to use
-
+
protected:
std::list<std::pair<stg_world_callback_t,void*> > cb_list; ///< List of callback functions and arguments
@@ -1135,9 +1135,6 @@ namespace Stg
Color color;
bool inherit_color;
- /** experimental - range 0 - 1, render glowing */
- double glow;
-
void DrawTop();
void DrawSides();
@@ -1787,6 +1784,8 @@ namespace Stg
bool rebuild_displaylist; ///< iff true, regenerate block display list before redraw
std::string say_string; ///< if non-null, this string is displayed in the GUI
+ bool stack_children; ///< whether child models should be stacked on top of this model or not
+
stg_bool_t stall;
int subs; ///< the number of subscriptions to this model
/** Thread safety flag. Iff true, Update() may be called in
@@ -1962,7 +1961,7 @@ namespace Stg
/** Causes this model and its children to recompute their global
position instead of using a cached pose in
Model::GetGlobalPose()..*/
- void GPoseDirtyTree();
+ //void GPoseDirtyTree();
virtual void Startup();
virtual void Shutdown();
View
@@ -1,4 +1,3 @@
-
# Desc: Device definitions for Activemedia robots.
# Author: Richard Vaughan, Andrew Howard, Luis Riazuelo
# Date: 10 Jun 2002

0 comments on commit 08e31b0

Please sign in to comment.