Update of /cvsroot/playerstage/code/stage/libstage
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20465/libstage
Modified Files:
Tag: opengl
Makefile Makefile.manual model.cc model_laser.cc
Log Message:
working on collision detection
Index: model_laser.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/model_laser.cc,v
retrieving revision 1.1.2.12
retrieving revision 1.1.2.13
diff -C2 -d -r1.1.2.12 -r1.1.2.13
*** model_laser.cc 26 Nov 2007 06:28:16 -0000 1.1.2.12
--- model_laser.cc 27 Nov 2007 07:03:33 -0000 1.1.2.13
***************
*** 15,21 ****
#include <sys/time.h>
- //#include <math.h>
- // #include <GL/gl.h>
-
#include "stage.hh"
--- 15,18 ----
Index: model.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/model.cc,v
retrieving revision 1.1.2.16
retrieving revision 1.1.2.17
diff -C2 -d -r1.1.2.16 -r1.1.2.17
*** model.cc 27 Nov 2007 05:36:01 -0000 1.1.2.16
--- model.cc 27 Nov 2007 07:03:33 -0000 1.1.2.17
***************
*** 329,335 ****
}
-
-
-
stg_d_draw_t* stg_d_draw_create( stg_d_type_t type,
stg_vertex_t* verts,
--- 329,332 ----
***************
*** 1128,1141 ****
!
! int lines_raytrace_match( StgModel* mod, StgModel* hitmod )
! {
! // Ignore invisible things, myself, my children, and my ancestors.
! if( hitmod->ObstacleReturn() && !(mod == hitmod) )//&&
(!stg_model_is_related(mod,hitmod)) )
! return 1;
!
! return 0; // no match
! }
!
--- 1125,1133 ----
! static bool collision_match( StgBlock* testblock,
! StgModel* finder )
! {
! return( (testblock->mod != finder) && testblock->mod->ObstacleReturn() );
! }
***************
*** 1161,1171 ****
/* } */
-
- /* stg_pose_t pose; */
- /* memcpy( &pose, &mod->geom.pose, sizeof(pose)); */
- /* stg_model_local_to_global( mod, &pose ); */
-
- /* //return NULL; */
-
// raytrace along all our blocks. expensive, but most vehicles
// will just be a few blocks, grippers 3 blocks, etc. not too bad.
--- 1153,1156 ----
***************
*** 1175,1178 ****
--- 1160,1165 ----
return NULL;
+ StgModel* hitmod = NULL;
+
// unrender myself - avoids a lot of self-hits
this->UnMap();
***************
*** 1182,1191 ****
stg_pose_sum( &local, pose, &this->geom.pose );
- //glNewList( this->dl_debug, GL_COMPILE );
- //glPushMatrix();
- //glTranslatef( 0,0,1.0 );
- //push_color_rgb( 0,0,1 );
- //glBegin( GL_LINES );
-
// loop over all blocks
for( GList* it = this->blocks; it; it=it->next )
--- 1169,1172 ----
***************
*** 1199,1251 ****
stg_point_t* pt2 = &b->pts[(p+1) % b->pt_count];
! stg_pose_t pp1;
! pp1.x = pt1->x;
! pp1.y = pt1->y;
! pp1.a = 0;
!
! stg_pose_t pp2;
! pp2.x = pt2->x;
! pp2.y = pt2->y;
! pp2.a = 0;
!
! stg_pose_t p1;
! stg_pose_t p2;
!
! // shift the line points into the global coordinate system
! stg_pose_sum( &p1, &local, &pp1 );
! stg_pose_sum( &p2, &local, &pp2 );
!
! //glVertex2f( p1.x, p1.y );
! //glVertex2f( p2.x, p2.y );
! printf( "tracing %.2f %.2f %.2f %.2f\n", p1.x, p1.y, p2.x, p2.y );
!
! //double dx = p2.x - p1.x;
! //double dy = p2.y - p1.y;
! // itl_t* itl = itl_create( p1.x, p1.y, 0.2,
! // p2.x, p2.y,
! // root->matrix,
! // PointToPoint );
!
! // StgModel* hitmod = itl_first_matching( itl, lines_raytrace_match,
this );
! // if( hitmod )
! // {
! // if( hitx ) *hitx = itl->x; // report them
! // if( hity ) *hity = itl->y;
! // itl_destroy( itl );
! // this->Map(1);
! // //pop_color();
! // //glEnd();
! // //glPopMatrix();
! // //glEndList();
!
! // return hitmod; // we hit this object! stop raytracing
! // }
! // itl_destroy( itl );
}
}
--- 1180,1211 ----
stg_point_t* pt2 = &b->pts[(p+1) % b->pt_count];
! //printf( "tracing %.2f %.2f %.2f %.2f\n", pt1->x, pt1->y, pt2->x,
pt2->y );
! double dx = pt2->x - pt1->x;
! double dy = pt2->y - pt1->y;
! double range = hypot( dx, dy );
! double bearing = atan2( dy,dx );
! stg_pose_t pose;
! bzero(&pose,sizeof(pose));
! pose.x = pt1->x;
! pose.y = pt1->y;
! pose.a = bearing;
! Raytrace( &pose,
! range,
! (stg_block_match_func_t)collision_match,
! (const void*)this,
! &hitmod );
! if( hitmod )
! printf( "I hit %s\n", hitmod->Token() );
!
! // if( hitmod )
! // {
! // if( hitx ) *hitx = itl->x; // report them
! // if( hity ) *hity = itl->y;
}
}
***************
*** 1253,1265 ****
// re-render myself
this->Map();
!
!
! //pop_color();
! //glEnd();
! //glPopMatrix();
! //glEndList();
!
!
! return NULL; // done
}
--- 1213,1217 ----
// re-render myself
this->Map();
! return hitmod; // done
}
***************
*** 1275,1279 ****
//stg_pose_t old_pose;
! //memcpy( &old_pose, &mod->pose, sizeof(old_pose));
stg_velocity_t v;
--- 1227,1231 ----
//stg_pose_t old_pose;
! //memcpy( &old_pose, &pose, sizeof(old_pose));
stg_velocity_t v;
***************
*** 1287,1298 ****
p.a += v.a * interval;
- //this->SetPose( &p );
-
// convert the new pose to global coords so we can see what it might hit
-
stg_pose_t gp;
memcpy( &gp, &p, sizeof(stg_pose_t));
! //this->LocalToGlobal( &gp );
// check this model and all it's children at the new pose
--- 1239,1247 ----
p.a += v.a * interval;
// convert the new pose to global coords so we can see what it might hit
stg_pose_t gp;
memcpy( &gp, &p, sizeof(stg_pose_t));
! this->LocalToGlobal( &gp );
// check this model and all it's children at the new pose
***************
*** 1304,1307 ****
--- 1253,1259 ----
printf( "hit %s at %.2f %.2f\n",
hitthing->Token(), hitx, hity );
+
+ //dd// //memcpy( &mod->pose, &old_pose, sizeof(mod->pose));
+ //this->SetPose( &old_pose );
}
else
Index: Makefile.manual
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/Makefile.manual,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -C2 -d -r1.1.2.8 -r1.1.2.9
*** Makefile.manual 27 Nov 2007 05:36:01 -0000 1.1.2.8
--- Makefile.manual 27 Nov 2007 07:03:33 -0000 1.1.2.9
***************
*** 1,8 ****
! SRC = \
../config.h \
colors.h \
stage.hh \
! worldfile.hh \
ancestor.cc \
block.cc \
--- 1,10 ----
! HDR = \
../config.h \
colors.h \
stage.hh \
! worldfile.hh
!
! SRC = \
ancestor.cc \
block.cc \
***************
*** 27,35 ****
LIBS= `fltk-config --use-gl --ldflags` `pkg-config --libs gdk-pixbuf-2.0`
-framework OpenGL
all: stage
! stage: $(SRC)
! g++ -o $@ $(CXXFLAGS) $(SRC) $(LIBS)
clean :
--- 29,41 ----
LIBS= `fltk-config --use-gl --ldflags` `pkg-config --libs gdk-pixbuf-2.0`
-framework OpenGL
+ OBJ=$(SRC:.cc=.o)
all: stage
! .cc.o:
! g++ $(CXXFLAGS) -c $<
!
! stage: $(OBJ)
! g++ $(LIBS) $(OBJ) -o $@
clean :
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit