I’ve successfully integrated odejava into my project, but I’m having a hell of a time tuning the physics to get what I consider to be believable behavior. Here’s what I have:
I’ve created a GeomTriMesh from a fractal terrain mesh to represent terrain. I’ve also created a simple box geometry to represent the user. The tri-mesh is added to the Space, the box is added to a body, which is added to the world. (BTW, the odejava API is pretty good, but it needs a ton more docs).
I’ve also, of course, created visual representations of all this using Java3D. The visual geometries exactly match the geometries I’m feeding odejava.
When I turn everything on (after setting the box’s body position to be a couple of meters above the terrain), the box falls as expected and contacts the terrain. Then the box jitters a little (as I would expect) as things settle down. If I wait long enough, the box will start to slide down one of the tilted triangles it’s landed on. That’s cool too. But as the simulation continues, the box doesn’t seem to behave very realistically, and eventually will flip completely over for no apparent reason. I’ve read the ODE docs and understand the issues concerning precision and instability, but I can’t seem to get the system to behave nicely.
I think I need some guidelines on what setting values to feed to ODE. For instance, here’s how I set up the world:
odeWorld = new World();
odeWorld.setGravity(0, -9, 0);
odeWorld.setStepInteractions(2);
Ode.setSurfaceMu(4);
Ode.dWorldSetCFM(odeWorld.getId(), 1);
On each frame of rendering, I do this:
odeWorld.setStepSize(frameTimeSeconds);
odeCollision.collide(odeSpace);
odeCollision.applyContacts();
odeWorld.stepFast();
odeConnection.updateAll();
Notice I’m using the DisplayBin class for the odeConnection variable (that whole API works quite nicely, BTW). Notice also that I’m not changing any of the contact collisions.
Am I doing anying fundamentally wrong here? Can anyone suggest better values or other settings for the world? Should I be doing something with the contact collisions?
-Tab