int main (int argc, char **argv) { dMass m; dMatrix3 R; // setup pointers to drawstuff callback functions dsFunctions fn; fn.version = DS_VERSION; fn.start = &start; fn.step = &simLoop; fn.command = &command; fn.stop = 0; fn.path_to_textures = "../../drawstuff/textures"; if(argc==2) fn.path_to_textures = argv[1]; // create world world = dWorldCreate(); space = dHashSpaceCreate (0); contactgroup = dJointGroupCreate (0); dWorldSetGravity (world,0,0,-9.8); dWorldSetQuickStepNumIterations (world, 64); // Create a static world using a triangle mesh that we can collide with. int numv = sizeof(world_vertices)/(3*sizeof(float)); int numi = sizeof(world_indices)/ sizeof(int); printf("numv=%d, numi=%d\n", numv, numi); dTriMeshDataID Data = dGeomTriMeshDataCreate(); // fprintf(stderr,"Building Single Precision Mesh\n"); dGeomTriMeshDataBuildSingle ( Data, world_vertices, 3 * sizeof(float), numv, world_indices, numi, 3 * sizeof(int) ); world_mesh = dCreateTriMesh(space, Data, 0, 0, 0); dGeomTriMeshEnableTC(world_mesh, dSphereClass, false); dGeomTriMeshEnableTC(world_mesh, dBoxClass, false); dGeomSetPosition(world_mesh, 0, 0, 0.5); dRSetIdentity(R); //dIASSERT(dVALIDMAT3(R)); dGeomSetRotation (world_mesh, R); float sx=0.0, sy=3.40, sz=6.80; sphbody = dBodyCreate (world); dMassSetSphere (&m,1,RADIUS); dBodySetMass (sphbody,&m); sphgeom = dCreateSphere(0, RADIUS); dGeomSetBody (sphgeom,sphbody); reset_ball(); dSpaceAdd (space, sphgeom); // run simulation dsSimulationLoop (argc,argv,352,288,&fn); // Causes segm violation? Why? // (because dWorldDestroy() destroys body connected to geom; must call first!) dGeomDestroy(sphgeom); dGeomDestroy (world_mesh); dJointGroupEmpty (contactgroup); dJointGroupDestroy (contactgroup); dSpaceDestroy (space); dWorldDestroy (world); return 0; }
void PhysicsTriMeshGeom::enableTC( Int32 geomClass, bool enable ) { PhysicsTriMeshGeomPtr tmpPtr(*this); dGeomTriMeshEnableTC(tmpPtr->id, geomClass, enable ? 1:0); }