Update of /cvsroot/playerstage/code/stage/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22379/src
Modified Files:
Tag: opengl
gui_gl.c model.c model_laser.c
Log Message:
very very broken - trying things out
Index: gui_gl.c
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/Attic/gui_gl.c,v
retrieving revision 1.1.2.15
retrieving revision 1.1.2.16
diff -C2 -d -r1.1.2.15 -r1.1.2.16
*** gui_gl.c 18 May 2007 05:21:07 -0000 1.1.2.15
--- gui_gl.c 19 May 2007 02:33:28 -0000 1.1.2.16
***************
*** 436,440 ****
// pack the laser hit points into a vertex array for fast rendering
! float* pts = malloc( 2 * (1+sample_count) * sizeof(float));
pts[0] = (float)gpose.x;
--- 436,442 ----
// pack the laser hit points into a vertex array for fast rendering
!
! static float* pts = NULL;
! pts = g_realloc( pts, 2 * (sample_count+1) * sizeof(float));
pts[0] = (float)gpose.x;
***************
*** 444,449 ****
for( s=0; s<sample_count; s++ )
{
! pts[2*s+2] = (float)samples[s].hitpoint.x;
! pts[2*s+3] = (float)samples[s].hitpoint.y;
}
--- 446,455 ----
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);
}
***************
*** 462,492 ****
}
! free(pts);
glPopMatrix();
glDepthMask( GL_TRUE );
}
! // outline the polgons that the selected robot intersects with
! push_color_stgcolor( stg_lookup_color( "orange" ));
! GList *b;
! for( b = mod->sense_poly->intersectors; b; b=b->next )
! {
! stg_polygon_t* p = (stg_polygon_t*)b->data;
! glPushMatrix();
! stg_pose_t pose;
! stg_model_get_global_pose( p->mod, &pose );
! // move into this model's coordinate frame
! glTranslatef( pose.x, pose.y, pose.z );
! glRotatef( RTOD(pose.a), 0,0,1 );
! gl_draw_polygon3d( p );
! glPopMatrix();
! }
! pop_color();
glEndList();
--- 468,498 ----
}
! //free(pts);
glPopMatrix();
glDepthMask( GL_TRUE );
}
! /* // outline the polgons that the selected robot intersects with */
! /* push_color_stgcolor( stg_lookup_color( "orange" )); */
! /* GList *b; */
! /* for( b = mod->sense_poly->intersectors; b; b=b->next ) */
! /* { */
! /* stg_polygon_t* p = (stg_polygon_t*)b->data; */
! /* glPushMatrix(); */
! /* stg_pose_t pose; */
! /* stg_model_get_global_pose( p->mod, &pose ); */
! /* // move into this model's coordinate frame */
! /* glTranslatef( pose.x, pose.y, pose.z ); */
! /* glRotatef( RTOD(pose.a), 0,0,1 ); */
! /* gl_draw_polygon3d( p ); */
! /* glPopMatrix(); */
! /* } */
! /* pop_color(); */
glEndList();
***************
*** 1208,1216 ****
--- 1214,1225 ----
void model_bbox_cb( gpointer key, stg_model_t* mod, void* user )
{
+ push_color_stgcolor( mod->color );
g_list_foreach( mod->polys, (GFunc)gl_draw_polygon_bbox_cb, NULL );
+ pop_color();
}
+
void draw_thumbnail( stg_world_t* world )
{
***************
*** 1330,1334 ****
assert( ep->polygon->mod );
! push_color_stgcolor( ep->polygon->color );
glBegin( GL_POLYGON );
--- 1339,1343 ----
assert( ep->polygon->mod );
! push_color_stgcolor( ep->polygon->mod->color );
glBegin( GL_POLYGON );
***************
*** 1359,1363 ****
for( ep = world->endpts.y; ep; ep=ep->next )
{
! push_color_stgcolor( ep->polygon->color );
glBegin( GL_POLYGON );
--- 1368,1372 ----
for( ep = world->endpts.y; ep; ep=ep->next )
{
! push_color_stgcolor( ep->polygon->mod->color );
glBegin( GL_POLYGON );
***************
*** 1380,1417 ****
glPrint( "%d", (int)i++ );
! glRasterPos2f( -0.8, ep->value );
glPrint( "%.2f", ep->value );
pop_color();
}
! i=0;
! for( ep = world->endpts.z; ep; ep=ep->next )
! {
! push_color_stgcolor( ep->polygon->color );
! glBegin( GL_POLYGON );
! glVertex3f( 0, 0, ep->value );
! if( ep->type == 0 )
! {
! glVertex3f( -hepsilon, 0, ep->value+hepsilon );
! glVertex3f( -epsilon, 0, ep->value );
! }
! else
! {
! glVertex3f( -epsilon, 0, ep->value );
! glVertex3f( -hepsilon, 0, ep->value-hepsilon );
! }
! glEnd();
! glRasterPos3f( -0.5, 0, ep->value );
! glPrint( "%d", (int)i++ );
! glRasterPos3f( -0.8, 0, ep->value );
! glPrint( "%.2f", ep->value );
! pop_color();
! }
//puts( "\n" );
--- 1389,1426 ----
glPrint( "%d", (int)i++ );
! glRasterPos2f( -0.8, ep->value - 0.3 );
glPrint( "%.2f", ep->value );
pop_color();
}
! /* i=0; */
! /* for( ep = world->endpts.z; ep; ep=ep->next ) */
! /* { */
! /* push_color_stgcolor( ep->polygon->color ); */
! /* glBegin( GL_POLYGON ); */
! /* glVertex3f( 0, 0, ep->value ); */
! /* if( ep->type == 0 ) */
! /* { */
! /* glVertex3f( -hepsilon, 0, ep->value+hepsilon ); */
! /* glVertex3f( -epsilon, 0, ep->value ); */
! /* } */
! /* else */
! /* { */
! /* glVertex3f( -epsilon, 0, ep->value ); */
! /* glVertex3f( -hepsilon, 0, ep->value-hepsilon ); */
! /* } */
! /* glEnd(); */
! /* glRasterPos3f( -0.5, 0, ep->value ); */
! /* glPrint( "%d", (int)i++ ); */
! /* glRasterPos3f( -0.8, 0, ep->value ); */
! /* glPrint( "%.2f", ep->value ); */
! /* pop_color(); */
! /* } */
//puts( "\n" );
***************
*** 1612,1616 ****
if( win->show_bboxes ) // draw bounding boxes
{
! //g_hash_table_foreach( world->models, (GHFunc)model_bbox_cb, NULL );
// draw the bbox lists
draw_endpoints( world );
--- 1621,1625 ----
if( win->show_bboxes ) // draw bounding boxes
{
! g_hash_table_foreach( world->models, (GHFunc)model_bbox_cb, NULL );
// draw the bbox lists
draw_endpoints( world );
Index: model.c
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/model.c,v
retrieving revision 1.153.2.13
retrieving revision 1.153.2.14
diff -C2 -d -r1.153.2.13 -r1.153.2.14
*** model.c 18 May 2007 05:21:07 -0000 1.153.2.13
--- model.c 19 May 2007 02:33:28 -0000 1.153.2.14
***************
*** 1991,2000 ****
// will just be a single rect, grippers 3 rects, etc. not too bad.
! size_t count=0;
//stg_polygon_t* polys = stg_model_get_polygons(mod, &count);
// no body? no collision
! if( count < 1 )
! return NULL;
// first find the models whose bounding box overlaps with this one
--- 1991,2000 ----
// will just be a single rect, grippers 3 rects, etc. not too bad.
! //size_t count=0;
//stg_polygon_t* polys = stg_model_get_polygons(mod, &count);
// no body? no collision
! //if( count < 1 )
! //return NULL;
// first find the models whose bounding box overlaps with this one
Index: model_laser.c
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/model_laser.c,v
retrieving revision 1.89.2.7
retrieving revision 1.89.2.8
diff -C2 -d -r1.89.2.7 -r1.89.2.8
*** model_laser.c 18 May 2007 05:21:07 -0000 1.89.2.7
--- model_laser.c 19 May 2007 02:33:28 -0000 1.89.2.8
***************
*** 132,143 ****
stg_model_set_cfg( mod, &lconf, sizeof(lconf) );
! double vol[6];
! vol[0] = 0;
! vol[1] = lconf.range_max;
! vol[2] = -lconf.range_max;
! vol[3] = lconf.range_max;
! vol[4] = -0.1;
! vol[5] = 0.1;
! stg_model_set_sense_volume( mod, vol );
--- 132,143 ----
stg_model_set_cfg( mod, &lconf, sizeof(lconf) );
! /* double vol[6]; */
! /* vol[0] = 0; */
! /* vol[1] = lconf.range_max; */
! /* vol[2] = -lconf.range_max; */
! /* vol[3] = lconf.range_max; */
! /* vol[4] = -0.1; */
! /* vol[5] = 0.1; */
! /* stg_model_set_sense_volume( mod, vol ); */
***************
*** 191,202 ****
// get the sensor's pose in global coords
! stg_pose_t pz;
! stg_model_get_global_pose( mod, &pz );
! PRINT_DEBUG3( "laser origin %.2f %.2f %.2f", pz.x, pz.y, pz.a );
double sample_incr = cfg->fov / (double)(cfg->samples-1);
! //double bearing = pz.a - cfg->fov/2.0;
#if TIMING
--- 191,202 ----
// get the sensor's pose in global coords
! stg_pose_t gpose;
! stg_model_get_global_pose( mod, &gpose );
! PRINT_DEBUG3( "laser origin %.2f %.2f %.2f", gpose.x, gpose.y, gpose.a );
double sample_incr = cfg->fov / (double)(cfg->samples-1);
! //double bearing = gpose.a - cfg->fov/2.0;
#if TIMING
***************
*** 213,277 ****
! stg_endpoint_t* ep = mod->world->endpts.x;
! assert( ep );
// wind along to the first point to the right of the model
! //while( ep->value <= pz.x )
// ep = ep->next;
- GList* hitlist = NULL;
! while( ep )
{
! //printf( "pz x: %.2f\n", pz.x );
! //printf( "ep: %s %.2f\n", ep->polygon->mod->token, ep->value );
! //printf( "ep next: %s %.2f\n", ep->next->polygon->mod->token,
ep->next->value );
! double xmin=0,ymin=0;
! if( ep->type == STG_BEGIN )
! {
! xmin = ep->polygon->epts[0].value;
! ymin = ep->polygon->epts[2].value;
! printf( "see polygon of %s starting at (%.2f,%.2f) ",
! ep->polygon->mod->token,
! xmin, ymin );
! hitlist = g_list_prepend( hitlist, ep->polygon );
! }
! if( ep->type == STG_END )
! {
! xmin = ep->polygon->epts[1].value;
! ymin = ep->polygon->epts[3].value;
! printf( "see polygon of %s ending at (%.2f,%.2f) ",
! ep->polygon->mod->token,
! xmin, ymin );
! hitlist = g_list_remove( hitlist, ep->polygon );
! }
!
! double angle = RTOD(atan2( ymin - pz.y, xmin - pz.x ));
!
! //if( angle > -90 && angle < 180 )
! {
! //ranges[(int)angle] = hypot( ymin - pz.y, xmin - pz.x );
! //ranges[(int)angle+1] = 4.0;
! //ranges[(int)angle+2] = 4.0;
! }
-
- if( xmin )
- {
- printf( "angle %.2f hits", angle );
- GList* it;
- for( it=hitlist; it; it=it->next )
- printf( " %s", ((stg_polygon_t*)it->data)->mod->token );
- puts("");
- }
! ep = ep->next;
! }
--- 213,346 ----
!
! //stg_endpoint_t* ep = mod->world->endpts.x;
! //assert( ep );
// wind along to the first point to the right of the model
! //while( ep->value <= gpose.x )
// ep = ep->next;
+
+ assert( mod->polys );
+
+ stg_endpoint_t* ep = ((stg_polygon_t*)mod->polys->data)->epts[1]; // x max
+
+
! // initialize the scan to max range
! double bearing_index0 = gpose.a - cfg->fov/2.0;
! double bearing = bearing_index0;
! int t;
! for( t=0; t<cfg->samples; t++ )
{
! double shortest = cfg->range_max;
!
!
! // for each model in the world that is not me
!
! // for each polygon in that model
!
! // for each line in that polygon
!
! // see if the ray intersects it
!
! // if the range is the shortest yet, store the range
!
!
! scan[t].range = 1.0;
! scan[t].hitpoint.x = gpose.x + scan[t].range * cos(bearing);
! scan[t].hitpoint.y = gpose.y + scan[t].range * sin(bearing);
! bearing += sample_incr;
! }
!
!
!
! /* GList* hitlist = NULL; */
! /* int index = 0; */
! /* int hitcount = 0; */
! /* while( ep ) */
! /* { */
! /* //printf( "gpose x: %.2f\n", gpose.x ); */
! /* //printf( "ep: %s %.2f\n", ep->polygon->mod->token, ep->value ); */
! /* //printf( "ep next: %s %.2f\n", ep->next->polygon->mod->token,
ep->next->value ); */
! /* double xmin=0,ymin=0; */
!
! /* if( ep->type == STG_BEGIN ) */
! /* { */
! /* xmin = ep->polygon->epts[0].value; */
! /* ymin = ep->polygon->epts[2].value; */
! /* printf( "see polygon of %s starting at (%.2f,%.2f) ", */
! /* ep->polygon->mod->token, */
! /* xmin, ymin ); */
!
! /* double global_angle = atan2( ymin - gpose.y, xmin - gpose.x ); */
! /* double scan_angle = global_angle - gpose.a + cfg->fov/2.0; */
! /* int next_index = (int)(scan_angle / sample_incr); */
!
! /* double range = cfg->range_max; */
! /* if( hitlist ) */
! /* { */
! /* stg_pose_t hispose; */
! /* stg_model_get_global_pose( ((stg_polygon_t*)hitlist->data)->mod,
&hispose ); */
! /* range = hypot( hispose.y - gpose.y, hispose.x - gpose.x ); */
! /* } */
! /* int i; */
! /* for( i=index; i<next_index; i++ ) */
! /* { */
! /* scan[i].range = range; */
! /* //scan[t].hitpoint.x = gpose.x + scan[t].range * cos(bearing); */
! /* //scan[t].hitpoint.y = gpose.y + scan[t].range * sin(bearing); */
! /* } */
!
! /* index = next_index; */
!
! /* if( index >= cfg->samples ) break; */
!
! /* hitlist = g_list_prepend( hitlist, ep->polygon ); */
! /* hitcount++; */
! /* } */
!
! /* if( ep->type == STG_END ) */
! /* { */
! /* xmin = ep->polygon->epts[1].value; */
! /* ymin = ep->polygon->epts[3].value; */
! /* printf( "see polygon of %s ending at (%.2f,%.2f) ", */
! /* ep->polygon->mod->token, */
! /* xmin, ymin ); */
! /* hitlist = g_list_remove( hitlist, ep->polygon ); */
! /* hitcount--; */
! /* } */
!
!
! /* if( hitcount > 0 ) */
! /* { */
! /* double angle = atan2( ymin - gpose.y, xmin - gpose.x ) - gpose.a +
cfg->fov/2.0; */
!
! /* int index2 = (int)(angle / sample_incr); */
!
! /* //for( */
!
!
! /* scan[index2].range = hypot( ymin - gpose.y, xmin - gpose.x ); */
! /* scan[index2].hitpoint.x = xmin; */
! /* scan[index2].hitpoint.y = ymin; */
!
! /* printf( "angle %.2f index % d hits", RTOD(angle), index ); */
! /* GList* it; */
! /* for( it=hitlist; it; it=it->next ) */
! /* printf( " %s", ((stg_polygon_t*)it->data)->mod->token ); */
! /* puts(""); */
! /* } */
!
! /* ep = ep->next; */
! /* } */
***************
*** 279,285 ****
/* for( int t=0; t<cfg->samples; t += cfg->resolution ) */
/* { */
! /* double bearing = pz.a - cfg->fov/2.0 + sample_incr * t; */
! /* itl_t* itl = itl_create2( mod, pz.x, pz.y, */
/* bearing, */
/* cfg->range_max, */
--- 348,354 ----
/* for( int t=0; t<cfg->samples; t += cfg->resolution ) */
/* { */
! /* double bearing = gpose.a - cfg->fov/2.0 + sample_incr * t; */
! /* itl_t* itl = itl_create2( mod, gpose.x, gpose.y, */
/* bearing, */
/* cfg->range_max, */
***************
*** 301,306 ****
/* { */
/* scan[t].range = cfg->range_max; */
! /* scan[t].hitpoint.x = pz.x + scan[t].range * cos(bearing); */
! /* scan[t].hitpoint.y = pz.y + scan[t].range * sin(bearing); */
/* } */
--- 370,375 ----
/* { */
/* scan[t].range = cfg->range_max; */
! /* scan[t].hitpoint.x = gpose.x + scan[t].range * cos(bearing); */
! /* scan[t].hitpoint.y = gpose.y + scan[t].range * sin(bearing); */
/* } */
-------------------------------------------------------------------------
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