Update of /cvsroot/playerstage/code/stage/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26448/src

Modified Files:
      Tag: opengl
        block.cc gui_gl.c matrix.c model.cc model_laser.cc 
        model_load.cc raytrace.cc stage_internal.h stg_time.cc 
        world.cc 
Log Message:
working on raytracing. fixed antialiasing bug

Index: model_laser.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/Attic/model_laser.cc,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** model_laser.cc      9 Jul 2007 00:03:24 -0000       1.1.2.2
--- model_laser.cc      10 Jul 2007 02:15:47 -0000      1.1.2.3
***************
*** 17,24 ****
--- 17,26 ----
  #include <sys/time.h>
  #include <math.h>
+ #include <GL/gl.h>
  
  #include "gui.h"
  #include "model.hh"
  
+ 
  #define TIMING 0
  #define LASER_FILLED 1
***************
*** 82,85 ****
--- 84,89 ----
    
    // sensible laser defaults 
+   this->update_interval_ms = 200; // common for a SICK LMS200
+ 
    stg_geom_t geom; 
    memset( &geom, 0, sizeof(geom));
***************
*** 155,161 ****
  
  void StgModelLaser::Update( void )
! {   
    StgModel::Update();
!   
    // no work to do if we're unsubscribed
    if( this->subs < 1 )
--- 159,167 ----
  
  void StgModelLaser::Update( void )
! {     
    StgModel::Update();
! 
!   puts( "LASER UPDATE" );
! 
    // no work to do if we're unsubscribed
    if( this->subs < 1 )
***************
*** 194,198 ****
        double bearing =  gpose.a - cfg->fov/2.0 + sample_incr * t;
        
!       itl_t* itl = itl_create( gpose.x, gpose.y,
                               bearing,
                               cfg->range_max,
--- 200,204 ----
        double bearing =  gpose.a - cfg->fov/2.0 + sample_incr * t;
        
!       itl_t* itl = itl_create( gpose.x, gpose.y, gpose.z,
                               bearing,
                               cfg->range_max,
***************
*** 213,217 ****
        if( hitmod )
        {
!         printf( "hit model %s\n", hitmod->Token() );
          scan[t].range = MAX( itl->range, cfg->range_min );
          scan[t].hitpoint.x = itl->x;
--- 219,223 ----
        if( hitmod )
        {
!         //printf( "hit model %s\n", hitmod->Token() );
          scan[t].range = MAX( itl->range, cfg->range_min );
          scan[t].hitpoint.x = itl->x;
***************
*** 272,276 ****
          (tv1.tv_sec + tv1.tv_usec / 1e6) );       
  #endif
- 
  }
  
--- 278,281 ----
***************
*** 311,312 ****
--- 316,384 ----
  //   StgModel::Draw();
  // }
+ 
+ void StgModelLaser::GuiGenerateData( void )
+ {
+   puts ("GL laser data" );
+ 
+   glNewList( this->dl_data, GL_COMPILE );
+ 
+   stg_laser_sample_t* samples = (stg_laser_sample_t*)this->data;
+   size_t sample_count = this->data_len / sizeof(stg_laser_sample_t);
+   stg_laser_config_t *cfg = (stg_laser_config_t*)this->cfg;
+   assert( cfg );
+   
+   if( samples && sample_count )
+     {
+       // do alpha properly
+       glDepthMask( GL_FALSE );
+       
+       glPushMatrix();
+       glTranslatef( 0,0, this->geom.size.z/2.0 ); // shoot the laser beam out 
at the right height
+       
+       // 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));
+       
+       pts[0] = 0.0;
+       pts[1] = 0.0;
+       
+       for( int s=0; s<sample_count; s++ )
+       {
+         double ray_angle = (s * (cfg->fov / (sample_count-1))) - 
cfg->fov/2.0;  
+         pts[2*s+2] = (float)(samples[s].range * cos(ray_angle) );
+         pts[2*s+3] = (float)(samples[s].range * sin(ray_angle) );
+       }
+       
+       glEnableClientState( GL_VERTEX_ARRAY );
+       glVertexPointer( 2, GL_FLOAT, 0, pts );
+       
+       glColor4f( 0, 0, 1, 0.2 );
+       glPolygonMode( GL_FRONT_AND_BACK, world->win->show_alpha ? GL_FILL : 
GL_LINES );
+       glDrawArrays( GL_POLYGON, 0, sample_count+1 );
+       
+       glPopMatrix();
+       glDepthMask( GL_TRUE );
+     }
+   
+   glEndList();
+   
+   world->win->dirty = true;
+ 
+   //make_dirty(mod);
+ 
+ /*   // loop through again, drawing bright boxes on top of the polygon */
+ /*   for( s=0; s<sample_count; s++ ) */
+ /*     {       */
+ /*       // if this hit point is bright, we draw a little box */
+ /*       if( samples[s].reflectance > 0 ) */
+ /*    { */
+  /*     stg_rtk_fig_color_rgb32( fg, bright_color ); */
+ /*      stg_rtk_fig_rectangle( fg,  */
+ /*                             points[1+s].x, points[1+s].y, 0, */
+ /*                             0.04, 0.04, 1 ); */
+ /*      stg_rtk_fig_color_rgb32( fg, laser_color ); */
+ /*    } */
+ /*     } */
+ }
+ 
+ 

Index: model.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/Attic/model.cc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** model.cc    9 Jul 2007 00:03:24 -0000       1.1.2.3
--- model.cc    10 Jul 2007 02:15:47 -0000      1.1.2.4
***************
*** 153,156 ****
--- 153,158 ----
                         bool inherit_color )
  {
+   //Map( 0 );
+   
    this->blocks = 
      g_list_prepend( this->blocks, 
***************
*** 161,164 ****
--- 163,168 ----
    // force recreation of display lists before drawing
    this->dirty = true;
+ 
+   //Map( 1 );
  }
  
***************
*** 330,333 ****
--- 334,340 ----
    this->gui_mask = this->parent ? 0 : STG_DEFAULT_MASK;
  
+   this->last_update_ms = -1;
+   this->update_interval_ms = 100;
+   
    // now we can add the basic square shape
    this->AddBlockRect( -0.5,-0.5,1,1 );
***************
*** 567,586 ****
  }
  
- 
- // // a virtual method init after the constructor
- // void StgModel::Initialize( void )
- // {
- //   printf( "Initialize model %s\n", this->token );
- 
- //   // TODO 
- //   // GUI init
- //   // other init?
- 
- // }
- 
- 
  void StgModel::Startup( void )
  {
    printf( "Startup model %s\n", this->token );
    CallCallbacks( &startup );
  }
--- 574,583 ----
  }
  
  void StgModel::Startup( void )
  {
    printf( "Startup model %s\n", this->token );
+ 
+   stg_world_start_updating_model( this->world, this );
+ 
    CallCallbacks( &startup );
  }
***************
*** 589,595 ****
--- 586,609 ----
  {
    printf( "Shutdown model %s\n", this->token );
+ 
+   stg_world_stop_updating_model( this->world, this );
+ 
    CallCallbacks( &shutdown );
  }
  
+ void StgModel::UpdateTreeIfDue( void )
+ {
+   if(  this->world->sim_time_ms  >= 
+        (this->last_update_ms + this->update_interval_ms) )
+     this->Update();
+   
+   LISTMETHOD( this->children, StgModel*, UpdateTreeIfDue );
+ }
+ 
+ void StgModel::UpdateTree( void )
+ {
+   LISTMETHOD( this->children, StgModel*, UpdateTree );
+ }
+ 
  void StgModel::Update( void )
  {
***************
*** 599,610 ****
    this->CallCallbacks( &update );
  
!   LISTMETHOD( this->children, StgModel*, Update );
  }
   
  
  void StgModel::Draw( void )
  {
!   //printf( "%s.Draw()\n",
!   //  this->token );
  
    glPushMatrix();
--- 613,643 ----
    this->CallCallbacks( &update );
  
!   this->last_update_ms = this->world->sim_time_ms;
  }
   
  
+ void StgModel::DrawData( void )
+ {
+   glPushMatrix();
+   
+   // move into this model's local coordinate frame
+   gl_pose_shift( &this->pose );
+   gl_pose_shift( &this->geom.pose );
+   
+   glCallList( this->dl_data );
+   
+   // shift up the CS to the top of this model
+   gl_coord_shift(  0,0, this->geom.size.z, 0 );
+   
+   // recursively draw the tree below this model 
+   LISTMETHOD( this->children, StgModel*, DrawData );
+ 
+   glPopMatrix(); // drop out of local coords
+ }
+ 
  void StgModel::Draw( void )
  {
!   printf( "%s.Draw()\n",
!     this->token );
  
    glPushMatrix();
***************
*** 627,632 ****
    
    glCallList( this->dl_body );
!   glCallList( this->dl_data );
!   glCallList( this->dl_data );
    
    // shift up the CS to the top of this model
--- 660,664 ----
    
    glCallList( this->dl_body );
!   //glCallList( this->dl_data );
    
    // shift up the CS to the top of this model
***************
*** 717,720 ****
--- 749,754 ----
    this->data_len = len;
  
+   this->GuiGenerateData();
+ 
    CallCallbacks( &this->data );
  }
***************
*** 1445,1447 ****
  
  
- 
--- 1479,1480 ----

Index: world.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/Attic/world.cc,v
retrieving revision 1.154.2.2
retrieving revision 1.154.2.3
diff -C2 -d -r1.154.2.2 -r1.154.2.3
*** world.cc    8 Jul 2007 05:24:04 -0000       1.154.2.2
--- world.cc    10 Jul 2007 02:15:47 -0000      1.154.2.3
***************
*** 86,97 ****
    snprintf( str, maxlen, "Ticks %lu Time: %lu:%lu:%02lu:%02lu.%03lu (sim:%3d 
real:%3d ratio:%2.2f)\tsubs: %d  %s",
            world->updates,
!           world->sim_time / (24*3600000), // days
!           world->sim_time / 3600000, // hours
!           (world->sim_time % 3600000) / 60000, // minutes
!           (world->sim_time % 60000) / 1000, // seconds
!           world->sim_time % 1000, // milliseconds
!           (int)world->sim_interval,
            (int)world->real_interval_measured,
!     (double)world->sim_interval / (double)world->real_interval_measured,
            world->subs,
            world->paused ? "--PAUSED--" : "" );
--- 86,97 ----
    snprintf( str, maxlen, "Ticks %lu Time: %lu:%lu:%02lu:%02lu.%03lu (sim:%3d 
real:%3d ratio:%2.2f)\tsubs: %d  %s",
            world->updates,
!           world->sim_time_ms / (24*3600000), // days
!           world->sim_time_ms / 3600000, // hours
!           (world->sim_time_ms % 3600000) / 60000, // minutes
!           (world->sim_time_ms % 60000) / 1000, // seconds
!           world->sim_time_ms % 1000, // milliseconds
!           (int)world->sim_interval_ms,
            (int)world->real_interval_measured,
!     (double)world->sim_interval_ms / (double)world->real_interval_measured,
            world->subs,
            world->paused ? "--PAUSED--" : "" );
***************
*** 100,109 ****
    snprintf( str, maxlen, "Ticks %lu Time: 
%lu:%lu:%02lu:%02lu.%03lu\t(sim/real:%2.2f)\tsubs: %d  %s",
            world->updates,
!           world->sim_time / (24*3600000), // days
!           world->sim_time / 3600000, // hours
!           (world->sim_time % 3600000) / 60000, // minutes
!           (world->sim_time % 60000) / 1000, // seconds
!           world->sim_time % 1000, // milliseconds
!           (double)world->sim_interval / (double)world->real_interval_measured,
            world->subs,
            world->paused ? "--PAUSED--" : "" );
--- 100,109 ----
    snprintf( str, maxlen, "Ticks %lu Time: 
%lu:%lu:%02lu:%02lu.%03lu\t(sim/real:%2.2f)\tsubs: %d  %s",
            world->updates,
!           world->sim_time_ms / (24*3600000), // days
!           world->sim_time_ms / 3600000, // hours
!           (world->sim_time_ms % 3600000) / 60000, // minutes
!           (world->sim_time_ms % 60000) / 1000, // seconds
!           world->sim_time_ms % 1000, // milliseconds
!           (double)world->sim_interval_ms / 
(double)world->real_interval_measured,
            world->subs,
            world->paused ? "--PAUSED--" : "" );
