I am attempting to get a bounding box for a Geometry object.
As I understand it, by default a BoundingSphere is set for a given objects modelBounds. This is no good for me since I need to position objects based on their width, and they are often taller than they are wide.
What I did was to set the modelBounds to a new BoundingBox, and then update the modelBounds:
geometry.setModelBound( new BoundingBox() );
geometry.updateModelBound();
however, this produces:
java.lang.ClassCastException
at com.jme.bounding.BoundingBox.transform(BoundingBox.java:211)
at com.jme.scene.Geometry.updateWorldBound(Geometry.java:854)
at com.jme.scene.Geometry.updateModelBound(Geometry.java:769)
it appears that BoundingBoxes don't like transforming BoundingSpheres (and vice versa). In the transform method, they cast the passed BoundingVolume to their own type.
to make the whole thing work I have to do this:
geometry.setWorldBound( new BoundingBox() );
geometry.setModelBound( new BoundingBox() );
geometry.updateModelBound();
Am I doing something silly or is there an easier route to the result I want ?