JBullet CompoundShape help

If anyone knows a bit about JBullet a bit help would be really nice:



Shouldn't the following two codes produce a shape wich behaves identical?



the working one


DefaultMotionState fallMotionState = new DefaultMotionState();
      javax.vecmath.Vector3f inertia = new javax.vecmath.Vector3f();
      boxshape.calculateLocalInertia(1,inertia);
      RigidBodyConstructionInfo fallconstrutor = new RigidBodyConstructionInfo(1,fallMotionState,boxshape,inertia);
      physicbox = new RigidBody(fallconstrutor);



The one that should  work but does not


      javax.vecmath.Vector3f inertia = new javax.vecmath.Vector3f();
      
      CompoundShape physicshape = new CompoundShape();
      BoxShape boxshape = new BoxShape(new javax.vecmath.Vector3f(1f,1f,1f));
      physicshape.addChildShape(new Transform(), boxshape);
      

      DefaultMotionState fallMotionState = new DefaultMotionState();
      RigidBodyConstructionInfo fallconstrutor = new RigidBodyConstructionInfo(10,fallMotionState,physicshape,inertia);
      physicbox = new RigidBody(fallconstrutor);

Well, here's 3 things.


  1. in the first example, you're actually calculating the local inertia.  You might be in the second example, but it's not there in the code.


  2. In the first example, your mass is 1.  In the second it's 10.


  3. Transform's constructor gives you a "zeroed out" transform . . . NOT an identity transform!!  Call 'setIdentity()' on your transform before you hand it into addChildShape().



    or . . . alternatively, use JMEPhysics with that nifty JBullet integration.  :stuck_out_tongue:

Yay, works now, thanks