ODE Tutorial 18: Speed Up without drawing objects

Most of this page was translated from http://demura.net/category/9ode by Babel Fish Translation. Sorry for strange and funny English from “the Chinese room“.

This is 18th article about ODE (Open Dynamics Engine) Tutorial. ODE is an open source physics libary, and it is widely used in various game software, and simulators in research.

This time, I explain the method of speed up a simulation without using the drawstuff, the 3D graphics engine, which is attached to ODE.

Drawstuff based on OpenGL is not the portion of ODE, it is only provided to show demo programs. I think drawstuff is very good for education purpose, because the library is very simple and it helps to study OpenGL.

The method of not using drawstuff is very simple. In the test program dsSimulationLoop is called in main function. This part to call the drawing loop, because it draws with each step of simulation and event processing from the keyboard. Functions of drawstuff begin with the letter “ds”.

That is, do not call dsSimulationLoop and other functions of drawstuff. Please see the following sample codes.

With drawing

void simLoop (int pause)
{
  // Write some necessary codes here
  dSpaceCollide(space,0,&nearCallback);
  dWorldStep(world,0.01);
  dJointGroupEmpty(contactgroup);
  const dReal *pos=dBodyGetPosition(apple);
  const dReal *R=dBodyGetRotation(apple);
  dsDrawSphere(pos, R, r);
}

int  main(int argc, char *argv[])
{
  // omission
  dsSimulationLoop(argc, argv, 640, 480,  &fn);
  // omission
}

Without drawing

static void simLoop (int pause)
{
  // Write some necessary codes here
  dSpaceCollide(space,0,&nearCallback);
  dWorldStep(world,0.01);
  dJointGroupEmpty(contactgroup);
  // const dReal *pos=dBodyGetPosition(apple);
  // const dReal *R=dBodyGetRotation(apple);
  //dsDrawSphere(pos, R, r); // without drawing
}

int  main(int argc, char *argv[])
{
  // omission
  while (1) {
    simLoop(0);  //  the argument must set to 0
  }
  // omission
}

To be continued.

コメント

タイトルとURLをコピーしました