OdeJava: Body with multiple Geoms

While trying to optimize my Xith/Ode-Combination, i tried to add multiple geoms to one body and encountered a problem: There seems to be no way to position the geoms within the body, so for now they all collapse. I am trying to avoid building a body from geomTriMeshs to gain more performce, so i would like to add some basic geoms to one body. I already tried to encapsulate the geom with a geomTransForm, but encountered the problem that the geomTransform seems not to collide with the rest of my objects.

Anyone tried this before / has a solution ?

Thanks in advance

Encapsulating the Geoms in a GeomTransform works. I already did that with succes.
Important: You’ll have to add the GeomTransformS to your space, where you calculate the collisions, i believe.

Arne

That’s cool to know, so i’m doing something wrong here. At first i’m creating a geom, then adding this to a newly created GeomTransform. Afterwards i set the position of the geom in the GeomTransform and add the geomTransform (and only that) to a body. Is this ok ? Is this the way to add more than one geom to a body ?

Yes. You’ll have to create a GeomTransform for every Geom you want to add to the Body.

Only a side thing I’d like to mention, so you can more easily understand this:
If A is the transform of the Body and
if B is the transform of the Geom then
the GeomTransform will have a transform of A*B.

Arne

I think i understood this, i left all rotational components zero for now and tried to synchronize the positions first. I’m setting the position of the geom relativ to the position of the encapsulating body. Then i add this body to ode, like i did with other primitives. What happens is, that the body containing the geomTransForm gets correctly influenced by ode’s gravity, but does not collide like/with other objects. I’m printing position of ode body and xith-object every step to assure they’re synchronized, so i don’t think i’m seeing something wrong here. The same coding works, if i add only the geomBox to my body, but that box gets placed at (0,0,0) relativ to body, like i mentioned before, so this way only works for one geometry per body.

That’s strange!
Do you add the Body to the Space or do you add the GeomTransform?

I add the geom to the geomTransform, the geomTransform to the body, the body to the space. If i add the geom ( a geomBox ) directly to the body everythings works like a charm.

qudus

Do everything as you do know (with the GeomTransform), but don’t add the Body to the space, but the GeomTransform.

That may work, though i thought geoms are static and not moveable. But that way i will only be able to add one geom. What i wanted to do is add multiple geoms to one body (say: four cubes with a little space in between them ) and see that body act as one collision object. The cubes should have no rotation / position themselves after adding them, only the body. The odejava body-object has a method: getGeoms() and that made me think i could add multiple geoms at different positions in one body to improve performance. I know ode has to check every single geom in that body against other bodies anyway, but at least it would not have to check the geoms of the body against themselves. I’m hoping for a speedup if i add ~100 geoms to a body instead of having 100 bodies. Somewhere in ode documentation ( or source perhaps ) if found that using geomTriMesh is much more expensive than using basic primitives. My final goal would be a level loader that can build collision objects only from primitives, so only xith has to deal with TriMeshes to optically accurate.

You miss understood me. You add the GeomTransform also to the Body. Tried that?


GeomCube c1 = new GeomCube();
GeomCube c2 = new GeomCube();
GeomTransform t1 = new GeomTransform();
GeomTransform t2 = new GeomTransform();
t1.setEncapsulated(c1); // I don't know the method-name out of my mind - I wan't to add c1 to t1
t2.setEncapsulated(c2);
Body b = new Body();
b.addGeom(t1);
b.addGeom(t2);
HashSpace s = new HashSpace();
s.add(t1);
s.add(t2);

Right, i miss understood you, I will try that next. And by the way: Thanks for all your help here, i noticed you help with lots of questions in this forum. I hope i will be able to help out now and then if i’m a little bit more into xith/ode.

qudus