***************
*** 119,123 ****
  void stg_world_set_interval_sim( stg_world_t* world, unsigned int val )
  {
!   world->sim_interval = val;
  }
  
--- 119,123 ----
  void stg_world_set_interval_sim( stg_world_t* world, unsigned int val )
  {
!   world->sim_interval_ms = val;
  }
  
***************
*** 247,251 ****
  stg_world_t* stg_world_create( stg_id_t id, 
                               const char* token, 
!                              int sim_interval, 
                               int real_interval,
                               int gui_interval,
--- 247,251 ----
  stg_world_t* stg_world_create( stg_id_t id, 
                               const char* token, 
!                              int sim_interval_ms, 
                               int real_interval,
                               int gui_interval,
***************
*** 268,273 ****
    world->models = g_hash_table_new( g_int_hash, g_int_equal );
    world->models_by_name = g_hash_table_new( g_str_hash, g_str_equal );
!   world->sim_time = 0.0;
!   world->sim_interval = sim_interval;
    world->wall_interval = real_interval;
    world->gui_interval = gui_interval;
--- 268,273 ----
    world->models = g_hash_table_new( g_int_hash, g_int_equal );
    world->models_by_name = g_hash_table_new( g_str_hash, g_str_equal );
!   world->sim_time_ms = 0.0;
!   world->sim_interval_ms = sim_interval_ms;
    world->wall_interval = real_interval;
    world->gui_interval = gui_interval;
***************
*** 372,380 ****
        printf( " [%d %lu %f] sim:%lu real:%lu  ratio:%.2f freq:%.2f \n",
              world->id, 
!             world->sim_time,
              world->updates,
!             world->sim_interval,
              world->real_interval_measured,
!             (double)world->sim_interval / 
(double)world->real_interval_measured,
              world->updates/t );
        
--- 372,380 ----
        printf( " [%d %lu %f] sim:%lu real:%lu  ratio:%.2f freq:%.2f \n",
              world->id, 
!             world->sim_time_ms,
              world->updates,
!             world->sim_interval_ms,
              world->real_interval_measured,
!             (double)world->sim_interval_ms / 
(double)world->real_interval_measured,
              world->updates/t );
        
***************
*** 383,402 ****
        
        // TEST DEBUGGING
!       glNewList( dl_debug, GL_COMPILE );
!       push_color_rgb( 0,1,0 );
  
!       glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
  
!       for( GList* it=world->children; it; it=it->next )
!       ((StgModel*)it->data)->Update();
  
!       pop_color();
!       glEndList(); // dl_debug
  
        
        world->wall_last_update = timenow;        
!       world->sim_time += world->sim_interval;
! 
!       
      }
  
--- 383,401 ----
        
        // TEST DEBUGGING
!       //glNewList( dl_debug, GL_COMPILE );
!       //push_color_rgb( 0,1,0 );
  
!       //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
  
!       for( GList* it=world->update_list; it; it=it->next )
!       ((StgModel*)it->data)->UpdateTreeIfDue();
  
!       //pop_color();
!       //glEndList(); // dl_debug
  
        
        world->wall_last_update = timenow;        
!       world->sim_time_ms += world->sim_interval_ms;
!     
      }
  

Index: stage_internal.h
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/stage_internal.h,v
retrieving revision 1.58.2.16
retrieving revision 1.58.2.17
diff -C2 -d -r1.58.2.16 -r1.58.2.17
*** stage_internal.h    9 Jul 2007 00:03:24 -0000       1.58.2.16
--- stage_internal.h    10 Jul 2007 02:15:47 -0000      1.58.2.17
***************
*** 70,74 ****
      stg_color_t color;
      bool inherit_color;
