[odejava] GeomTransform broken?

I’m trying to use one aspect of the new multi-geom support. Specifically, I’m trying to add a single Geom to a body where the Geom’s center does not coincide with the body’s reference point. I started with code like this:

chassisBody.addGeom(new GeomBox(CHASSIS_WIDTH, CHASSIS_HEIGHT, CHASSIS_DEPTH));

And that works as expected. I then changed it to offset the geom relative to the body:

g = new GeomBox(CHASSIS_WIDTH, CHASSIS_HEIGHT, CHASSIS_DEPTH);
g.setPosition(V_CHASSIS_OFFSET);
gt = new GeomTransform("chassisTransform");
gt.setEncapsulatedGeom(g);
chassisBody.addGeom(gt);

But when I run the sim, the chassis body immediately disappears from view. I haven’t tried to track it down, but maybe it’s falling through the Trimesh terrain. This is also the behavior when V_CHASSIS_OFFSET is a zero vector (0, 0, 0), which I would expect to behave exactly as if there was no GeomTransform, just like the first code block.

Am I doing something wrong? I believe I’m doing things as the ODE docs say, but maybe I missed something.

-Tab

I assume you’ve read: http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=physics;action=display;num=1082775578

The only thing I can see that I did differently is that I set the position of the encapsulated geom AFTER encapuslating it.

ODE’s very procedual at times and likes things in the correct order - maybe that’s it.

try:


g = new GeomBox(CHASSIS_WIDTH, CHASSIS_HEIGHT, CHASSIS_DEPTH);
gt = new GeomTransform("chassisTransform");
gt.setEncapsulatedGeom(g);
chassisBody.addGeom(gt); 

g.setPosition(V_CHASSIS_OFFSET);

Will.

Yes I did see the post you refered to, but had forgotten about it :-/

I’ll try changing the order of the statements. Thanks for the tip.

-Tab

Changing the order as you suggested didn’t help; same problem. However, I have discovered that my model isn’t simply falling through the terrain, but is getting totally dislocated from reality:

location: (-1.0, 50.0, -1.0)
location: (NaN, NaN, NaN)

That’s output from my app for each frame. Each line of output is before I call stepFast. The first line indicates my body’s location as I set it before I run the sim. The second line shows the body’s location after ODE gets done with it. And that’s the last line of output. No additional frames are rendered and it seems the whole Java3D render loop is stuck (trying to render an object that is “nowhere”?).

When I revert to my previous code (i.e., no GeomTransform), I get normal output:

location: (-1.0, 50.0, -1.0)
location: (-1.0, 49.720078, -1.0)
location: (-1.0, 49.613567, -1.0)
location: (-1.0, 49.488773, -1.0)
location: (-0.9878979, 49.206493, -1.0057374)
location: (-0.9750137, 49.111187, -1.0105658)
location: (-0.95794374, 49.023903, -1.0157655)
location: (-0.94674605, 48.94492, -1.0238384)
location: (-0.9331251, 48.95429, -1.0324804)
location: (-0.92429227, 48.981445, -1.0410043)
...

As you can see, the sim runs and the body can be seen to fall under gravity’s influence until it collides with the terrain at about y=49.3, then it bounces a bit and life goes on.

I can’t figure out what’s wrong. I’m willing to try to build a test case, but that would be a horrendous task starting from my current code base. In the test you displayed in the other post, did you have gravity?

-Tab

I’ve got the NaN (means “Not a Number” FYI) issue before and it’s a pain.

Can you run my multi-geom/encapsulated-geom demo? If so, can you try and mimick my code? Try running org.odejava.test.simple.MultiGeomTest (you’ll need to run it though a harness - either the Xith3D class RunDemo or your own implementation of RunDemo).

I run :


java -cp xith3d.jar:odejava-xith3d.jar:../odejava/odejava.jar org.odejava.xith3d.test.RunDemo org.odejava.test.simple.MultiGeomTest

That code works great for me. I have seen your issue before though - I think ODE just needs things in the correct order. It’s VERY important to make backups/use version control with this I find, being able to roll back to the last working version is essentiall!

Will.

No luck yet. I’ve run the demo and it works as expected. My code is doing exactly what yours is, in the same order. I’m still scratching my head.

I’ll try to reduce my code to the bare minimum while reproducing my problem. I have no idea how long this will take because some real life is intruding on my play time. I’ll update when I get something. Thanks.

-Tab

ok, a test case would be good, we can try and work through the problem.

It’s annoying, but I sometimes have similar non-deterministic behaviour from ODE/Odejava (in other words some times it just doesn’t work for no reason).

Will.