int main (int argc, char **argv) { // 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"; // create world world = dWorldCreate(); space = dHashSpaceCreate (0); contactgroup = dJointGroupCreate (0); dWorldSetGravity (world,0,0,-0.5); dWorldSetCFM (world,1e-5); dWorldSetAutoDisableFlag (world,1); dWorldSetContactMaxCorrectingVel (world,0.1); dWorldSetContactSurfaceLayer (world,0.001); dCreatePlane (space,0,0,1,0); memset (obj,0,sizeof(obj)); // run simulation dsSimulationLoop (argc,argv,352,288,&fn); dJointGroupDestroy (contactgroup); dSpaceDestroy (space); dWorldDestroy (world); return 0; }
int main( int argc, char **argv ) { // 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_TEXTURE_PATH; // create world dInitODE2( 0 ); world = dWorldCreate(); space = dSimpleSpaceCreate( 0 ); contactgroup = dJointGroupCreate( 0 ); dWorldSetGravity( world,0,0,-0.5 ); dWorldSetCFM( world,1e-5 ); dCreatePlane( space,0,0,1,0 ); memset( obj,0,sizeof( obj ) ); // run simulation dsSimulationLoop( argc,argv,352,288,&fn ); dJointGroupDestroy( contactgroup ); dSpaceDestroy( space ); dWorldDestroy( world ); dCloseODE(); return 0; }
void constructWorldForTest (dReal gravity, int bodycount, /* body 1 pos */ dReal pos1x, dReal pos1y, dReal pos1z, /* body 2 pos */ dReal pos2x, dReal pos2y, dReal pos2z, /* body 1 rotation axis */ dReal ax1x, dReal ax1y, dReal ax1z, /* body 1 rotation axis */ dReal ax2x, dReal ax2y, dReal ax2z, /* rotation angles */ dReal a1, dReal a2) { // create world world = dWorldCreate(); dWorldSetERP (world,0.2); dWorldSetCFM (world,1e-6); dWorldSetGravity (world,0,0,gravity); dMass m; dMassSetBox (&m,1,SIDE,SIDE,SIDE); dMassAdjust (&m,MASS); body[0] = dBodyCreate (world); dBodySetMass (body[0],&m); dBodySetPosition (body[0], pos1x, pos1y, pos1z); dQuaternion q; dQFromAxisAndAngle (q,ax1x,ax1y,ax1z,a1); dBodySetQuaternion (body[0],q); if (bodycount==2) { body[1] = dBodyCreate (world); dBodySetMass (body[1],&m); dBodySetPosition (body[1], pos2x, pos2y, pos2z); dQFromAxisAndAngle (q,ax2x,ax2y,ax2z,a2); dBodySetQuaternion (body[1],q); } else body[1] = 0; }
CPhysicManager::CPhysicManager(IEngine* _Engine):CBaseObject(_Engine){ SetParam("BaseClass","PhysicManager"); SetParam("Type","CPhysicManager"); SetParam("Name","-"); dSetErrorHandler (SilenceMessage); //затыкаем рот идиотским ошибкам dSetDebugHandler (SilenceMessage); //затыкаем рот идиотским ошибкам dSetMessageHandler (SilenceMessage); //затыкаем рот идиотским ошибкам calc_time= 0.0f; world = dWorldCreate(); dWorldSetGravity(world, 0, 0, -0.01 ); space=dHashSpaceCreate(0); contactgroup = dJointGroupCreate(0); LOGGER->LogMsg("+CPhysicManager"); ptr_world = world; ptr_contactgroup = contactgroup; dWorldSetCFM(world, 1e-5); dWorldSetERP(world, 0.2); dWorldSetContactMaxCorrectingVel(world, 0.9); dWorldSetContactSurfaceLayer(world, 0.001); dWorldSetAutoDisableFlag(world, 1); // ground = #define SHIRINA 1000 //dGeomID tmp = dCreateBox( space, SHIRINA, SHIRINA, 1); //dGeomSetPosition(tmp, SHIRINA/2, SHIRINA/2, 0); // двигаем центр координат //tmp = dCreateBox( space, 1, SHIRINA, SHIRINA); //dGeomSetPosition(tmp, 0, SHIRINA/2, SHIRINA/2); // двигаем центр координат //tmp = dCreateBox( space, SHIRINA, 1, SHIRINA); //dGeomSetPosition(tmp, SHIRINA/2, 0, SHIRINA/2); // двигаем центр координат dCreatePlane (space,0,0,1,0); //dCreatePlane (space,1,1,0,0); //dCreatePlane (space,0,1,0,0); //dCreatePlane (space,1,0,0,0); //dCreatePlane (space,0,0,20,0); //dCreatePlane (space,0,10,0,0); //dCreatePlane (space,10,0,0,0); //dCreatePlane (space,0,0,1,0); //dCreatePlane (space,0,0,1,0); //dCreatePlane (space,0,0,1,0); //dCreatePlane (space,0,0,1,0); //dCreatePlane (space,0,0,1,0); };
void HarrierSim::start2() { // setDrawStuff(); world = dWorldCreate(); space = dHashSpaceCreate(0); contactgroup = dJointGroupCreate(0); ground = dCreatePlane(space, 0, 0, 1, 0); dWorldSetGravity(world,0,0,-0.5); dWorldSetCFM (world,1e-6); dWorldSetERP (world,1); //dWorldSetAutoDisableFlag (world,1); dWorldSetContactMaxCorrectingVel (world,0.1); //set the contact penetration dWorldSetContactSurfaceLayer(world, 0.001); makeHarrier(); itsHarrierObject = vp->load3DSObject("./etc/spaceship.3ds", "./etc/textures/spaceshiptexture.ppm"); itsHarrierObject.scale = 0.1; //set the viewpoint double xyz[3] = {0 , 25.0, 20}; double hpr[3] = {-90.0,-35,0.0}; vp->dsSetViewpoint (xyz,hpr); vp->setZoom(1.5); }
// Called by Physics::Server when the Level is attached to the server. void CLevel::Activate() { TimeToSim = 0.0; // Initialize ODE //???per-Level? dInitODE(); ODEWorldID = dWorldCreate(); dWorldSetQuickStepNumIterations(ODEWorldID, 20); // FIXME(enno): is a quadtree significantly faster? -- can't count geoms with quadtree ODECommonSpaceID = dSimpleSpaceCreate(NULL); ODEDynamicSpaceID = dSimpleSpaceCreate(ODECommonSpaceID); ODEStaticSpaceID = dSimpleSpaceCreate(ODECommonSpaceID); dWorldSetGravity(ODEWorldID, Gravity.x, Gravity.y, Gravity.z); dWorldSetContactSurfaceLayer(ODEWorldID, 0.001f); dWorldSetContactMaxCorrectingVel(ODEWorldID, 100.0f); dWorldSetERP(ODEWorldID, 0.2f); // ODE's default value dWorldSetCFM(ODEWorldID, 0.001f); // the default is 10^-5 // setup autodisabling dWorldSetAutoDisableFlag(ODEWorldID, 1); dWorldSetAutoDisableSteps(ODEWorldID, 5); //dWorldSetAutoDisableTime(ODEWorldID, 1.f); dWorldSetAutoDisableLinearThreshold(ODEWorldID, 0.05f); // default is 0.01 dWorldSetAutoDisableAngularThreshold(ODEWorldID, 0.1f); // default is 0.01 // create a Contact group for joints ContactJointGroup = dJointGroupCreate(0); }
/** * \brief This function initializes the ode world. * * pre: * - world_init = false * * post: * - world, space and contactgroup should be created * - the ODE world parameters should be set * - at the end world_init have to become true */ void WorldPhysics::initTheWorld(void) { MutexLocker locker(&iMutex); // if world_init = true debug something if (!world_init) { //LOG_DEBUG("init physics world"); world = dWorldCreate(); space = dHashSpaceCreate(0); contactgroup = dJointGroupCreate(0); old_gravity = world_gravity; old_cfm = world_cfm; old_erp = world_erp; dWorldSetGravity(world, world_gravity.x(), world_gravity.y(), world_gravity.z()); dWorldSetCFM(world, (dReal)world_cfm); dWorldSetERP (world, (dReal)world_erp); dWorldSetAutoDisableFlag (world,0); // if usefull for some tests a ground can be created here plane = 0; //dCreatePlane (space,0,0,1,0); world_init = 1; drawStruct draw; draw.ptr_draw = (DrawInterface*)this; if(control->graphics) control->graphics->addDrawItems(&draw); } //printf("initTheWorld..\n"); }
void CDynamics3DEngine::Init(TConfigurationNode& t_tree) { /* Init parent */ CPhysicsEngine::Init(t_tree); /* Parse the XML */ GetNodeAttributeOrDefault(t_tree, "gravity", m_cGravity, CVector3(0.0f, 0.0f, -9.81f)); GetNodeAttributeOrDefault<Real>(t_tree, "erp", m_fERP, 0.8); GetNodeAttributeOrDefault<Real>(t_tree, "cfm", m_fCFM, 0.01); GetNodeAttributeOrDefault<UInt32>(t_tree, "iterations", m_unIterations, 20); GetNodeAttributeOrDefault<size_t>(t_tree, "max_contacts", m_unMaxContacts, 32); /* Init ODE stuff */ m_tWorldID = dWorldCreate(); m_tSpaceID = dHashSpaceCreate(0); dSpaceSetSublevel(m_tSpaceID, 0); m_tContactJointGroupID = dJointGroupCreate(0); dWorldSetGravity(m_tWorldID, 0.0f, 0.0f, -9.81f); dWorldSetERP(m_tWorldID, m_fERP); dWorldSetCFM(m_tWorldID, m_fCFM); dWorldSetQuickStepNumIterations(m_tWorldID, m_unIterations); dInitODE(); /* Initialize contact information */ m_ptContacts = new dContact[m_unMaxContacts]; for(UInt32 i = 0; i < m_unMaxContacts; ++i) { ::memset(&(m_ptContacts[i].surface), 0, sizeof(dSurfaceParameters)); m_ptContacts[i].surface.mode = dContactMu2; m_ptContacts[i].surface.mu = dInfinity; m_ptContacts[i].surface.mu2 = dInfinity; } /* Add a planar floor */ m_tFloor = dCreatePlane(m_tSpaceID, 0, 0, 1.0f, 0.0f); /* Set the random seed from a random number taken from ARGoS RNG */ m_pcRNG = CARGoSRandom::CreateRNG("argos"); dRandSetSeed(m_pcRNG->Uniform(CRange<UInt32>(1,65535))); }
/* ------------------------ * メイン関数 ------------------------ */ int main(int argc, char *argv[]) { /* txtデータ読み込み */ LoadTxt("route.txt", routeX, routeY, routeZ, &lineRoute); LoadTxt("obstacle.txt", obstX, obstY, obstZ, &lineObst); /* ODEの初期化 */ dInitODE(); /* 描画関数の設定 */ setDrawStuff(); /* ワールド, スペース, 接触点グループの生成 */ world = dWorldCreate(); space = dHashSpaceCreate(0); contactgroup = dJointGroupCreate(0); /* 地面, 重力の生成 */ ground = dCreatePlane(space,0,0,1,0); dWorldSetGravity(world, 0.0, 0.0, -9.8); /* CFM, ERPの設定 */ dWorldSetCFM(world,1e-3); dWorldSetERP(world,0.8); /* 全方向移動ロボットの生成 */ t1 = clock(); MakeBox(); MakeOmni(); /* シミュレーションループ */ dsSimulationLoop(argc,argv,640,480,&fn); /* 接触点グループ, スペース, ワールドの破壊, ODEの終了 */ dJointGroupDestroy(contactgroup); dSpaceDestroy(space); dWorldDestroy(world); dCloseODE(); return 0; }
int main (int argc, char **argv) { // 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_TEXTURE_PATH; // create world dInitODE(); world = dWorldCreate(); #if 1 space = dHashSpaceCreate (0); #elif 0 dVector3 center = {0,0,0}, extents = { 100, 100, 100}; space = dQuadTreeSpaceCreate(0, center, extents, 5); #elif 0 space = dSweepAndPruneSpaceCreate (0, dSAP_AXES_XYZ); #else space = dSimpleSpaceCreate(0); #endif contactgroup = dJointGroupCreate (0); dWorldSetGravity (world,0,0,-0.5); dWorldSetCFM (world,1e-5); dWorldSetLinearDamping(world, 0.00001); dWorldSetAngularDamping(world, 0.005); dWorldSetMaxAngularSpeed(world, 200); dWorldSetContactSurfaceLayer (world,0.001); ground = dCreatePlane (space,0,0,1,0); memset (obj,0,sizeof(obj)); // create lift platform platform = dCreateBox(space, 4, 4, 1); dGeomSetCategoryBits(ground, 1ul); dGeomSetCategoryBits(platform, 2ul); dGeomSetCollideBits(ground, ~2ul); dGeomSetCollideBits(platform, ~1ul); // run simulation dsSimulationLoop (argc,argv,352,288,&fn); dJointGroupDestroy (contactgroup); dSpaceDestroy (space); dWorldDestroy (world); dCloseODE(); return 0; }
int main (int argc, char **argv) { // 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_TEXTURE_PATH; if(argc==2) { fn.path_to_textures = argv[1]; } // create world dInitODE2(0); world = dWorldCreate(); space = dSimpleSpaceCreate(0); contactgroup = dJointGroupCreate (0); dWorldSetGravity (world,0,0,-0.5); dWorldSetCFM (world,1e-5); dCreatePlane (space,0,0,1,0); memset (obj,0,sizeof(obj)); // note: can't share tridata if intending to trimesh-trimesh collide TriData1 = dGeomTriMeshDataCreate(); dGeomTriMeshDataBuildSingle(TriData1, &Vertices[0], 3 * sizeof(float), VertexCount, (dTriIndex*)&Indices[0], IndexCount, 3 * sizeof(dTriIndex)); TriData2 = dGeomTriMeshDataCreate(); dGeomTriMeshDataBuildSingle(TriData2, &Vertices[0], 3 * sizeof(float), VertexCount, (dTriIndex*)&Indices[0], IndexCount, 3 * sizeof(dTriIndex)); TriMesh1 = dCreateTriMesh(space, TriData1, 0, 0, 0); TriMesh2 = dCreateTriMesh(space, TriData2, 0, 0, 0); dGeomSetData(TriMesh1, TriData1); dGeomSetData(TriMesh2, TriData2); {dGeomSetPosition(TriMesh1, 0, 0, 0.9); dMatrix3 Rotation; dRFromAxisAndAngle(Rotation, 1, 0, 0, M_PI / 2); dGeomSetRotation(TriMesh1, Rotation);} {dGeomSetPosition(TriMesh2, 1, 0, 0.9); dMatrix3 Rotation; dRFromAxisAndAngle(Rotation, 1, 0, 0, M_PI / 2); dGeomSetRotation(TriMesh2, Rotation);} // run simulation dsSimulationLoop (argc,argv,352,288,&fn); dJointGroupDestroy (contactgroup); dSpaceDestroy (space); dWorldDestroy (world); dCloseODE(); return 0; }
int main (int argc, char **argv) { // setup pointers to drawstuff callback functions dsFunctions fn; fn.version = DS_VERSION; fn.start = &start; fn.step = &simLoop; fn.stop = 0; fn.command = 0; fn.path_to_textures = "../../drawstuff/textures"; dInitODE (); // create world world = dWorldCreate (); space = dHashSpaceCreate (0); dWorldSetGravity (world,0,0,0); //Original Gravity = -0.2 dWorldSetCFM (world,1e-5); dCreatePlane (space,0,0,1,0); contactgroup = dJointGroupCreate (0); // create object sphere0 = dBodyCreate (world); sphere0_geom = dCreateSphere (space,0.5); dMassSetSphere (&m,1,0.5); dBodySetMass (sphere0,&m); dGeomSetBody (sphere0_geom,sphere0); sphere1 = dBodyCreate (world); sphere1_geom = dCreateSphere (space,0.5); dMassSetSphere (&m,1,0.5); dBodySetMass (sphere1,&m); dGeomSetBody (sphere1_geom,sphere1); sphere2 = dBodyCreate (world); sphere2_geom = dCreateSphere (space,0.5); dMassSetSphere (&m,1,0.5); dBodySetMass (sphere2,&m); dGeomSetBody (sphere2_geom,sphere2); // set initial position dBodySetPosition (sphere0,0,0,4); dBodySetPosition (sphere1,5,0,4); dBodySetPosition (sphere2,-2,0,4); // run simulation dsSimulationLoop (argc,argv,352,288,&fn); // clean up dJointGroupDestroy (contactgroup); dSpaceDestroy (space); dWorldDestroy (world); dCloseODE(); return 0; }
void ode::reset() { world = dWorldCreate(); space = dSweepAndPruneSpaceCreate(0, dSAP_AXES_XYZ ); dWorldSetGravity (world,0,300,0); dWorldSetCFM (world, 1e-5); dWorldSetERP (world, 0.8); //dWorldSetQuickStepNumIterations (world,ITERS); ground = dCreatePlane (space,0,0,100,0); }
void initWorldModelling(int testcase) { /* create world */ dRandSetSeed(1); dInitODE(); //dInitODE2(dInitFlagManualThreadCleanup); //dAllocateODEDataForThread(dAllocateMaskAll); world = dWorldCreate(); space = dHashSpaceCreate (0); //dWorldSetAutoDisableFlag(World, 1); // The parameter needs to be zero. contactgroup = dJointGroupCreate (0); dWorldSetGravity (world,0,-9.81f,0); dWorldSetCFM (world,1e-2f); //1e-5f was the originally value used. dWorldSetERP(world,1.0f); // 1 is Error Correction is applied. // Set Damping dWorldSetLinearDamping(world, 0.01f); // 0.00001 dWorldSetAngularDamping(world, 0.005f); // 0.005 dWorldSetMaxAngularSpeed(world, 200); // Set and get the depth of the surface layer around all geometry objects. Contacts are allowed to sink into the surface layer up to the given depth before coming to rest. The default value is zero. Increasing this to some small value (e.g. 0.001) can help prevent jittering problems due to contacts being repeatedly made and broken. dWorldSetContactSurfaceLayer (world,0.001f); ground = dCreatePlane (space,0,1,0,0); switch(testcase) { case 1:initIslands();test1();break;// Carrier stability case 2:initIslands();test1();test2();break;// Manta landing on island. case 3:initIslands();test1();test2();test3();break;// Manta crashing on structure case 4:initIslands();test1();test2();test3();test4();break;// Manta landing on runway case 5:initIslands();test1();test2();break;// Manta landing on aircraft case 6:initIslands();test1();test6();break;// Carrier stranded on island case 7:test1();test2();test7();break; //Manta crashing on water. case 8:initIslands();test1();test8();break; // Walrus reaching island. case 9:test1();test9();break; // Walrus stability. case 10:initIslands();test1();test10();break; // Walrus arrive to island and build the command center. case 11:initIslands();test11();break; // Carrier stability far away. case 12:initIslands();test1();test12();break; // Bullets case 13:initIslands();test13();break; default:initIslands();test1();break; } testing = testcase; }
int main (int argc, char **argv) { static dMass m; dReal mass = 1.0; // set for drawing dsFunctions fn; fn.version = DS_VERSION; fn.start = &start; fn.step = &simLoop; fn.command = NULL; fn.stop = NULL; fn.path_to_textures = "../textures"; dInitODE(); // init ODE world = dWorldCreate(); // create a dynamic world space = dSimpleSpaceCreate (0); //@a box capsule = dBodyCreate (world); geom = dCreateCapsule (space,radius,length); //create geometry. dMassSetCapsule(&m,DENSITY,3,radius,length); dBodySetMass (capsule,&m); dGeomSetBody(geom,capsule); dBodySetPosition (capsule,0,4,1); //Gravedad y cosas de simulacion dWorldSetGravity(world,0,0,-9.81); dWorldSetCFM (world,1e-5); dCreatePlane (space,0,0,1,0); contactgroup = dJointGroupCreate (0); // the simulation dsSimulationLoop (argc,argv,960,480,&fn); //-- Destroy the world!!! dJointGroupDestroy (contactgroup); dSpaceDestroy (space); dWorldDestroy (world); dCloseODE(); return 0; }
int main (int argc, char **argv) { // setup pointers to drawstuff callback functions dsFunctions fn; fn.version = DS_VERSION; fn.start = &start; fn.step = &simLoop; fn.command = 0; fn.stop = 0; fn.path_to_textures = DRAWSTUFF_TEXTURE_PATH; if(argc==2) { fn.path_to_textures = argv[1]; } // create world dInitODE2(0); int i; contactgroup.create (); world.setGravity (0,0,-0.5); dWorldSetCFM (world.id(),1e-5); dPlane plane (space,0,0,1,0); for (i=0; i<NUM; i++) { body[i].create (world); dReal k = i*SIDE; body[i].setPosition (k,k,k+0.4); dMass m; m.setBox (1,SIDE,SIDE,SIDE); m.adjust (MASS); body[i].setMass (&m); body[i].setData ((void*)(size_t)i); box[i].create (space,SIDE,SIDE,SIDE); box[i].setBody (body[i]); } for (i=0; i<(NUM-1); i++) { joint[i].create (world); joint[i].attach (body[i],body[i+1]); dReal k = (i+0.5)*SIDE; joint[i].setAnchor (k,k,k+0.4); } // run simulation dsSimulationLoop (argc,argv,352,288,&fn); dCloseODE(); return 0; }
ODESimulator::ODESimulator() { timestep = 0; g_ODE_object.Init(); worldID = dWorldCreate(); contactGroupID = dJointGroupCreate(0); //envSpaceID = dHashSpaceCreate(0); //dHashSpaceSetLevels(envSpaceID,-2,1); envSpaceID = dSimpleSpaceCreate(0); dWorldSetERP(worldID,settings.errorReductionParameter); dWorldSetCFM(worldID,settings.dampedLeastSquaresParameter); dWorldSetGravity(worldID,settings.gravity[0],settings.gravity[1],settings.gravity[2]); }
int main (int argc, char **argv) { // 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_TEXTURE_PATH; if(argc==2) { fn.path_to_textures = argv[1]; } // create world dInitODE2(0); world = dWorldCreate(); space = dHashSpaceCreate (0); contactgroup = dJointGroupCreate (0); dWorldSetGravity (world,0,0,-GRAVITY); dWorldSetCFM (world,1e-5); dWorldSetAutoDisableFlag (world,1); #if 1 dWorldSetAutoDisableAverageSamplesCount( world, 10 ); #endif dWorldSetLinearDamping(world, 0.00001); dWorldSetAngularDamping(world, 0.005); dWorldSetMaxAngularSpeed(world, 200); dWorldSetContactMaxCorrectingVel (world,0.1); dWorldSetContactSurfaceLayer (world,0.001); dCreatePlane (space,0,0,1,0); memset (obj,0,sizeof(obj)); // run simulation dsSimulationLoop (argc,argv,352,288,&fn); dJointGroupDestroy (contactgroup); dSpaceDestroy (space); dWorldDestroy (world); dCloseODE(); return 0; }
int main (int argc, char **argv) { // 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(); dVector3 Center = {0, 0, 0, 0}; dVector3 Extents = {WORLD_SIZE * 0.55, WORLD_SIZE * 0.55, WORLD_SIZE * 0.55, 0}; //space = dSimpleSpaceCreate(0); //space = dHashSpaceCreate (0); space = dQuadTreeSpaceCreate (0, Center, Extents, 6); contactgroup = dJointGroupCreate (0); dWorldSetGravity (world,0,0,-0.5); dWorldSetCFM (world,1e-5); dCreatePlane (space,0,0,1,0); memset (obj,0,sizeof(obj)); for (int i = 0; i < NUM; i++){ command('s'); } // run simulation dsSimulationLoop (argc,argv,352,288,&fn); dJointGroupDestroy (contactgroup); dSpaceDestroy (space); dWorldDestroy (world); return 0; }
void PhysicalWorld::onInit() { InternalMessage("Physic","Physic::PhysicalWorld::onInit entering " + Kernel::toString(getObject()->getIdentifier())) ; Kernel::Log::Block temp("Physic","PhysicalWorld::onInit") ; m_world = new dWorld() ; dWorldSetCFM(m_world->id(),Kernel::Parameters::getValue<float>("Physic","WorldCFM")) ; dWorldSetERP(m_world->id(),Kernel::Parameters::getValue<float>("Physic","WorldERP")) ; dWorldSetContactSurfaceLayer(m_world->id(),Kernel::Parameters::getValue<float>("Physic","WorldContactSurfaceLayer")) ; dWorldSetContactMaxCorrectingVel(m_world->id(),Kernel::Parameters::getValue<float>("Physic","WorldContactMaxCorrectingVelocity")) ; m_collision_space = new dSimpleSpace(0) ; m_contact_group = dJointGroupCreate(0) ; }
int main (int argc, char *argv[]) { dInitODE(); setDrawStuff(); world = dWorldCreate(); space = dHashSpaceCreate(0); contactgroup = dJointGroupCreate(0); dWorldSetGravity(world,0,0,0); dWorldSetERP(world,1.0); // ERPの設定 dWorldSetCFM(world,0.0); // CFMの設定 ground = dCreatePlane(space,0,0,1,0); create(); dsSimulationLoop (argc,argv,500,600,&fn); dWorldDestroy (world); dCloseODE(); return 0; }
void CPHWorld::Create() { dWorldID phWorld=0; if (psDeviceFlags.test(mtPhysics)) Device.seqFrameMT.Add (this,REG_PRIORITY_HIGH); else Device.seqFrame.Add (this,REG_PRIORITY_LOW); m_commander =xr_new<CPHCommander>(); //dVector3 extensions={2048,256,2048}; /* Fbox level_box = Level().ObjectSpace.GetBoundingVolume(); Fvector level_size,level_center; level_box . getsize (level_size); level_box . getcenter (level_center); dVector3 extensions = { level_size.x ,256.f,level_size.z}; dVector3 center = {level_center.x,0.f,level_center.z}; */ #ifdef ODE_SLOW_SOLVER #else dWorldSetAutoEnableDepthSF1(phWorld, 100000000); ///dWorldSetContactSurfaceLayer(phWorld,0.f); //phWorld->contactp.min_depth =0.f; #endif ContactGroup = dJointGroupCreate(0); dWorldSetGravity (phWorld, 0,-Gravity(), 0);//-2.f*9.81f Mesh.Create (0,phWorld); #ifdef PH_PLAIN plane=dCreatePlane(Space,0,1,0,0.3f); #endif //const dReal k_p=2400000.f;//550000.f;///1000000.f; //const dReal k_d=200000.f; dWorldSetERP(phWorld, ERP(world_spring,world_damping) ); dWorldSetCFM(phWorld, CFM(world_spring,world_damping)); //dWorldSetERP(phWorld, 0.2f); //dWorldSetCFM(phWorld, 0.000001f); disable_count=0; m_motion_ray=dCreateRayMotions(0); phBoundaries.set(Level().ObjectSpace.GetBoundingVolume()); phBoundaries.y1-=30.f; CPHCollideValidator::Init(); b_exist=true; }
void create_world(Controller* controller,bool log,bool bMoviePlay) { // create world dRandSetSeed(10); dInitODE(); creatures.clear(); world = dWorldCreate(); space = dHashSpaceCreate (0); contactgroup = dJointGroupCreate (0); dWorldSetGravity (world,0,0,-9.8); floorplane = dCreatePlane (space,0,0,1, 0.0); dWorldSetERP(world,0.1); dWorldSetCFM(world,1E-4); Biped* biped = new Biped(log,bMoviePlay); dVector3 pos={0.0,0.0,0.0}; biped->Create(world,space,pos,controller); creatures.push_back(biped); }
ODEWorld::ODEWorld(const Gravity &g, double erp) : m_timeStep(0.01), m_itrCnt(0), m_nowtime(0.0), m_quickStep(false), m_mu (SPARTS_MU1), m_mu2 (SPARTS_MU2), m_slip1 (SPARTS_SLIP1), m_slip2 (SPARTS_SLIP2), m_soft_erp(SPARTS_ERP), m_soft_cfm(SPARTS_CFM), m_bounce (SPARTS_BOUNCE), m_bounce_vel(0.0) { m_world = dWorldCreate(); dWorldSetGravity(m_world, g.x, g.y, g.z); // default dWorldSetERP(m_world, SPARTS_ERP); dWorldSetCFM(m_world, SPARTS_CFM); m_space = dHashSpaceCreate(0); m_jgroup = dJointGroupCreate(0); // modified by inamura }
/*** メイン関数 ***/ int main(int argc, char *argv[]) { dInitODE(); // ODEの初期化 setDrawStuff(); // 描画関数の設定 world = dWorldCreate(); // ワールドの生成 space = dHashSpaceCreate(0); // スペースの生成 contactgroup = dJointGroupCreate(0); // 接触点グループの生成 ground = dCreatePlane(space,0,0,1,0); // 地面の生成 dWorldSetGravity(world, 0.0, 0.0, - 9.8); // 重力加速度の設定 dWorldSetCFM(world,1e-3); // CFMの設定 dWorldSetERP(world,0.8); // ERPの設定 makeOmni(); // 全方向移動ロボットの生成 makeBall(); // ボールの生成 makeGoal(); // ゴールの生成 dsSimulationLoop(argc,argv,640,480,&fn); // シミュレーションループ dJointGroupDestroy(contactgroup); // 接触点グループの破壊 dSpaceDestroy(space); // スペースの破壊 dWorldDestroy(world); // ワールドの破壊 dCloseODE(); // ODEの終了 return 0; }
bool Simulation::loadFile(const std::string& filename, std::list<std::string>& errors) { ASSERT(scene == 0); Parser parser; if(!parser.parse(filename, errors)) return false; ASSERT(scene); dInitODE(); physicalWorld = dWorldCreate(); rootSpace = dHashSpaceCreate(0); staticSpace = dHashSpaceCreate(rootSpace); movableSpace = dHashSpaceCreate(rootSpace); contactGroup = dJointGroupCreate(0); dWorldSetGravity(physicalWorld, 0, 0, scene->gravity); if(scene->erp != -1.f) dWorldSetERP(physicalWorld, scene->erp); if(scene->cfm != -1.f) dWorldSetCFM(physicalWorld, scene->cfm); if(scene->quickSolverIterations != -1) dWorldSetQuickStepNumIterations(physicalWorld, scene->quickSolverIterations); #ifdef MULTI_THREADING threading = dThreadingAllocateMultiThreadedImplementation(); pool = dThreadingAllocateThreadPool(std::thread::hardware_concurrency(), 0, dAllocateFlagBasicData, nullptr); dThreadingThreadPoolServeMultiThreadedImplementation(pool, threading); dWorldSetStepThreadingImplementation(physicalWorld, dThreadingImplementationGetFunctions(threading), threading); #endif scene->createPhysics(); renderer.init(); return true; }
int main (int argc, char **argv) { setDrawStuff(); // Initialize Drawstuff "fn" parameters dInitODE(); // Initialize ODE world = dWorldCreate(); // Create a dynamic world space = dHashSpaceCreate(0); // Create a 3D space contactgroup = dJointGroupCreate(0); // Create a Joint group dWorldSetGravity(world,0,0,-9.8); // Set gravity (x,y,z) dWorldSetERP (world, 0.95); // ERP: good: [0.8,1.0> dWorldSetCFM(world,1e-5); // CFM ground = dCreatePlane(space,0,0,1,0); // Create ground: plane (space,a,b,c,d) Model::rCreateRobot(world,space,jointR,jointL); // Create robot dsSimulationLoop(argc,argv,600,400,&fn);// Simulation using Drawstuff "fn" parameters dJointGroupDestroy(contactgroup); // Destroy Joint group dSpaceDestroy(space); // Destroy space dWorldDestroy (world); // Destroy the world dCloseODE(); // Close ODE return 0; }
void PhysicsServer::SetCFM( float val ) { m_CFM = val; if (m_WorldID) dWorldSetCFM( m_WorldID, val ); } // PhysicsServer::SetCFM
int main (int argc, char **argv) { // 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 dInitODE(); world = dWorldCreate(); space = dSimpleSpaceCreate(0); contactgroup = dJointGroupCreate (0); dWorldSetGravity (world,0,0,-0.5); dWorldSetCFM (world,1e-5); //dCreatePlane (space,0,0,1,0); memset (obj,0,sizeof(obj)); Size[0] = 5.0f; Size[1] = 5.0f; Size[2] = 2.5f; Vertices[0][0] = -Size[0]; Vertices[0][1] = -Size[1]; Vertices[0][2] = Size[2]; Vertices[1][0] = Size[0]; Vertices[1][1] = -Size[1]; Vertices[1][2] = Size[2]; Vertices[2][0] = Size[0]; Vertices[2][1] = Size[1]; Vertices[2][2] = Size[2]; Vertices[3][0] = -Size[0]; Vertices[3][1] = Size[1]; Vertices[3][2] = Size[2]; Vertices[4][0] = 0; Vertices[4][1] = 0; Vertices[4][2] = 0; Indices[0] = 0; Indices[1] = 1; Indices[2] = 4; Indices[3] = 1; Indices[4] = 2; Indices[5] = 4; Indices[6] = 2; Indices[7] = 3; Indices[8] = 4; Indices[9] = 3; Indices[10] = 0; Indices[11] = 4; dTriMeshDataID Data = dGeomTriMeshDataCreate(); dGeomTriMeshDataBuildSimple(Data, (dReal*)Vertices, VertexCount, Indices, IndexCount); TriMesh = dCreateTriMesh(space, Data, 0, 0, 0); //dGeomSetPosition(TriMesh, 0, 0, 1.0); Ray = dCreateRay(space, 0.9); dVector3 Origin, Direction; Origin[0] = 0.0; Origin[1] = 0; Origin[2] = 0.5; Origin[3] = 0; Direction[0] = 0; Direction[1] = 1.1f; Direction[2] = -1; Direction[3] = 0; dNormalize3(Direction); dGeomRaySet(Ray, Origin[0], Origin[1], Origin[2], Direction[0], Direction[1], Direction[2]); // run simulation dsSimulationLoop (argc,argv,352,288,&fn); dJointGroupDestroy (contactgroup); dSpaceDestroy (space); dWorldDestroy (world); dCloseODE(); return 0; }
int main (int argc, char **argv) { // 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_TEXTURE_PATH; // create world dInitODE2(0); world = dWorldCreate(); space = dSimpleSpaceCreate(0); contactgroup = dJointGroupCreate (0); dWorldSetGravity (world,0,0,-0.5); dWorldSetCFM (world,1e-5); //dCreatePlane (space,0,0,1,0); memset (obj,0,sizeof(obj)); Size[0] = 5.0f; Size[1] = 5.0f; Size[2] = 2.5f; Vertices[0][0] = -Size[0]; Vertices[0][1] = -Size[1]; Vertices[0][2] = Size[2]; Vertices[1][0] = Size[0]; Vertices[1][1] = -Size[1]; Vertices[1][2] = Size[2]; Vertices[2][0] = Size[0]; Vertices[2][1] = Size[1]; Vertices[2][2] = Size[2]; Vertices[3][0] = -Size[0]; Vertices[3][1] = Size[1]; Vertices[3][2] = Size[2]; Vertices[4][0] = 0; Vertices[4][1] = 0; Vertices[4][2] = 0; Indices[0] = 0; Indices[1] = 1; Indices[2] = 4; Indices[3] = 1; Indices[4] = 2; Indices[5] = 4; Indices[6] = 2; Indices[7] = 3; Indices[8] = 4; Indices[9] = 3; Indices[10] = 0; Indices[11] = 4; dTriMeshDataID Data = dGeomTriMeshDataCreate(); //dGeomTriMeshDataBuildSimple(Data, (dReal*)Vertices, VertexCount, Indices, IndexCount); dGeomTriMeshDataBuildSingle(Data, Vertices[0], 3 * sizeof(float), VertexCount, &Indices[0], IndexCount, 3 * sizeof(dTriIndex)); dGeomTriMeshDataPreprocess2(Data, (1U << dTRIDATAPREPROCESS_BUILD_FACE_ANGLES), NULL); TriMesh = dCreateTriMesh(space, Data, 0, 0, 0); //dGeomSetPosition(TriMesh, 0, 0, 1.0); Ray = dCreateRay(space, 0.9); dVector3 Origin, Direction; Origin[0] = 0.0; Origin[1] = 0; Origin[2] = 0.5; Origin[3] = 0; Direction[0] = 0; Direction[1] = 1.1f; Direction[2] = -1; Direction[3] = 0; dNormalize3(Direction); dGeomRaySet(Ray, Origin[0], Origin[1], Origin[2], Direction[0], Direction[1], Direction[2]); dThreadingImplementationID threading = dThreadingAllocateMultiThreadedImplementation(); dThreadingThreadPoolID pool = dThreadingAllocateThreadPool(4, 0, dAllocateFlagBasicData, NULL); dThreadingThreadPoolServeMultiThreadedImplementation(pool, threading); // dWorldSetStepIslandsProcessingMaxThreadCount(world, 1); dWorldSetStepThreadingImplementation(world, dThreadingImplementationGetFunctions(threading), threading); // run simulation dsSimulationLoop (argc,argv,352,288,&fn); dThreadingImplementationShutdownProcessing(threading); dThreadingFreeThreadPool(pool); dWorldSetStepThreadingImplementation(world, NULL, NULL); dThreadingFreeImplementation(threading); dJointGroupDestroy (contactgroup); dSpaceDestroy (space); dWorldDestroy (world); dCloseODE(); return 0; }