Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Correct way to get bounding box of scene node?
#1
What's the correct way to get the bounding box of a scene node? There is SceneNode.WorldBoundingBox, but I don't think this updates the bounding box when it's dirty, so I've considered calling SceneNode.Update before accessing the WorldBoundingBox. Then I found Scene.UpdateSceneNodeWorldMatrixData(SceneNode), which is another option. So I'm not sure what the best way to get the up-to-date bounding box is.

On a related note, what is the correct way to get the up-to-date world matrix of the scene node?
#2
Each SceneNode has two bounding boxes: localBoundingBox and WorldBoundingBox.

The localBoundingBox is in local coordinates (not affected by the parent's transformations) and is transformed by the SceneNode's transformation. Because localBoundingBox is protected, you need to call the GetLocalBoundingBox method to get its value (note that this method takes an updateIfDirty parameter that is true by default).

The WorldBoundingBox is in world coordinates and is transformed by the parent's transformations and the transformation on this SceneNode.

See the related help topics:
https://www.ab4d.com/help/SharpEngine/ht...ingBox.htm
https://www.ab4d.com/help/SharpEngine/ht...ingBox.htm
https://www.ab4d.com/help/SharpEngine/ht...ingBox.htm

Note that the online help info text should also be available through IntelliSense.

When you change a transformation on a SceneNode, then the LocalBoundingBox is immediately changed.
To update the WorldBoundingBox you need to call SceneNode.Update method.

But if the transformation is changed on the parent's GroupNode, then you need to call GroupNode.Update to update the WorldBoundingBox on the child nodes.

You can also always call the Scene.Update method - this will update the WorldBoundingBox on all "dirty" SceneNodes (SceneNode's DirtyFlags indicate that WorldBoundingBox needs to be updated).


If the mesh is changed in MeshModelNode, then you need to call Mesh.Update and MeshModelNode.Update to get the updated WorldBoundingBox.



The Scene.UpdateSceneNodeWorldMatrixData method is used by the effects - the method get the current value of the WorldBoundingBox and updates the GpuBuffer that stores the world matrices data for the GPU - see https://www.ab4d.com/help/SharpEngine/ht...ixData.htm
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)