14. Speed-up your simulation

 

This 14th tutorial explains how to speed-up without using Drawstuff, the 3D graphics library,  for your simulation.

Drawstuff is not part of ODE, it is, however, used to show demo programs of ODE. It is implemented  based on OpenGL, and it is very simple so it is a very good educational materials to learn OpenGL.

Without using Drawstuff is very easy, just do not call dsSimulationLoop in the main function and functions related drawing .

Please read the following sample code.


  • If you want to draw
static void simLoop (int pause)
{
  // Write necessary codes for your simulation
  dSpaceCollide(space,0,&nearCallback);
  dWorldStep(world,0.01);
  dJointGroupEmpty(contactgroup);
  drawSphere(torso.geom);
}

int  main(int argc, char *argv[])
{
  // Omit
  dsSimulationLoop(argc, argv, 640, 480,  &fn);
  // Omit
}
  • If you do not want to draw
static void simLoop (int pause)
{
  // Write necessary codes for your simulation
  dSpaceCollide(space,0,&nearCallback);
  dWorldStep(world,0.01);
  dJointGroupEmpty(contactgroup);
}

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

The sample program does not draw anything, if you want to use Drawstuff, comment out the line 13 below.

// # Define DRAW Back to the drawing off the comments.

That’s all.  See you !

demu

スポンサーリンク
シェアする
demura.netをフォローする
タイトルとURLをコピーしました