BoundingBox and BoundingCylinder shifted origin

Hi!

I’m trying to apply a BoundindBox or a BoundingCylinder collision shape to a mesh. However I get the weird problem of them being shifted in regards to the model.



http://i.imgur.com/rFX8t.png



As you can see the BoundingBox and BoundingCylinder is lower than the mesh. And I use simply:

[java]

Geometry geom = (Geometry) assetManager.loadModel(model);



CollisionShape shape = CollisionShapeFactory.createBoxShape(geom);



RigidBodyControl control = new RigidBodyControl( shape , 0.0f );

geom.addControl(control);

bulletAppState.getPhysicsSpace().add(control);



[/java]



How can I make it work properly?



thanks a lot :slight_smile:

Either adjust in your modelling program or

attach the model to a node, but before attaching adjust the local translation. then attach the physics to the node.

The geometry batch factory can do this.

Edit: nonsense… worked too much today, sorry ^^ I meant the collision shape factory but in fact it doesn’t account for the offset of the bounding boxes… So you’d have to find the offset between the bounding box center and the spatial center and then offset the collision shape in the compound shape to the same amount. And in fact the CollisionShapeFactory should do so too ^^

2 Likes