!     int display_list; //< id of the OpenGL displaylist to draw this block
    } stg_block_t;
    
--- 70,74 ----
      stg_color_t color;
      bool inherit_color;
!     //    int display_list; //< id of the OpenGL displaylist to draw this 
block
    } stg_block_t;
    
***************
*** 254,259 ****
      char* token; ///< the name of this world
  
!     stg_msec_t sim_time; ///< the current time in this world
!     stg_msec_t sim_interval; ///< this much simulated time elapses each step.
      long unsigned int updates; ///< the number of simulaticuted
      
--- 254,259 ----
      char* token; ///< the name of this world
  
!     stg_msec_t sim_time_ms; ///< the current time in this world
!     stg_msec_t sim_interval_ms; ///< this much simulated time elapses each 
step.
      long unsigned int updates; ///< the number of simulaticuted
      
***************
*** 285,288 ****
--- 285,290 ----
    };
  
+ void stg_world_start_updating_model( stg_world_t* world, StgModel* mod );
+ void stg_world_stop_updating_model( stg_world_t* world, StgModel* mod );
  
    // ROTATED RECTANGLES -------------------------------------------------
***************
*** 464,468 ****
   typedef struct
    {
!     double x, y, a;
      double cosa, sina, tana;
      double range;
--- 466,470 ----
   typedef struct
    {
!     double x, y, z, a;
      double cosa, sina, tana;
      double range;
***************
*** 479,483 ****
    typedef int(*stg_itl_test_func_t)(StgModel* finder, StgModel* found );
  
!   itl_t* itl_create( double x, double y, double a, double b, 
                   stg_matrix_t* matrix, itl_mode_t pmode );
  
--- 481,485 ----
    typedef int(*stg_itl_test_func_t)(StgModel* finder, StgModel* found );
  
! itl_t* itl_create( double x, double y, double z, double a, double b, 
                   stg_matrix_t* matrix, itl_mode_t pmode );
  

Index: raytrace.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/Attic/raytrace.cc,v
retrieving revision 1.12.2.2
retrieving revision 1.12.2.3
diff -C2 -d -r1.12.2.2 -r1.12.2.3
*** raytrace.cc 9 Jul 2007 00:03:24 -0000       1.12.2.2
--- raytrace.cc 10 Jul 2007 02:15:47 -0000      1.12.2.3
***************
*** 55,59 ****
  }
  
! itl_t* itl_create( double x, double y, double a, double b, 
                   stg_matrix_t* matrix, itl_mode_t pmode )
  {   
--- 55,59 ----
  }
  
! itl_t* itl_create( double x, double y, double z, double a, double b, 
                   stg_matrix_t* matrix, itl_mode_t pmode )
  {   
***************
*** 63,66 ****
--- 63,67 ----
    itl->x = x;
    itl->y = y;
+   itl->z = z;
    itl->models = NULL;
    itl->index = 0;
***************
*** 161,164 ****
--- 162,166 ----
  // returns the first model in the array that matches, else NULL.
  static StgModel* gslist_first_matching( GSList* list, 
+                                       stg_meters_t z,
                                        stg_itl_test_func_t func, 
                                        StgModel* finder )
***************
*** 168,187 ****
        stg_block_t* block = (stg_block_t*)list->data;
  
!       // test the block's height. It must overlap the origin of the
!       // finding model
  
        stg_pose_t gpose;
!       finder->GetGlobalPose( &gpose );
! 
!       stg_geom_t geom;
!       finder->GetGeom( &geom );
! 
!       //if( (block->zmin < gpose.z - geom.size.z/2.0) || 
!       //  (block->zmax > gpose.z + geom.size.z/2.0) )
!       //return NULL; // no overlap
! 
!       StgModel* candidate = block->mod;
  
!       if( (*func)( finder, candidate ) )
        return candidate;
      }
--- 170,185 ----
        stg_block_t* block = (stg_block_t*)list->data;
  
!       // test to see if the block exists at height z
!       StgModel* candidate = block->mod;
  
        stg_pose_t gpose;
!       candidate->GetGlobalPose( &gpose );
  
!      double block_min = gpose.z + block->zmin;
!       double block_max = gpose.z + block->zmax;
!       
!       if( block_min < z && 
!         block_max > z && 
!         (*func)( finder, candidate ) )
        return candidate;
      }
