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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| 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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| 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
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?