[ODE] Combining OSG (osgART) and ODE

Rémi Chaignon remi.chaignon at gmail.com
Mon May 21 17:56:18 MST 2007

Hi everyone,

I have an application using OpenSceneGraph (osgART actually) and I would
like to combine OpenDynamicsEngine with it. I have used the Dice example
from Don Burns as a basis (http://donburns.net/OSG/Dice), but the simulation
goes wrong. I have tried many ways to set up the ground plane and the
gravity of the ODE World, but the dice were either floating in the air, or
oscillating in the world around the wrong axis. I assume the problem comes
from the referential, I'm not sure it is the same between OSG and ODE, or
from a mistake in matrix conversion between OSG and ODE.

Here are 2 ways to set up my applications that I tried and unfortunately did
not work:

1) In his example, Don Burns set the camera with a LookAt like this:
        camera->setViewByLookAt( 0, -220, 0, 0, 0, 0, 0, 0, 1);

   So I assume the coordinate system is: X right; Y forward; Z up.
   Then he sets ODE like this:
        dWorldSetGravity(world, 0, 0, -9.80);
        setGroundPlane( osg::Plane(0, 0, 1, -100) );

   In my application, the projection matrix is set up by ARToolKit, but I
got the LookAt attributes and it's like this:
        eye: 0, 0, -20;  center: 0, 0, -19;  up: 0, 3, 0

   So I assume my coordinate system is: X right; Y up; Z forward.
   And I tried to set up ODE like this:
        dWorldSetGravity(world, 0, -9.80, 0;
        setGroundPlane( osg::Plane(0, 1, 0, -100) );

     Without collision: the dice fall realisticly along the good axis.
     With collision: the dice are floating in the air, they seem to collide
with something sometimes, but I'm not sure :s (one is going quite fast on
the left)

2) At application start up, 3 markers are in the same ground, the
application get their matrix and position and extract a plane from them (
osg::Plane(v0, v1, v2); ).
    I set the ground plane of the ODE world with this plane. For the
gravity, I get the normal of the plane, normalize it, and scale it by
-9.80(current example:
0.25, 8.25, 5.25).

     Without collision: the dice goes up along the good axis, if I put the
density a little bit higher, the dices fall realisticly.
     With collision: the dice are floating in the air.

I don't understand why the collisions put such a mess. I've tried to tweak
the gravity factor, the plane, the density of the object in ODE, the CFM but
nothing made sense. I have seen what looked like collisions but the models
were already well inside each other, so I suppose what is displayed (the OSG
part) does not correspond to what is in ODE. Somehow, although ODE is set up
from OSG, and OSG's transform are set by ODE's matrix, both world are not
the same.

I'm sorry if I haven't been clear enough. I'm quite lost, any help would be
very much appreciated.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ode.org/pipermail/ode/attachments/20070522/d0cebcc3/attachment.htm

More information about the ODE mailing list