***************
*** 260,264 ****
        { 
          StgModel* hitmod = 
!           gslist_first_matching( (GSList*)cell->data, func, finder );
          
          if( hitmod ) 
--- 258,262 ----
        { 
          StgModel* hitmod = 
!           gslist_first_matching( (GSList*)cell->data, itl->z, func, finder );
          
          if( hitmod ) 

Index: model_load.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/Attic/model_load.cc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** model_load.cc       9 Jul 2007 00:03:24 -0000       1.1.2.3
--- model_load.cc       10 Jul 2007 02:15:47 -0000      1.1.2.4
***************
*** 6,15 ****
  
  void StgModel::Load( void )
! {
!   
! 
!   //const char* typestr = wf_read_string( mod->id, "type", NULL );
!   //PRINT_MSG2( "Model %p is type %s", mod, typestr );
!   
    if( wf->PropertyExists( this->id, "name" ) )
      {
--- 6,10 ----
  
  void StgModel::Load( void )
! {  
    if( wf->PropertyExists( this->id, "name" ) )
      {
***************
*** 24,27 ****
--- 19,24 ----
      }
  
+   PRINT_WARN1( "%s::Load", token );
+ 
    if( wf->PropertyExists( this->id, "origin" ) )
      {
***************
*** 75,139 ****
      }
    
-   if( wf->PropertyExists( this->id, "mass" ))
-     {
-       stg_kg_t mass = wf->ReadFloat(this->id, "mass", this->mass );      
-       this->SetMass( mass );
-     }
-   
-   if( wf->PropertyExists( this->id, "fiducial_return" ))
-     {
-       int fid = 
-       wf->ReadInt( this->id, "fiducial_return", this->fiducial_return );     
-       this->SetFiducialReturn( fid  );
-     }
- 
-   if( wf->PropertyExists( this->id, "fiducial_key" ))
-     {
-       int fkey = 
-       wf->ReadInt( this->id, "fiducial_key", this->fiducial_key );     
-       this->SetFiducialKey( fkey );
-     }
-   
-   if( wf->PropertyExists( this->id, "obstacle_return" ))
-     {
-       int obs = 
-       wf->ReadInt( this->id, "obstacle_return", this->obstacle_return );
-       this->SetObstacleReturn( obs  );
-     }
-   
-   if( wf->PropertyExists( this->id, "ranger_return" ))
-     {
-       int rng = 
-       wf->ReadInt( this->id, "ranger_return", this->ranger_return );
-       this->SetRangerReturn( rng );
-     }
-   
-   if( wf->PropertyExists( this->id, "blob_return" ))
-     {
-       int blb = 
-       wf->ReadInt( this->id, "blob_return", this->blob_return );      
-       this->SetBlobReturn( blb );
-     }
-   
-   if( wf->PropertyExists( this->id, "laser_return" ))
-     {
-       int lsr = 
-       wf->ReadInt(this->id, "laser_return", this->laser_return );      
-       this->SetLaserReturn( lsr );
-     }
-   
-   if( wf->PropertyExists( this->id, "gripper_return" ))
-     {
-       int grp = 
-       wf->ReadInt( this->id, "gripper_return", this->gripper_return );
-       this->SetGripperReturn( grp );
-     }
-   
    if( wf->PropertyExists( this->id, "boundary" ))
!     {
!       int bdy =  
!       wf->ReadInt(this->id, "boundary", this->boundary  ); 
!       this->SetBoundary( bdy );
!     }
    
    if( wf->PropertyExists( this->id, "color" ))
--- 72,77 ----
      }
    
    if( wf->PropertyExists( this->id, "boundary" ))
!       this->SetBoundary( wf->ReadInt(this->id, "boundary", this->boundary  ));
    
    if( wf->PropertyExists( this->id, "color" ))
***************
*** 268,289 ****
        
        stg_block_list_scale( this->blocks, &this->geom.size );
-       }
  
      
!     int gui_nose = wf->ReadInt(this->id, "gui_nose", this->gui_nose );  
!     this->SetGuiNose(gui_nose );
!     
!     int gui_grid = wf->ReadInt(this->id, "gui_grid", this->gui_grid );  
!     this->SetGuiGrid( gui_grid );
    
-     int gui_outline = wf->ReadInt(this->id, "gui_outline", this->gui_outline 
);  
-     this->SetGuiOutline( gui_outline );
-     
-     stg_movemask_t gui_movemask = wf->ReadInt(this->id, "gui_movemask", 
this->gui_mask );  
-     this->SetGuiMask( gui_movemask );
-     
-     stg_meters_t mres = wf->ReadFloat(this->id, "map_resolution", 
this->map_resolution );  
-     this->SetMapResolution( mres );
-     
      // call any type-specific load callbacks
      this->CallCallbacks( &this->load );
--- 206,251 ----
        
        stg_block_list_scale( this->blocks, &this->geom.size );
  
+       }
      
!  if( wf->PropertyExists( this->id, "mass" ))
!     this->SetMass( wf->ReadFloat(this->id, "mass", this->mass ));
!   
!   if( wf->PropertyExists( this->id, "fiducial_return" ))
!     this->SetFiducialReturn( wf->ReadInt( this->id, "fiducial_return", 
this->fiducial_return ));
!   
!   if( wf->PropertyExists( this->id, "fiducial_key" ))
!       this->SetFiducialKey( wf->ReadInt( this->id, "fiducial_key", 
this->fiducial_key ));
!   
!   if( wf->PropertyExists( this->id, "obstacle_return" ))
!     this->SetObstacleReturn( wf->ReadInt( this->id, "obstacle_return", 
this->obstacle_return ));
!   
!   if( wf->PropertyExists( this->id, "ranger_return" ))
!     this->SetRangerReturn( wf->ReadInt( this->id, "ranger_return", 
this->ranger_return ));
!   
!   if( wf->PropertyExists( this->id, "blob_return" ))
!     this->SetBlobReturn( wf->ReadInt( this->id, "blob_return", 
this->blob_return ));
!   
!   if( wf->PropertyExists( this->id, "laser_return" ))
!     this->SetLaserReturn( wf->ReadInt(this->id, "laser_return", 
this->laser_return ));
!   
!   if( wf->PropertyExists( this->id, "gripper_return" ))
!     this->SetGripperReturn( wf->ReadInt( this->id, "gripper_return", 
this->gripper_return ));
!   
!   if( wf->PropertyExists( this->id, "gui_nose" ))
!     this->SetGuiNose( wf->ReadInt(this->id, "gui_nose", this->gui_nose ));    
!   
!   if( wf->PropertyExists( this->id, "gui_grid" ))
!     this->SetGuiGrid( wf->ReadInt(this->id, "gui_grid", this->gui_grid ));  
!   
!   if( wf->PropertyExists( this->id, "gui_outline" ))
!     this->SetGuiOutline( wf->ReadInt(this->id, "gui_outline", 
this->gui_outline )); 
!   
!   if( wf->PropertyExists( this->id, "gui_movemask" ))
!     this->SetGuiMask( wf->ReadInt(this->id, "gui_movemask", this->gui_mask ));
!   
!   if( wf->PropertyExists( this->id, "map_resolution" ))
!     this->SetMapResolution( wf->ReadFloat(this->id, "map_resolution", 
this->map_resolution )); 
    
      // call any type-specific load callbacks
      this->CallCallbacks( &this->load );

Index: gui_gl.c
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/Attic/gui_gl.c,v
retrieving revision 1.1.2.26
retrieving revision 1.1.2.27
diff -C2 -d -r1.1.2.26 -r1.1.2.27
*** gui_gl.c    9 Jul 2007 00:03:24 -0000       1.1.2.26
--- gui_gl.c    10 Jul 2007 02:15:47 -0000      1.1.2.27
***************
*** 634,648 ****
      }
  
    glEnable (GL_DEPTH_TEST);
    glDepthFunc (GL_LESS);
    glClearColor ( 0.7, 0.7, 0.8, 1.0);
!   //glClearColor ( 0,0,0, 1.0);
    gdk_gl_glPolygonOffsetEXT (proc, 1.0, 1.0);
  
    glEnable (GL_CULL_FACE);
!   glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
!   glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
!   glDisable (GL_LIGHTING);
    
    gdk_gl_drawable_gl_end (gldrawable);
  
--- 634,659 ----
      }
  
