14. Speed-up

This is the 14th ODE (Open Dynamics Engine) tutorial.

This tutorial explans how to speed-up without using drawstuff, the3D 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 the 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
C++:
  1. static void simLoop (int pause)
  2. {
  3.   // Write necessary codes for your simulation
  4.   dSpaceCollide(space,0,&nearCallback);
  5.   dWorldStep(world,0.01);
  6.   dJointGroupEmpty(contactgroup);
  7.   drawSphere(torso.geom);
  8. }
  9.  
  10. int  main(int argc, char *argv[])
  11. {
  12.  // Omit
  13.  dsSimulationLoop(argc, argv, 640, 480,  &fn);
  14.  // Omit
  15. }

  • If you do not want to draw
C++:
  1. static void simLoop (int pause)
  2. {
  3.   // Write necessary codes for your simulation  dSpaceCollide(space,0,&nearCallback);
  4.   dWorldStep(world,0.01);
  5.   dJointGroupEmpty(contactgroup);
  6. }
  7.  
  8. int  main(int argc, char *argv[])
  9. {
  10.   // Omit
  11.   while (1) {
  12.     simLoop(0)// The argument must set to be 0
  13.   }
  14.   // Omit
  15. }

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

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

That's all.  See you !

demu

Leave a Reply

カウンタ (since 2008-3-15)
Copyright © 1998-2008    Kosei Demura