Revision: 7159
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7159&view=rev
Author:   rtv
Date:     2008-11-19 08:22:32 +0000 (Wed, 19 Nov 2008)

Log Message:
-----------
geometry fixes & graphics tweaks

Modified Paths:
--------------
    code/stage/trunk/examples/ctrl/fasr.cc
    code/stage/trunk/libstage/block.cc
    code/stage/trunk/libstage/blockgroup.cc
    code/stage/trunk/libstage/canvas.cc
    code/stage/trunk/libstage/model.cc
    code/stage/trunk/libstage/model_laser.cc
    code/stage/trunk/libstage/stage.hh
    code/stage/trunk/libstage/stage_internal.hh
    code/stage/trunk/libstage/world.cc
    code/stage/trunk/libstage/worldgui.cc
    code/stage/trunk/worlds/fasr.world
    code/stage/trunk/worlds/pioneer.inc

Modified: code/stage/trunk/examples/ctrl/fasr.cc
===================================================================
--- code/stage/trunk/examples/ctrl/fasr.cc      2008-11-19 01:24:40 UTC (rev 
7158)
+++ code/stage/trunk/examples/ctrl/fasr.cc      2008-11-19 08:22:32 UTC (rev 
7159)
@@ -32,6 +32,7 @@
 {
   StgModelPosition* pos;
   StgModelLaser* laser;
+  StgModelRanger* ranger;
   StgModelBlobfinder* blobfinder;
 
   StgModel *source, *sink;
@@ -59,6 +60,11 @@
   assert( robot->laser );
   robot->laser->Subscribe();
 
+  robot->ranger = (StgModelRanger*)mod->GetModel( "ranger:0" );
+  assert( robot->ranger );
+  robot->ranger->Subscribe();
+
+
   robot->avoidcount = 0;
   robot->randcount = 0;
   

Modified: code/stage/trunk/libstage/block.cc
===================================================================
--- code/stage/trunk/libstage/block.cc  2008-11-19 01:24:40 UTC (rev 7158)
+++ code/stage/trunk/libstage/block.cc  2008-11-19 08:22:32 UTC (rev 7159)
@@ -175,6 +175,9 @@
 {
   stg_pose_t gpose = mod->GetGlobalPose();
 
+  // add local offset
+  gpose = pose_sum( gpose, mod->geom.pose );
+
   stg_point3_t scale;
   scale.x = mod->geom.size.x / mod->blockgroup.size.x;
   scale.y = mod->geom.size.y / mod->blockgroup.size.y;

Modified: code/stage/trunk/libstage/blockgroup.cc
===================================================================
--- code/stage/trunk/libstage/blockgroup.cc     2008-11-19 01:24:40 UTC (rev 
7158)
+++ code/stage/trunk/libstage/blockgroup.cc     2008-11-19 08:22:32 UTC (rev 
7159)
@@ -190,8 +190,6 @@
   if( displaylist == 0 )
         BuildDisplayList( mod );
   
-  //gl_pose_shift( &geom.pose );
-
   glCallList( displaylist );
 }
 

Modified: code/stage/trunk/libstage/canvas.cc
===================================================================
--- code/stage/trunk/libstage/canvas.cc 2008-11-19 01:24:40 UTC (rev 7158)
+++ code/stage/trunk/libstage/canvas.cc 2008-11-19 08:22:32 UTC (rev 7159)
@@ -30,6 +30,7 @@
 static  GLuint texName;
 static bool blur = true;
 
+static bool init_done = false;
 
 void StgCanvas::TimerCallback( StgCanvas* c )
 {
@@ -45,11 +46,14 @@
                                                        c);
 }
 
-StgCanvas::StgCanvas( StgWorldGui* world, int x, int y, int w, int h) :
-  Fl_Gl_Window(x,y,w,h),
+StgCanvas::StgCanvas( StgWorldGui* world, 
+                                                        int x, int y, 
+                                                        int width, int height) 
:
+  Fl_Gl_Window( x, y, width, height ),
   // initialize Option objects
   showBlinken( "Blinkenlights", "show_blinkenlights", "", true ),
   showBlocks( "Blocks", "show_blocks", "b", true  ),