+   glDisable (GL_LIGHTING);
+   
    glEnable (GL_DEPTH_TEST);
    glDepthFunc (GL_LESS);
    glClearColor ( 0.7, 0.7, 0.8, 1.0);
! 
    gdk_gl_glPolygonOffsetEXT (proc, 1.0, 1.0);
  
+   glCullFace( GL_BACK );
    glEnable (GL_CULL_FACE);
! 
!   //glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
!   //glEnable( GL_POLYGON_SMOOTH );
    
+   // set gl state that won't change every redraw
+   glEnable( GL_BLEND );
+   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+   glEnable( GL_LINE_SMOOTH );
+   glHint (GL_LINE_SMOOTH_HINT, GL_FASTEST);
+   glEnable(GL_DEPTH_TEST);
+   glDepthMask(GL_TRUE);
+ 
    gdk_gl_drawable_gl_end (gldrawable);
  
***************
*** 807,824 ****
  
    // clear the offscreen buffer
!   glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
-   glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- 
-   if( win->show_alpha )
-     { 
-       glEnable(GL_LINE_SMOOTH); 
-       glEnable(GL_BLEND);
-     }
-   else
-     {
-       glDisable(GL_BLEND);
-       glDisable(GL_LINE_SMOOTH);
-     }
  
    double zclip = hypot(world->width, world->height) * win->scale;
--- 818,823 ----
  
    // clear the offscreen buffer
!   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    
  
    double zclip = hypot(world->width, world->height) * win->scale;
***************
*** 909,912 ****
--- 908,912 ----
    // draw the floor a little pushed into the distance so it doesn't z-fight 
with the
    // models
+   glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    glEnable(GL_POLYGON_OFFSET_FILL);
    glPolygonOffset(1.0, 1.0);
***************
*** 923,937 ****
    if( win->show_matrix )
      {
        glTranslatef( 0,0,1 );
!       glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
        push_color_rgb( 0,1,0 );
        stg_cell_render_tree( world->matrix->root );
        glTranslatef( 0,0,-1 );
        pop_color();
      }
  
    push_color_rgb( 1, 0, 0 );
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
!   glLineWidth( 2 );
    g_list_foreach( world->win->selected_models, (GFunc)gl_model_selected, NULL 
);
    glLineWidth( 1 );
--- 923,940 ----
    if( win->show_matrix )
      {
+       glDisable( GL_LINE_SMOOTH );
+       glLineWidth( 1 );
        glTranslatef( 0,0,1 );
!       glPolygonMode( GL_FRONT, GL_LINE );
        push_color_rgb( 0,1,0 );
        stg_cell_render_tree( world->matrix->root );
        glTranslatef( 0,0,-1 );
        pop_color();
+       glEnable( GL_LINE_SMOOTH );
      }
  
    push_color_rgb( 1, 0, 0 );
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
!   glLineWidth( 4 );
    g_list_foreach( world->win->selected_models, (GFunc)gl_model_selected, NULL 
);
    glLineWidth( 1 );
***************
*** 942,945 ****
--- 945,951 ----
      ((StgModel*)it->data)->Draw();
  
+   for( it=world->children; it; it=it->next )
+     ((StgModel*)it->data)->DrawData();
+ 
  
    // draw anything in the assorted displaylist list
***************
*** 951,955 ****
      }
  
!   
  
  
--- 957,970 ----
      }
  
! 
!   glLineWidth( 2.0 );
!   push_color_rgb( 1,0,0 );
!   glBegin( GL_LINE_LOOP );
!      glVertex3f( 0,0,0 );
!      glVertex3f( 1,0,0 );
!      glVertex3f( 1,1,0 );
!      glVertex3f( 0,1,0 );
!   glEnd();
!   pop_color();
  
  
***************
*** 1442,1450 ****
    dl_debug = glGenLists(1);
  
