Getting size of node

Hi,



How do I get the size (x,y,z) of a Node?

Nodes don’t have a size… they have children. You can get how many children with Quantity… they have a world translation which you can get as well getWorldTranslation… they also have a bounding volume (if their children do) which you can get with getWorldBounds.

What do you mean by size?

Thanks for the quick reply allthough I’m afraid I don’t quiet understand. I get my Node from loading a ms3d model.



I don’t want to get the quantity of children, just the spatial x,y,z size… It’s for creating a “dummy box” to add to the ode physics system.



Thanks

Getting the worldBounds as Cep suggests would be your best bet. Nodes are abstract things… they do not represent physical objects in the world as Geometry (TriMesh) do.

The world bounds would be your best bet then. The Node of the model is a containment of all the "pieces" of the model. That is, a model is commonly made up of multiple TriMeshes, and the Node is the container for all these pieces. The world bounds will contain all the meshes.

To get the "size" you need to get the bounding volume with getWorldBounds. The bounding volume returns ether a box or a Sphere that surrounds the geometry of a node. You can you this information with ode.

Load the node with property “bound”,“box” so it uses bounding boxes. Get the node’s world bound and cast it to a bounding box. Check that bounding box for the center and extents

Ok, so is:


node.setWorldBound( new BoundingBox() );
node.updateWorldBound();



equivalent to loading the model with the "bound","box" property?

No. Users should never ever use the function setWorldBound. It’s an internal thing

Model bound is what you manually set (in some cases) world bound is calculated by the scene graph every update. World bounds are created from a merging of multiple model bounds.

Love how the developers are so quick on the draw here that you get 3 similar answers in a 5 minute span. XD

Ah, ok I see, but when loading a model like this:


converter.setProperty("bound","box");
converter.convert(model.openStream(),BO);
node = jbr.loadBinaryFormat(
      new ByteArrayInputStream(BO.toByteArray()));



Gettings the world bound seems to return null :?


BoundingBox playerBox = (BoundingBox)node.getWorldBound();

It requires at least one call to updateGeometricState or updateWorldBounds if you just need the bounds. This is because the bounds are generated after the scene graph is built.



EDIT: Don’t use updateWorldBounds… my mistake.

Call updateGeometricState (0,true) then get the world bound. That will tell it to buidl the world bound.

It still returns null :frowning:

No sorry, when using updateGeometricState(0,true) instead of updateWorldBound() it worked.



Thanks!

Yeah, I didn’t get my “edit” in on my post in time.

It seems to be returning a BoundingSphere though, and when trying to cast it into a BoundingBox I get a ClassCastException.

You have to load it as a BoundingBox "bound","box"