+  showBBoxes( "Debug/Bounding boxes", "show_boundingboxes", "^b", false  ),
   showClock( "Clock", "show_clock", "c", true ),
   showData( "Data", "show_data", "d", false ),
   showFlags( "Flags", "show_flags", "l",  true ),
@@ -63,33 +67,101 @@
   showTrailRise( "Trails/Rising blocks", "show_trailrise", "^r", false ),
   showTrails( "Trails/Fast", "show_trailfast", "^f", false ),
   showTree( "Debug/Tree", "show_tree", "^t", false ),
+  showBlur( "Trails/Blur", "show_trailblur", "^d", false ),
   pCamOn( "Perspective camera", "pcam_on", "r", false ),
-  visualizeAll( "Visualize All", "vis_all", "^v", true ) 
+  visualizeAll( "Visualize All", "vis_all", "^v", true ),
+  // and the rest
+  world( world ),
+  selected_models( NULL ),
+  last_selection( NULL ),
+  wf( NULL ),
+  startx( -1 ),
+  starty( -1 ),
+  interval(  50 ), //msec between redraws
+  graphics( true )
 {
   end();
-
+  
   //show(); // must do this so that the GL context is created before 
configuring GL
   // but that line causes a segfault in Linux/X11! TODO: test in OS X
-
-  this->world = world;
-  selected_models = NULL;
-  last_selection = NULL;
-  wf = NULL;
-
+  
   perspective_camera.setPose( 0.0, -4.0, 3.0 );
   current_camera = &camera;
   setDirtyBuffer();
        
-  startx = starty = -1;
-  interval = 50; //msec between redraws
-  
   // enable accumulation buffer
   mode( mode() | FL_ACCUM );
   assert( can_do( FL_ACCUM ) );
+}
 
-  graphics = true;
+void StgCanvas::InitGl()
+{
+  valid(1);
+  FixViewport(w(), h());
+  
+  // set gl state that won't change every redraw
+  glClearColor ( 0.7, 0.7, 0.8, 1.0);
+  glDisable( GL_LIGHTING );
+  glEnable( GL_DEPTH_TEST );
+  glDepthFunc( GL_LESS );
+  glCullFace( GL_BACK );
+  glEnable (GL_CULL_FACE);
+  glEnable( GL_BLEND );
+  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+  glEnable( GL_LINE_SMOOTH );
+  glHint( GL_LINE_SMOOTH_HINT, GL_FASTEST );
+  glDepthMask( GL_TRUE );
+  glEnable( GL_TEXTURE_2D );
+  glEnableClientState( GL_VERTEX_ARRAY );
+  glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
+  
+  // install a font
+  gl_font( FL_HELVETICA, 12 );  
+
+  blur = false;
+  
+  // load textures
+  std::string fullpath = FileManager::findFile( "assets/stall.png" );
+  if ( fullpath == "" ) 
+        {
+               PRINT_DEBUG( "Unable to load texture.\n" );
+        }
+  
+  GLuint stall_id = TextureManager::getInstance().loadTexture( 
fullpath.c_str() );
+  TextureManager::getInstance()._stall_texture_id = stall_id;
+  
+  //TODO merge this code into the textureManager?
+  int i, j;
+  for (i = 0; i < checkImageHeight; i++) 
+        for (j = 0; j < checkImageWidth; j++) 
+               {                       
+                 int even = (i+j)%2;
+                 checkImage[i][j][0] = (GLubyte) 255 - 10*even;
+                 checkImage[i][j][1] = (GLubyte) 255 - 10*even;
+                 checkImage[i][j][2] = (GLubyte) 255;// - 5*even;
+                 checkImage[i][j][3] = 255;
+               }
+  
+  
+  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+  glGenTextures(1, &texName);           
+  glBindTexture(GL_TEXTURE_2D, texName);
+  glEnable(GL_TEXTURE_2D);
+  
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+  
+  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, checkImageHeight, 
+                                       0, GL_RGBA, GL_UNSIGNED_BYTE, 
checkImage);
+  
+  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+  init_done = true; 
 }
 
