GeomTransform problems

When I create a GeomBox and attach it to a Body, collision detection and response works fine. Here’s the code:

GeomBox gb = new GeomBox(1.0f, 1.0f, 1.0f);
World w = …
Body b = new Body(null, w, gb);

When I encapsulate the GeomBox within a GeomTransform, collision detection no longer works. Here’s the modified code:

GeomBox gb = new GeomBox(1.0f, 1.0f, 1.0f);
GeomTransform gt = new GeomTransform();
gt.setEncapsulatedGeom(gb);

World w = …
Body b = new Body(null, w, gt);

Does anyone know what I’m doing wrong?

are you adding it to a space?

Will.

I have some problems with GeomTransforms too. Trying to run the MultiGeomTest demo, this appears:

ODE Message 2: inertia must be positive definite <ode/scr/ode.cpp:410>

I created some geometries like the example class (MultiGeomExample in odejava test directory) but don’t seem to be useful.

Any idea?

I was attempting to build some multiple geometries bodies. I tried to attach several geometries to a body but they aren’t displayed (using Xith3D HighLevelApiExample and SimpleExample demos). I also created 3 bodies and tried to link them using a fixed joint. They are indeed displayed but the interaction and behavior in not correct. They put together during a free fall. How can I really create a multiple geometry body and display it?

In both cases, I call space.addBodyGeoms(b). I get a warning if I try to add the encapsulated geom.

I am also trying to create a body with multiple geometries :slight_smile:

Got it working! The problem seems to be related to the way that the body’s mass and inertia parameters are set. GeomTransform doesn’t seem to operate correctly after I set body mass using adjustMass. Conversely, I’m not having any problems with GeomTransform after setting the body’s mass and inertial parameters using setMassParameters. :smiley:

[quote]I created some geometries like the example class (MultiGeomExample in odejava test directory) but don’t seem to be useful.
[/quote]
Care to elaborate? The Multi geom test demo look correct to me - I see a box with a rectangle at a set transform.

They should really be created using GeomTransform. Fixed joints shouldn’t be used unless there is a compelling reason and certainly not as a substitute for GeomTransform. I use GeomTransform extensivly and it works well.

Will.

[quote]Got it working! The problem seems to be related to the way that the body’s mass and inertia parameters are set. GeomTransform doesn’t seem to operate correctly after I set body mass using adjustMass. Conversely, I’m not having any problems with GeomTransform after setting the body’s mass and inertial parameters using setMassParameters. :smiley:
[/quote]
Glad you worked it out. I’ve had a few moments like that before too. It is very important to realise that despite the fact Odejava is object orientated, ODE is not and requires calls to be made in a specific order as you have found out. Most of my “strange” problems have all related to mass.

Will.

Thanks for the setMassParameters tip. It is very useful Nevertheless, I still have problems with the HighLevelApiExample shown by Xith3D. I added this in the initObjects() method in HighLevelApiExample.java:

Geombox myBox1 = new GeomBox(depth,length,height);
Geombox myBox2= new GeomBox(depth,length,height);

myBoxBody = new Body("myBody1", world);            
myBoxBody.addGeom(myBox1);
GeomTransform  myTransform = new GeomTransform();
myTransform.setEncapsulatedGeom(myBox2);
myBoxBody.addGeom(myTransform);
myBoxBody.setMassParameters(1f,0f,0f,0f,0.01f,0.01f,0.01f,0.01f,0.01f,0.01f);
            
myBoxBodyId = myBoxBody.getGeom().getNativeAddr();
      
space.addBodyGeoms(myBoxBody);
myBox1.setPosition(  1.5f, 0f, 6.5f);
myBox2.setPosition( -1.5f, 0f, 6.5f);
            
myBoxBody.setPosition(0f,0f,6.5f);

and added this in iterateContacts(), too:


      if(contact.getGeomID2() == myBoxBody){
              contact.getPosition(pos);
              contact.getNormal(normal);
              contact.setMode(Ode.dContactBounce | Ode.dContactApprox1);
              contact.setBounce(1.25f);
              contact.setBounceVel(0.2f);
              contact.setMu(0f);
                    
              System.err.println(
                        "B: "
                        + i
                        + " myBoxBody  hits geom "
                        + contact.getGeomID1()
                        + "\n  d="
                        + contact.getDepth()
                        + "\n  pos="
                        + pos
                        + "\n  normal="
                        + normal);
      }

The SimpleExample of Xith3D was not modified. Both classes were compiled without errors or warnings. When I execute the HighLevelApiExample.class everything seems to be OK and there in no exceptions. Execute this class only produces DOS command lines. But executing SimpleExample.class, everything is OK [b]before [/b]the first contact of myBoxBody with the box defined in HighLevelApiExample that is above the sphere. When the contact occurs, all the bodies displayed disappear.

Any idea?
What am I doing wrong?