|
From: Rodrigo H. <kw...@us...> - 2005-07-10 23:26:49
|
Update of /cvsroot/freesolid/freesolid/sample In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31211/sample Modified Files: Makefile.am walk.cpp Log Message: Depth penetration computation done, needs more tests. Index: Makefile.am =================================================================== RCS file: /cvsroot/freesolid/freesolid/sample/Makefile.am,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Makefile.am 8 Jul 2005 23:27:49 -0000 1.10 --- Makefile.am 10 Jul 2005 23:26:40 -0000 1.11 *************** *** 1,5 **** # Bypass extra crappy libtool linking ! all: sample x_wing teapot torus ellipsoid walk depth sample.o: sample.cpp --- 1,5 ---- # Bypass extra crappy libtool linking ! all: sample x_wing teapot torus ellipsoid walk sample.o: sample.cpp Index: walk.cpp =================================================================== RCS file: /cvsroot/freesolid/freesolid/sample/walk.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** walk.cpp 8 Jul 2005 23:27:49 -0000 1.6 --- walk.cpp 10 Jul 2005 23:26:40 -0000 1.7 *************** *** 45,63 **** void DrawWorld(); void DrawEllipsoid(float xradius, float yradius, float zradius); void Step(float step); int main(int argc, char *argv[]); - void CollideCallback(void * client_data, DtObjectRef obj1, DtObjectRef obj2, - const DtCollData *coll_data) - { - if(coll_data!=NULL) - { - // fprintf(stdout,"Collided Point 1 %f,%f,%f\nPoint 2 %f,%f,%f\nNormal %f,%f,%f\n", - // coll_data->point1[X],coll_data->point1[Y],coll_data->point1[Z], - // coll_data->point1[X],coll_data->point1[Y],coll_data->point1[Z], - // coll_data->normal[X],coll_data->normal[Y],coll_data->normal[Z]); - } - } --- 45,53 ---- void DrawWorld(); void DrawEllipsoid(float xradius, float yradius, float zradius); + void DrawBox(float width, float height, float depth); void Step(float step); int main(int argc, char *argv[]); *************** *** 77,80 **** --- 67,87 ---- const float gravity = -9.8f; const float stepsize = 0.016; + float boxsize[3]={20.0f,20.0f,5.0f}; + + void CollideCallback(void * client_data, DtObjectRef obj1, DtObjectRef obj2, + const DtCollData *coll_data) + { + if(coll_data!=NULL) + { + // fprintf(stdout,"Collided Point 1 %f,%f,%f\nPoint 2 %f,%f,%f\nNormal %f,%f,%f\n", + // coll_data->point1[X],coll_data->point1[Y],coll_data->point1[Z], + // coll_data->point1[X],coll_data->point1[Y],coll_data->point1[Z], + // coll_data->normal[X],coll_data->normal[Y],coll_data->normal[Z]); + + player.pos[X]-=coll_data->normal[X]; + player.pos[Y]-=coll_data->normal[Y]; + player.pos[Z]-=coll_data->normal[Z]; + } + } int main(int argc, char *argv[]) *************** *** 92,96 **** ellipsoid = dtEllipsoid(player.radii[0],player.radii[1],player.radii[2]); //ellipsoid = dtSphere(player.radii[2]); ! box = dtBox(player.radii[0],player.radii[1],player.radii[2]); dtCreateObject(&player, ellipsoid); dtCreateObject(&object2, world); --- 99,103 ---- ellipsoid = dtEllipsoid(player.radii[0],player.radii[1],player.radii[2]); //ellipsoid = dtSphere(player.radii[2]); ! box = dtBox(boxsize[0],boxsize[1],boxsize[2]); dtCreateObject(&player, ellipsoid); dtCreateObject(&object2, world); *************** *** 142,146 **** dtSelectObject(&object3); dtLoadIdentity(); - //dtTranslate(player.pos[X],player.pos[Y],player.pos[Z]); while(bRunning) { --- 149,152 ---- *************** *** 169,172 **** --- 175,179 ---- DrawEllipsoid(player.radii[X],player.radii[Y],player.radii[Z]); glPopMatrix(); + DrawBox(boxsize[0],boxsize[1],boxsize[2]); SDL_GL_SwapBuffers(); } *************** *** 246,250 **** --- 253,304 ---- gluSphere(sphereqobj, 1.0, 30, 30); } + void DrawBox(float width, float height, float depth) + { + float wdiv2=width/2; + float hdiv2=height/2; + float ddiv2=depth/2; + glPushMatrix(); + glBegin(GL_LINES); + { + glVertex3f(wdiv2,hdiv2,ddiv2); + glVertex3f(-wdiv2,hdiv2,ddiv2); + + glVertex3f(-wdiv2,-hdiv2,ddiv2); + glVertex3f(wdiv2,-hdiv2,ddiv2); + + glVertex3f(wdiv2,hdiv2,ddiv2); + glVertex3f(wdiv2,-hdiv2,ddiv2); + + glVertex3f(-wdiv2,-hdiv2,ddiv2); + glVertex3f(-wdiv2,hdiv2,ddiv2); + + glVertex3f(wdiv2,hdiv2,-ddiv2); + glVertex3f(-wdiv2,hdiv2,-ddiv2); + + glVertex3f(-wdiv2,-hdiv2,-ddiv2); + glVertex3f(wdiv2,-hdiv2,-ddiv2); + + glVertex3f(wdiv2,hdiv2,-ddiv2); + glVertex3f(wdiv2,-hdiv2,-ddiv2); + + glVertex3f(-wdiv2,-hdiv2,-ddiv2); + glVertex3f(-wdiv2,hdiv2,-ddiv2); + + glVertex3f(-wdiv2,-hdiv2,ddiv2); + glVertex3f(-wdiv2,-hdiv2,-ddiv2); + + glVertex3f(wdiv2,-hdiv2,ddiv2); + glVertex3f(wdiv2,-hdiv2,-ddiv2); + glVertex3f(wdiv2,hdiv2,-ddiv2); + glVertex3f(wdiv2,hdiv2,ddiv2); + + glVertex3f(-wdiv2,hdiv2,ddiv2); + glVertex3f(-wdiv2,hdiv2,-ddiv2); + } + glEnd(); + glPopMatrix(); + + } void DrawWorld() { |