+
 StgCanvas::~StgCanvas()
 { 
   // nothing to do
@@ -563,6 +635,20 @@
   LISTMETHOD( models_sorted, StgModel*, DrawBlocksTree );
 }
 
+void StgCanvas::DrawBoundingBoxes() 
+{
+  glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
+  glLineWidth( 2.0 );
+  glPointSize( 5.0 );
+  glDisable (GL_CULL_FACE);
+  
+  world->DrawBoundingBoxTree();
+  
+  glEnable (GL_CULL_FACE);
+  glLineWidth( 1.0 );
+  glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
+}
+
 inline void StgCanvas::resetCamera()
 {
   float max_x = 0, max_y = 0, min_x = 0, min_y = 0;
@@ -673,29 +759,32 @@
   if( showBlocks )
         DrawBlocks();
 
+  if( showBBoxes )
+        DrawBoundingBoxes();
+
 // MOTION BLUR
-//   if( showBlocks )
-//      {
-//             DrawBlocks();
+   if( showBlur )
+        {
+               DrawBlocks();
                
-//             static float count = 0; 
+               //static float count = 0; 
                
-//             if( ! blur )
-//               {
-//                      blur = true;
-//                      glClear( GL_ACCUM_BUFFER_BIT | GL_COLOR_BUFFER_BIT | 
GL_DEPTH_BUFFER_BIT );
-//                      glAccum( GL_LOAD, 1.0 );
-//               }
-//             else
-//               {     
-//                      glAccum( GL_MULT, 0.9 );
-//                      glAccum( GL_ACCUM, 0.1 );
+               if( ! blur )
+                 {
+                        blur = true;
+                        glClear( GL_ACCUM_BUFFER_BIT | GL_COLOR_BUFFER_BIT | 
GL_DEPTH_BUFFER_BIT );
+                        glAccum( GL_LOAD, 1.0 );
+                 }
+               else
+                 {     
+                        glAccum( GL_MULT, 0.9 );
+                        glAccum( GL_ACCUM, 0.1 );
                         
-//                      glAccum( GL_RETURN, 1.1 );
+                        glAccum( GL_RETURN, 1.1 );
                         
-//                      DrawBlocks(); // outline at current location
-//               }
-//      }
+                        DrawBlocks(); // outline at current location
+                 }
+        }
 
 // GRAY TRAILS
 //   if( showBlocks )
@@ -981,6 +1070,8 @@
   //showTrailArrows.createMenuItem( menu, path ); // broken
   showTrails.createMenuItem( menu, path ); 
   // showTrailRise.createMenuItem( menu, path );  // broken
+  showBBoxes.createMenuItem( menu, path );
+  showBlur.createMenuItem( menu, path );
   showTree.createMenuItem( menu, path );  
   showScreenshots.createMenuItem( menu, path );  
 }
@@ -997,6 +1088,8 @@
   showData.Load( wf, sec );
   showFlags.Load( wf, sec );
   showBlocks.Load( wf, sec );
+  showBBoxes.Load( wf, sec );
+  showBlur.Load( wf, sec );
   showClock.Load( wf, sec );
   showFollow.Load( wf, sec );
   showFootprints.Load( wf, sec );
@@ -1027,6 +1120,8 @@
 
   showData.Save( wf, sec );
   showBlocks.Save( wf, sec );
+  showBBoxes.Save( wf, sec );
+  showBlur.Save( wf, sec );
   showClock.Save( wf, sec );
   showFlags.Save( wf, sec );
   showFollow.Save( wf, sec );
@@ -1047,7 +1142,6 @@
 //   static unsigned long calls=0;
 //   printf( "Draw calls %lu\n", ++calls );
 
-  static bool loaded_texture = false;
 
   //Enable the following to debug camera model
   //   if( loaded_texture == true && pCamOn == true )