-   // set gl state that won't change every redraw
-   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
-   glEnable(GL_DEPTH_TEST);
-   glDepthMask(GL_TRUE);
- 
    return drawing_area;
  }
--- 1457,1460 ----
***************
*** 1537,1626 ****
  
  
- /* int gl_laser_render_data( stg_model_t* mod, void* enabled ) */
- /* { */
- /*   //puts ("GL laser data" ); */
- /*   int list = gui_model_get_displaylist( mod, LIST_DATA ); */
-   
- /*   glNewList( list, GL_COMPILE ); */
- 
- 
  
- /*   // end exp */
- 
- /*   stg_laser_sample_t* samples = (stg_laser_sample_t*)mod->data;  */
- /*   size_t sample_count = mod->data_len / sizeof(stg_laser_sample_t); */
- /*   stg_laser_config_t *cfg = (stg_laser_config_t*)mod->cfg; */
- /*   assert( cfg ); */
-   
- /*   if( samples && sample_count ) */
- /*     {     */
- /*       stg_pose_t gpose; */
- /*       stg_model_get_global_pose( mod, &gpose ); */
- 
- /*   // do alpha properly */
- /*       glDepthMask( GL_FALSE ); */
-       
- /*       glPushMatrix(); */
- /*       glTranslatef( 0,0, gpose.z + mod->geom.size.z/2.0 ); // shoot the 
laser beam out at the right height */
-       
- /*       // 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)); 
*/
-       
- /*       pts[0] = (float)gpose.x; */
- /*       pts[1] = (float)gpose.y; */
-       
- /*       int s; */
- /*       for( s=0; s<sample_count; s++ ) */
- /*    { */
- /*      double ray_angle = gpose.a + (s * (cfg->fov / (sample_count-1))) - 
cfg->fov/2.0; */
- 
- /*      //pts[2*s+2] = (float)samples[s].hitpoint.x; */
- /*      //pts[2*s+3] = (float)samples[s].hitpoint.y; */
- /*      pts[2*s+2] = (float)(samples[s].range * cos(ray_angle) + gpose.x); */
- /*      pts[2*s+3] = (float)(samples[s].range * sin(ray_angle) + gpose.y); */
- /*    } */
-       
- /*       glEnableClientState( GL_VERTEX_ARRAY ); */
- /*       glVertexPointer( 2, GL_FLOAT, 0, pts ); */
-       
- /*       if( mod->world->win->show_alpha ) */
- /*    { */
- /*      glColor4f( 0, 0, 1, 0.1 ); */
- /*      glDrawArrays( GL_POLYGON, 0, sample_count+1 ); */
- /*    } */
- /*       else */
- /*    { */
- /*      glColor3f( 0.5, 0.5, 1.0 ); */
- /*      glDrawArrays( GL_LINE_LOOP, 0, sample_count+1 ); */
- /*    } */
-       
- /*       //free(pts); */
- /*       glPopMatrix(); */
- /*       glDepthMask( GL_TRUE );  */
- /*     } */
-   
- 
- /*   glEndList(); */
-   
- /*   make_dirty(mod); */
- 
- /* /\*   // loop through again, drawing bright boxes on top of the polygon 
*\/ */
- /* /\*   for( s=0; s<sample_count; s++ ) *\/ */
- /* /\*     {       *\/ */
- /* /\*       // if this hit point is bright, we draw a little box *\/ */
- /* /\*       if( samples[s].reflectance > 0 ) *\/ */
- /* /\*        { *\/ */
- /* /\*          stg_rtk_fig_color_rgb32( fg, bright_color ); *\/ */
- /* /\*          stg_rtk_fig_rectangle( fg,  *\/ */
- /* /\*                                 points[1+s].x, points[1+s].y, 0, *\/ */
- /* /\*                                 0.04, 0.04, 1 ); *\/ */
- /* /\*          stg_rtk_fig_color_rgb32( fg, laser_color ); *\/ */
- /* /\*        } *\/ */
- /* /\*     } *\/ */
-       
- /*   return 0; // callback runs until removed */
- /* } */
  
  /* int gl_fiducial_render_data( stg_model_t* mod, void* enabled ) */
--- 1547,1551 ----

Index: block.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/Attic/block.cc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** block.cc    9 Jul 2007 00:03:24 -0000       1.1.2.3
--- block.cc    10 Jul 2007 02:15:47 -0000      1.1.2.4
***************
*** 27,34 ****
    block->inherit_color = inherit_color;
  
-   // generate an OpenGL displaylist for this block
-   block->display_list = glGenLists( 1 );  
-   stg_block_update( block );
- 
    return block;
  }
