How to get ModelBound?

I want to get the size/extends of a loaded Model to unify their size at runtime.

So I did:

mesh.setModelBound(new BoundingBox());



BoundingSphere bound = (BoundingSphere)mesh.getWorldBound();

mesh.setLocalScale(1f/bound.getRadius()); // unifiy display size to one

but the problem is that the returned bound is always null? What I do not understand is the difference between ModelBound and WorldBound and why there is only a setter for ModelBound but the getter is just for WorldBound, thee is no "getModelBound"?

i never really understood what updatemodelbound, updateworldbound and updategeometricstate are actually doing. it seems it just works the way i do it. :smiley:

updateModelBound(): take the bounding model that has been set and apply dimensions to contain geometric object

updateWorldBound(): take multiple model bounds and collapse them into one bounding area

updateGeometricState():  apply transformations to geometry

I think this is correct HoD, although I just gathered it from reading the Javadocs so I am probably wrong…

update the gemometricState after ur update the model bound.

btw, u r attaching a boundingBox to the mesh but u r casting it into a BoundingSphere…u might wanna fix that too.

a sample code here:

mesh.setModelBound(new BoundingBox());
mesh.updateGemetricState(0, true);

BoundingBox bounding = (BoundingBox)mesh.getWorldBound();

1 Like

Thank you now it works!

codymanix said:

Thank you now it works!

glad i could help~ :D

The best way is to check the source :slight_smile:

In NetBeans, you can highlight a class name or method and then right click -> Go to -> Source and instantly know what the method does. jME's design is simple so you should have no problems understanding what's going on.

updateGeometricstate also updates the worldbound.


update the gemometricState after ur update the model bound.

i also encountered a situation where updateworldbound did nothing, but traversing the graph and calling updateworldbound everywhere did create and update the worldbound.
in the end, i wrote a method which just calls a lot on a lot and gives the result i need :). i'll probably optimize it later.

Actually, that brings up a good question for me.

If I call rootNode.updateGeometricState() (or any of the other update functions) is the call passed down through the scenegraph?  It almost seems like it depends on the update method called, updateGeometricState() does but updateWorldBounds() does not.

updtaegeometicstate is recursive, updateworldbound is…kind of. if you have a node without abound, it will stop there, even if its children do have bounds. or so i think.