@@ -1055,75 +1149,9 @@
 
   if (!valid() ) 
     { 
-      valid(1);
-      FixViewport(w(), h());
+               if( ! init_done )
+                 InitGl();
                
-      // set gl state that won't change every redraw
-      glClearColor ( 0.7, 0.7, 0.8, 1.0);
-      glDisable( GL_LIGHTING );
-      glEnable( GL_DEPTH_TEST );
-      glDepthFunc( GL_LESS );
-      glCullFace( GL_BACK );
-      glEnable (GL_CULL_FACE);
-      glEnable( GL_BLEND );
-      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
-      glEnable( GL_LINE_SMOOTH );
-      glHint( GL_LINE_SMOOTH_HINT, GL_FASTEST );
-      glDepthMask( GL_TRUE );
-      glEnable( GL_TEXTURE_2D );
-               glEnableClientState( GL_VERTEX_ARRAY );
-               glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
-
-               blur = false;
-
-      //TODO find a better home for loading textures
-      if( loaded_texture == false ) 
-                 {
-                        std::string fullpath = FileManager::findFile( 
"assets/stall.png" );
-                        if ( fullpath == "" ) {
-                               PRINT_DEBUG( "Unable to load texture.\n" );
-                        }
-                        
-                        GLuint stall_id = 
TextureManager::getInstance().loadTexture( fullpath.c_str() );
-                        TextureManager::getInstance()._stall_texture_id = 
stall_id;
-                        
-                        //create floor texture
-                        {
-                               //TODO merge this code into the textureManager
-                               int i, j;
-                               for (i = 0; i < checkImageHeight; i++) 
-                                 for (j = 0; j < checkImageWidth; j++) 
-                                        {                      
-                                               int even = (i+j)%2;
-                                               checkImage[i][j][0] = (GLubyte) 
255 - 10*even;
-                                               checkImage[i][j][1] = (GLubyte) 
255 - 10*even;
-                                               checkImage[i][j][2] = (GLubyte) 
255;// - 5*even;
-                                               checkImage[i][j][3] = 255;
-                                        }
-                               
-                               
-                               glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-                               glGenTextures(1, &texName);              
-                               glBindTexture(GL_TEXTURE_2D, texName);
-                               glEnable(GL_TEXTURE_2D);
-                               
-                               glTexParameteri(GL_TEXTURE_2D, 
GL_TEXTURE_WRAP_S, GL_REPEAT);
-                               glTexParameteri(GL_TEXTURE_2D, 
GL_TEXTURE_WRAP_T, GL_REPEAT);
-                               glTexParameteri(GL_TEXTURE_2D, 
GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-                               glTexParameteri(GL_TEXTURE_2D, 
GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-                               
-                               glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 
checkImageWidth, checkImageHeight, 
-                                                                0, GL_RGBA, 
GL_UNSIGNED_BYTE, checkImage);
-                               
-                               glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, 
GL_MODULATE);
-                        }
-                        
-                        loaded_texture = true;
-                 }
-               
-      // install a font
-      gl_font( FL_HELVETICA, 12 );
-               
       if( pCamOn == true ) 
                  {
                         perspective_camera.setAspect( static_cast< float >( 
w() ) / static_cast< float >( h() ) );

Modified: code/stage/trunk/libstage/model.cc
===================================================================
--- code/stage/trunk/libstage/model.cc  2008-11-19 01:24:40 UTC (rev 7158)
+++ code/stage/trunk/libstage/model.cc  2008-11-19 08:22:32 UTC (rev 7159)
@@ -923,31 +923,56 @@
 }
 
 void StgModel::DrawBlocks( )
+{ 
+  gl_pose_shift( &geom.pose );
+  blockgroup.CallDisplayList( this );
+}
+
+void StgModel::DrawBoundingBoxTree()
 {
-  // testing - draw bounding box
-  //   PushColor( color );
+  PushLocalCoords();
+  LISTMETHOD( children, StgModel*, DrawBoundingBoxTree );
+  DrawBoundingBox();
+  PopCoords();
+}
+
+void StgModel::DrawBoundingBox()
+{
+  gl_pose_shift( &geom.pose );  
+
+  PushColor( color );
   
-  //   // bottom
-  //   glBegin( GL_LINE_LOOP );
-  //   glVertex3f( -geom.size.x/2.0, -geom.size.y/2.0, 0 );
-  //   glVertex3f( +geom.size.x/2.0, -geom.size.y/2.0, 0 );
-  //   glVertex3f( +geom.size.x/2.0, +geom.size.y/2.0, 0 );
-  //   glVertex3f( -geom.size.x/2.0, +geom.size.y/2.0, 0 );
-  //   glEnd();
+  glBegin( GL_QUAD_STRIP );
   
-  //   // top
-  //   glBegin( GL_LINE_LOOP );
-  //   glVertex3f( -geom.size.x/2.0, -geom.size.y/2.0, geom.size.z );
-  //   glVertex3f( +geom.size.x/2.0, -geom.size.y/2.0, geom.size.z );
-  //   glVertex3f( +geom.size.x/2.0, +geom.size.y/2.0, geom.size.z );
-  //   glVertex3f( -geom.size.x/2.0, +geom.size.y/2.0, geom.size.z );
-  //   glEnd();
-  
-  //   PopColor();
-  
-  blockgroup.CallDisplayList( this );
-  
-  //printf( "calling list for %s\n", token );
+  glVertex3f( -geom.size.x/2.0, -geom.size.y/2.0, geom.size.z );
+  glVertex3f( -geom.size.x/2.0, -geom.size.y/2.0, 0 );
+ 
+  glVertex3f( +geom.size.x/2.0, -geom.size.y/2.0, geom.size.z );
+  glVertex3f( +geom.size.x/2.0, -geom.size.y/2.0, 0 );
+ 
+  glVertex3f( +geom.size.x/2.0, +geom.size.y/2.0, geom.size.z );
+  glVertex3f( +geom.size.x/2.0, +geom.size.y/2.0, 0 );
+
+  glVertex3f( +geom.size.x/2.0, +geom.size.y/2.0, geom.size.z );
+  glVertex3f( +geom.size.x/2.0, +geom.size.y/2.0, 0 );
+
+  glVertex3f( -geom.size.x/2.0, +geom.size.y/2.0, geom.size.z );
+  glVertex3f( -geom.size.x/2.0, +geom.size.y/2.0, 0 );
+
+  glVertex3f( -geom.size.x/2.0, -geom.size.y/2.0, geom.size.z );
+  glVertex3f( -geom.size.x/2.0, -geom.size.y/2.0, 0 );
+
+  glEnd();
+
+  glBegin( GL_LINES );
+  glVertex2f( -0.02, 0 ); 
+  glVertex2f( +0.02, 0 ); 
+
+  glVertex2f( 0, -0.02 ); 
+  glVertex2f( 0, +0.02 ); 
+  glEnd();
+
+  PopColor();
 }
 
 // move into this model's local coordinate frame
@@ -959,14 +984,6 @@
         glTranslatef( 0,0, parent->geom.size.z );
   
   gl_pose_shift( &pose );
-
-  // useful debug - draw a point at the local origin
- //  PushColor( color );
-//   glPointSize( 5.0 );
-//   glBegin( GL_POINTS );
-//   glVertex2i( 0, 0 );
-//   glEnd();
-//   PopColor();
 }
 
 void StgModel::PopCoords()
@@ -984,8 +1001,8 @@
 
 void StgModel::DrawStatus( Camera* cam ) 
 {
-       if( say_string )          
-       {
+  if( say_string )       
+        {
                float yaw, pitch;
                pitch = - cam->pitch();
                yaw = - cam->yaw();                     
@@ -1011,59 +1028,58 @@
                
                GLboolean valid;
                glGetBooleanv( GL_CURRENT_RASTER_POSITION_VALID, &valid );
-               if( valid == true ) {
-                       GLdouble wx, wy, wz;
-                       GLint viewport[4];
-                       glGetIntegerv(GL_VIEWPORT, viewport);
-                       
-                       GLdouble modelview[16];
-                       glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
-                       
-                       GLdouble projection[16];        
-                       glGetDoublev(GL_PROJECTION_MATRIX, projection);
-                       
+               if( valid ) 
+                 {
+                        GLdouble wx, wy, wz;
+                        GLint viewport[4];
+                        glGetIntegerv(GL_VIEWPORT, viewport);
+                        
+                        GLdouble modelview[16];
+                        glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
+                        
+                        GLdouble projection[16];       
+                        glGetDoublev(GL_PROJECTION_MATRIX, projection);
+                        
                        //get width and height in world coords
-                       gluUnProject( pos[0] + w, pos[1], pos[2], modelview, 
projection, viewport, &wx, &wy, &wz );
-                       w = wx;
-                       gluUnProject( pos[0], pos[1] + h, pos[2], modelview, 
projection, viewport, &wx, &wy, &wz );
-                       h = wy;
-                       
-                       
-                       // calculate speech bubble margin
-                       const float m = h/10;
-                       
-                       // draw inside of bubble
-                       PushColor( BUBBLE_FILL );
-                       glPushAttrib( GL_POLYGON_BIT | GL_LINE_BIT );
-                       glPolygonMode( GL_FRONT, GL_FILL );
-                       glEnable( GL_POLYGON_OFFSET_FILL );
-                       glPolygonOffset( 1.0, 1.0 );
-                       gl_draw_octagon( w, h, m );
-                       glDisable( GL_POLYGON_OFFSET_FILL );
-                       PopColor();
-                       
-                       // draw outline of bubble
-                       PushColor( BUBBLE_BORDER );
-                       glLineWidth( 1 );
-                       glEnable( GL_LINE_SMOOTH );
-                       glPolygonMode( GL_FRONT, GL_LINE );
-                       gl_draw_octagon( w, h, m );
-                       glPopAttrib();
-                       PopColor();
-
-                       PushColor( BUBBLE_TEXT );
-                       // draw text inside the bubble
-                       gl_draw_string( 2.5*m, 2.5*m, 0, this->say_string );
-                       PopColor();
-                       
-               }
+                        gluUnProject( pos[0] + w, pos[1], pos[2], modelview, 
projection, viewport, &wx, &wy, &wz );
+                        w = wx;
+                        gluUnProject( pos[0], pos[1] + h, pos[2], modelview, 
projection, viewport, &wx, &wy, &wz );
+                        h = wy;
+                        
+                        // calculate speech bubble margin
+                        const float m = h/10;
+                        
+                        // draw inside of bubble
+                        PushColor( BUBBLE_FILL );
+                        glPushAttrib( GL_POLYGON_BIT | GL_LINE_BIT );
+                        glPolygonMode( GL_FRONT, GL_FILL );
+                        glEnable( GL_POLYGON_OFFSET_FILL );
+                        glPolygonOffset( 1.0, 1.0 );
+                        gl_draw_octagon( w, h, m );
+                        glDisable( GL_POLYGON_OFFSET_FILL );
+                        PopColor();
+                        
+                        // draw outline of bubble
+                        PushColor( BUBBLE_BORDER );
+                        glLineWidth( 1 );
+                        glEnable( GL_LINE_SMOOTH );
+                        glPolygonMode( GL_FRONT, GL_LINE );
+                        gl_draw_octagon( w, h, m );
+                        glPopAttrib();
+                        PopColor();
+                        
+                        PushColor( BUBBLE_TEXT );
+                        // draw text inside the bubble
+                        gl_draw_string( 2.5*m, 2.5*m, 0, this->say_string );
+                        PopColor();                    
+                 }
                glPopMatrix();
-    }
-       
-       if( stall )
-    {
+        }
+  
+  if( stall )
+        {
                DrawImage( TextureManager::getInstance()._stall_texture_id, 
cam, 0.85 );
-    }
+        }
 }
 
 stg_meters_t StgModel::ModelHeight()