--- 27,30 ----
***************
*** 37,44 ****
  void stg_block_destroy( stg_block_t* block )
  {
-   assert( block );
    assert( block->pts );
  
-   glDeleteLists( block->display_list, 1 );
    g_free( block->pts );
    g_free( block );
--- 33,39 ----
  void stg_block_destroy( stg_block_t* block )
  {
    assert( block->pts );
+   assert( block );
  
    g_free( block->pts );
    g_free( block );
***************
*** 53,73 ****
  }
   
- void stg_block_render( stg_block_t* b )
- {
-   //printf( "rendering block @ %p with %d points\n", b, (int)b->pt_count );
-   glCallList( b->display_list );
- }
  
  static void block_top( stg_block_t* b )
  {
-   //stg_geom_t geom;      
-   //b->mod->GetGeom( &geom );
- 
    // draw a top that fits over the stripa
    glBegin(GL_POLYGON);
    for( unsigned int p=0; p<b->pt_count; p++)
-     {
      glVertex3f( b->pts[p].x, b->pts[p].y, b->zmax );
-     }
    glEnd();
  }
--- 48,58 ----
***************
*** 75,81 ****
  static void block_sides( stg_block_t* b )
  {
-   //stg_geom_t geom;      
-   //b->mod->GetGeom( &geom );
-   
    // construct a strip that wraps around the polygon
    glBegin(GL_QUAD_STRIP);
--- 60,63 ----
***************
*** 91,99 ****
  }
  
- void stg_block_update( stg_block_t* b )
- { 
-   // draw filled color polygons
  
!   glNewList( b->display_list, GL_COMPILE );
  
    stg_color_t color;
--- 73,80 ----
  }
  
  
! void stg_block_render( stg_block_t* b )
! {
!   // draw filled color polygons
  
    stg_color_t color;
***************
*** 106,112 ****
    stg_color_to_glcolor4dv( color, gcol );
  
-   //glDisable(GL_BLEND);
-   //glDisable(GL_LINE_SMOOTH);
-   
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL );
    push_color( gcol );
--- 87,90 ----
***************
*** 118,121 ****
--- 96,100 ----
    
  
+   
    // draw the block outline in a darker version of the same color
    gcol[0]/=2.0;
***************
*** 124,141 ****
    push_color( gcol );
  
-   glLineWidth( 0 );
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE );
    block_top( b );
    block_sides( b );  
  
-   //glEnable(GL_BLEND);
-   //glEnable(GL_LINE_SMOOTH);
  
    pop_color();
-   pop_color();
- 
-   glEndList();
  }
  
  void stg_block_list_scale( GList* blocks, 
                           stg_size_t* size )
--- 103,118 ----
    push_color( gcol );
  
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE );
+   glDepthMask(GL_FALSE); 
    block_top( b );
    block_sides( b );  
+   glDepthMask(GL_TRUE); 
  
  
+   //pop_color();
    pop_color();
  }
  
+ 
  void stg_block_list_scale( GList* blocks, 
                           stg_size_t* size )
***************
*** 203,207 ****
  
        // recalculate the GL drawlist
!       stg_block_update( block );
      }
  }
--- 180,184 ----
  
        // recalculate the GL drawlist
!       //stg_block_update( block );
      }
  }

Index: stg_time.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/stg_time.cc,v
retrieving revision 1.11
retrieving revision 1.11.6.1
diff -C2 -d -r1.11 -r1.11.6.1
*** stg_time.cc 20 Sep 2005 00:36:24 -0000      1.11
--- stg_time.cc 10 Jul 2007 02:15:47 -0000      1.11.6.1
***************
*** 33,39 ****
  #include "p_driver.h"
  
- // Stage's global quit flag
- extern int _stg_quit;
- 
  // Constructor
  StgTime::StgTime( StgDriver* driver )
--- 33,36 ----
***************
*** 50,55 ****
  }
  
- extern int update_request;
- 
  // Get the simulator time
  int StgTime::GetTime(struct timeval* time)
--- 47,50 ----
***************
*** 61,66 ****
    stg_world_t* world = driver->world;
    
!   time->tv_sec  = (int)floor(world->sim_time / 1e3);
!   time->tv_usec = (int)rint(fmod(world->sim_time,1e3) * 1e3);
    
    PRINT_DEBUG2( "time now %ld sec %ld usec", time->tv_sec, time->tv_usec );
--- 56,61 ----
    stg_world_t* world = driver->world;
    
!   time->tv_sec  = (int)floor(world->sim_time_ms / 1e3);
!   time->tv_usec = (int)rint(fmod(world->sim_time_ms,1e3) * 1e3);
    
    PRINT_DEBUG2( "time now %ld sec %ld usec", time->tv_sec, time->tv_usec );
***************
*** 77,81 ****
    stg_world_t* world = driver->world;
    
!   *time = world->sim_time / 1e3;
    
    PRINT_DEBUG1( "time now %f sec ", *time);
--- 72,76 ----
    stg_world_t* world = driver->world;
    
!   *time = world->sim_time_ms / 1e3;
    
    PRINT_DEBUG1( "time now %f sec ", *time);

Index: matrix.c
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/matrix.c,v
retrieving revision 1.22.4.5
retrieving revision 1.22.4.6
diff -C2 -d -r1.22.4.5 -r1.22.4.6
*** matrix.c    8 Jul 2007 05:24:04 -0000       1.22.4.5
--- matrix.c    10 Jul 2007 02:15:47 -0000      1.22.4.6
***************
*** 52,65 ****
  void stg_cell_render( stg_cell_t* cell )
  {
-   //puts( "cell render" );
- 
-   //glPolygonMode( GL_FRONT_AND_BACK, GL_LINES );
- 
    double dx = cell->size/2.0;
- 
    glRectf( cell->x-dx , cell->y-dx, cell->x+dx, cell->y+dx );
- 
-   //printf( "cell %.2f,%.2f size %.2f\n", 
-   //  cell->x, cell->y, cell->size );
  }
  
--- 52,57 ----


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to