コード例 #1
0
ファイル: ODEDomain.cpp プロジェクト: saneku/PODE2.0
ODEDomain::ODEDomain(char const *space_type, Input *input) : BaseDomain(input)
{
    printf("ODEDomain constructor\n");   
    dInitODE();
    world = dWorldCreate();
    contactgroup = dJointGroupCreate (0);
           
    //dWorldSetAutoDisableFlag(world,1);
    
    //dWorldSetCFM(world,1e-5);
    //Set and get the global CFM (constraint force mixing) value. Typical values are in the range 10-9 -- 1. The default is 10-5 if single precision is being used, or 10-10 if double precision is being used.
    
    //TODO HERE HAS TO BE ANOTHER PARAMETR
    //dWorldSetContactSurfaceLayer(world,0.001);

    //dWorldSetQuickStepNumIterations (world,ITERS);
    
    dRandSetSeed (time(NULL));
    setGravity(m_input->gravity_v[0],m_input->gravity_v[1],m_input->gravity_v[2]);

    if (space_type == std::string("quad"))
    {
        dVector3 Center = {boundaries[0][0]+delta[0]*0.5, boundaries[1][0]+delta[1]*0.5, boundaries[2][0]+delta[2]*0.5, 0};
        dVector3 Extents = {delta[0] * 0.55, delta[1] * 0.55, delta[2] * 0.55, 0};                
        printf(":::: Using Quad Tree Space\n");
        space = dQuadTreeSpaceCreate (0, Center, Extents, 6);        
    }
    else if (space_type == std::string("hash"))
    {                
        printf(":::: Using Hash Space\n");
        space = dHashSpaceCreate (0);
        //dHashSpaceSetLevels (space,-10,10);
    }
    else if (space_type == std::string("sap")) 
    {
        printf(":::: Using Sweep And Prune Space\n");
        space = dSweepAndPruneSpaceCreate (0, dSAP_AXES_XYZ);
    }
    else if (space_type == std::string("simple")) 
    {
        printf(":::: Using Simple Space\n");
        space = dSimpleSpaceCreate(0);
    }

    if (!space) 
    {
        printf(":::: Using Sweep And Prune Space\n");
        space = dSweepAndPruneSpaceCreate (0, dSAP_AXES_XYZ);            
    }
    
    //TODO redo tests
    //I did tests: deposition of 10000 particles without& (~catBits[PARTICLES])& (~catBits[PARTICLES]) collisions.
    //SWAP: 6 sec
    //HASH: 7.15 sec
    //QUAD: 41.8 sec
    //SIMLE: 59 sec
    
    printf("ODE conf: %s", dGetConfiguration());      
    printf("\n:::: sizeof(dReal)=%lu\n\n", sizeof(dReal));
}
コード例 #2
0
ファイル: demo_motion.cpp プロジェクト: EdgarSun/opende
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;
}
コード例 #3
0
void PhysicsQuadTreeSpace::initQuadTree(dSpaceID space)
{
    dVector3 c, e;
    c[0]=getCenter().x();
    c[1]=getCenter().y();
    c[2]=getCenter().z();
    e[0]=getExtent().x();
    e[1]=getExtent().y();
    e[2]=getExtent().z();
    _SpaceID = dQuadTreeSpaceCreate(space, c, e, getDepth());
}
コード例 #4
0
ファイル: test_space_stress.cpp プロジェクト: Ricku34/ODE.js
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;
}
コード例 #5
0
ファイル: demo_space.cpp プロジェクト: deavid/soyamirror
int main (int argc, char **argv)
{
  int i;

  // 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];
    }

  dInitODE();

  // test the simple space:
  // space = dSimpleSpaceCreate();

  // test the hash space:
  // space = dHashSpaceCreate (0);
  // dHashSpaceSetLevels (space,-10,10);

  // test the quadtree space
  dVector3 Center = {0, 0, 0, 0};
  dVector3 Extents = {10, 0, 10, 0};
  space = dQuadTreeSpaceCreate(0, Center, Extents, 7);

  for (i=0; i < NUM; i++) geom[i] = 0;
  init_test();

  // run simulation
  dsSimulationLoop (argc,argv,352,288,&fn);

  dSpaceDestroy (space);
  dCloseODE();
  return 0;
}
コード例 #6
0
ファイル: ODESimulator.cpp プロジェクト: sub77/hobbycode
	void ODESimulator::initData(SimulatorData data)
	{
		Simulator::initData(data);

		// We can only init ODE once.
		if (0 == mInitCounter)
		{
			dInitODE();
		}
		++mInitCounter;

		// Create ODE world.
		mWorldID = dWorldCreate();

		// Set default gravity.
		setGravity(defaults::gravity);

		// Create the root ODE space.
		//mRootSpaceID = dSimpleSpaceCreate(0);
		//dVector3 center = {0, 0, 0};
		//dVector3 extents = {200, 100, 200};
		//mRootSpaceID = dQuadTreeSpaceCreate(0, center, extents, 5);

		if (data.useOctreeInsteadHash)
		{
			dVector3 center = { data.worldCenter[0],
			                    data.worldCenter[1],
			                    data.worldCenter[2] };
			dVector3 extents = { data.worldSize[0],
			                     data.worldSize[1],
			                     data.worldSize[2] };
			mRootSpaceID = dQuadTreeSpaceCreate(0, center, extents, data.octreeDepth);
		}
		else
		{
			mRootSpaceID = dHashSpaceCreate(0);
			dHashSpaceSetLevels(mRootSpaceID, data.hashMinLevel, data.hashMaxLevel);
		}

		mRootSpace = new ODESpace(mRootSpaceID);

		// Create the ODE contact joint group.
		mContactJointGroupID = dJointGroupCreate(0);

		// Set the ODE global CFM value that will be used by all Joints
		// (including contacts).  This affects normal Joint constraint
		// operation and Joint limits.  The user cannot adjust CFM, but
		// they can adjust ERP (a.k.a. bounciness/restitution) for materials
		// (i.e. contact settings) and Joint limits.
		dWorldSetCFM(mWorldID, defaults::ode::globalCFM);

		// Set the ODE global ERP value.  This will only be used for Joints
		// under normal conditions, not at their limits.  Also, it will not
		// affect contacts at all since they use material properties to
		// calculate ERP.
		dWorldSetERP(mWorldID, (real) 0.5 * (defaults::ode::maxERP +
		              defaults::ode::minERP));

		dWorldSetContactSurfaceLayer(mWorldID, defaults::ode::surfaceLayer);

		setSolverAccuracy(defaults::solverAccuracy);
		mCollisionCount = 0;
		// "mRaycastResult" is initialized in its own constructor.
		mSensorSolid = NULL;
		mRayContactGroup = defaults::shape::contactGroup;
	}