@@ -1228,7 +1244,6 @@
   PopCoords();
 }
 
-
 void StgModel::DrawGrid( void )
 {
   if ( gui_grid ) 
@@ -1250,7 +1265,6 @@
     }
 }
 
-
 inline bool velocity_is_zero( stg_velocity_t& v )
 {
   return( !(v.x || v.y || v.z || v.a) );
@@ -1291,14 +1305,6 @@
         world->NeedRedraw();
 }
 
-// void StgModel::GPoseDirtyTree( void )
-// {
-//   this->gpose_dirty = true; // our global pose may have changed
-
-//   for( GList* it = this->children; it; it=it->next )
-//     ((StgModel*)it->data)->GPoseDirtyTree();
-// }
-
 void StgModel::SetPose( stg_pose_t pose )
 {
   //PRINT_DEBUG5( "%s.SetPose(%.2f %.2f %.2f %.2f)", 

Modified: code/stage/trunk/libstage/model_laser.cc
===================================================================
--- code/stage/trunk/libstage/model_laser.cc    2008-11-19 01:24:40 UTC (rev 
7158)
+++ code/stage/trunk/libstage/model_laser.cc    2008-11-19 08:22:32 UTC (rev 
7159)
@@ -319,11 +319,13 @@
       glTranslatef( 0,0, geom.size.z/2.0 ); // shoot the laser beam out at the 
right height
             
       // DEBUG - draw the origin of the laser beams
+      PushColor( 0,0,0,1.0 );
       glPointSize( 4.0 );
       glBegin( GL_POINTS );
       glVertex2f( 0,0 );
       glEnd();
-               
+               PopColor();
+
       // pack the laser hit points into a vertex array for fast rendering
       static float* pts = NULL;
       pts = (float*)g_realloc( pts, 2 * (sample_count+1) * sizeof(float));

Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh  2008-11-19 01:24:40 UTC (rev 7158)
+++ code/stage/trunk/libstage/stage.hh  2008-11-19 08:22:32 UTC (rev 7159)
@@ -1384,6 +1384,8 @@
   
         void DrawBlocksTree();
         virtual void DrawBlocks();
+        void DrawBoundingBox();
+        void DrawBoundingBoxTree();
         virtual void DrawStatus( Camera* cam );
         void DrawStatusTree( Camera* cam );
   
@@ -1924,6 +1926,8 @@
         virtual bool Save( const char* filename );
        
         inline virtual bool IsGUI() { return true; }
+
+        void DrawBoundingBoxTree();
        
         void Start(){ paused = false; };
         void Stop(){ paused = true; };

Modified: code/stage/trunk/libstage/stage_internal.hh
===================================================================
--- code/stage/trunk/libstage/stage_internal.hh 2008-11-19 01:24:40 UTC (rev 
7158)
+++ code/stage/trunk/libstage/stage_internal.hh 2008-11-19 08:22:32 UTC (rev 
7159)
@@ -81,39 +81,41 @@
   
   void AddModel( StgModel* mod );
 
-       Option
-               showBlinken, 
-               showBlocks, 
-               showClock, 
-               showData, 
-               showFlags,
-               showFollow,
-               showFootprints, 
-               showGrid, 
-               showOccupancy, 
-               showScreenshots,
-               showStatus,
-               showTrailArrows, 
-               showTrailRise, 
-               showTrails, 
-               showTree,
-               pCamOn,
-               visualizeAll;
+  Option showBlinken, 
+        showBlocks, 
+        showClock, 
+        showData, 
+        showFlags,
+        showFollow,
+        showFootprints, 
+        showGrid, 
+        showOccupancy, 
+        showScreenshots,
+        showStatus,
+        showTrailArrows, 
+        showTrailRise, 
+        showTrails, 
+        showTree,
+        showBBoxes,
+        showBlur,
+        pCamOn,
+        visualizeAll;
   
 public:
-       StgCanvas( StgWorldGui* world, int x, int y, int W,int H);
+       StgCanvas( StgWorldGui* world, int x, int y, int width, int height);
        ~StgCanvas();
 
        bool graphics;
        StgWorldGui* world;
 
        void Screenshot();
-  
+  void InitGl();
        void createMenuItems( Fl_Menu_Bar* menu, std::string path );
   
        void FixViewport(int W,int H);
        void DrawFloor(); //simpler floor compared to grid
        void DrawBlocks();
+  void DrawBoundingBoxes();
        void resetCamera();
        virtual void renderFrame();
        virtual void draw();

Modified: code/stage/trunk/libstage/world.cc
===================================================================
--- code/stage/trunk/libstage/world.cc  2008-11-19 01:24:40 UTC (rev 7158)
+++ code/stage/trunk/libstage/world.cc  2008-11-19 08:22:32 UTC (rev 7159)
@@ -239,8 +239,17 @@
   //g_hash_table_insert( blockgroups_by_entity, (gpointer)entity, 
mod->blockgroup );
 }
   
