Hello,
First post on this group !
I’ve adjusted my project to use jMonkeyEngine3. ( I started the project with JAVA3D )
I need to retrieve the bouding box of a loaded spatial :
[java]
public void setBattleground( String fileName, float width, float depth )
{
battlegroundNode = ViewManager.getAssetManager().loadModel( fileName );
BoundingBox box = (BoundingBox) backgroundNode.getWorldBound();
[/java]
I tried the method getWorldBound() but it doesn’t seem to return what I want.
In fact I need to resize my model
[java]
float currentWidth = box.getXExtent();
float currentDepth = box.getZExtent();
float currentHeight= box.getYExtent();
//scale
float xcoeff = width / currentWidth;
float zcoeff = depth / currentDepth;
float ycoeff = ( xcoeff + zcoeff ) / 2.0f;
battlegroundNode.scale( xcoeff, ycoeff, ycoeff );
[/java]
The model is correctly resized but :
[java]
//update
battlegroundNode.updateGeometricState();
box = (BoundingBox) backgroundNode.getWorldBound();
currentWidth = box.getXExtent();
currentDepth = box.getZExtent();
currentHeight= box.getYExtent();
System.out.println( "Scene width : " + String.valueOf( currentWidth ) );
System.out.println( "Scene depth : " + String.valueOf( currentDepth ) );
[/java]
The worldBound hasn’t changed.
–>My questions are :
- What is the differencies between WorldBound and ModelBound ?
- Why do we have only getWorldBound() but setWorldBound() and setModelBound() ?
- How can I retrieve the bounding box of my model ?
Thanks in advance
Edit :
I was doing the wrong thing.
See post : http://hub.jmonkeyengine.org/groups/graphics/forum/topic/retreive-size-anf-position-from-a-loaded-j3o/