+// delete a model from the hash table
+static void destroy_sregion( gpointer dummy1, SuperRegion* sr, gpointer dummy2 
)
+{
+       free(sr);
+}
+
 void StgWorld::Load( const char* worldfile_path )
 {
+  // note: must call Unload() before calling Load() if a world already
+  // exists TODO: unload doesn't clean up enough right now
+
   GHashTable* entitytable = g_hash_table_new( g_direct_hash, g_direct_equal );
 
        printf( " [Loading %s]", worldfile_path );
@@ -338,11 +347,6 @@
        free(mod);
 }
 
-// delete a model from the hash table
-static void destroy_sregion( gpointer dummy1, SuperRegion* sr, gpointer dummy2 
)
-{
-       free(sr);
-}
 
 void StgWorld::UnLoad()
 {
@@ -877,7 +881,6 @@
         }
 }
 
-
 void StgWorld::Extend( stg_point3_t pt )
 {
        extent.x.min = MIN( extent.x.min, pt.x);

Modified: code/stage/trunk/libstage/worldgui.cc
===================================================================
--- code/stage/trunk/libstage/worldgui.cc       2008-11-19 01:24:40 UTC (rev 
7158)
+++ code/stage/trunk/libstage/worldgui.cc       2008-11-19 08:22:32 UTC (rev 
7159)
@@ -695,6 +695,10 @@
   }
 }
 
+void StgWorldGui::DrawBoundingBoxTree()
+{
+  LISTMETHOD( StgWorld::children, StgModel*, DrawBoundingBoxTree );
+}
 
 void StgWorldGui::PushColor( stg_color_t col )
 { canvas->PushColor( col ); } 

Modified: code/stage/trunk/worlds/fasr.world
===================================================================
--- code/stage/trunk/worlds/fasr.world  2008-11-19 01:24:40 UTC (rev 7158)
+++ code/stage/trunk/worlds/fasr.world  2008-11-19 08:22:32 UTC (rev 7159)
@@ -62,7 +62,7 @@
 
 define autorob pioneer2dx                
 (               
- sicklaser( samples 36 range_max 5 laser_return 2  )
+ sicklaser( samples 32 range_max 5 laser_return 2  )
  ctrl "fasr"
 )
 

Modified: code/stage/trunk/worlds/pioneer.inc
===================================================================
--- code/stage/trunk/worlds/pioneer.inc 2008-11-19 01:24:40 UTC (rev 7158)
+++ code/stage/trunk/worlds/pioneer.inc 2008-11-19 08:22:32 UTC (rev 7159)
@@ -131,7 +131,7 @@
 
   # use the sonar array defined above with a small vertical offset to
   # drop the sensors into the robot body
-  p2dx_sonar( pose [0.04 0 -0.03 0] ) 
+  p2dx_sonar( pose [0 0 -0.03 0] ) 
 
   # differential steering model
   drive "diff"


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to