I am basically trying to get the size of the bounding volumn(box or sphere) after updating my model's bound, but it keeps giving me 0's for everything; like radius, center x and y etc.
Can anyone please looks at my code and see what's wrong?
Note: I have inserted a system.out.println() in the code right after I updated all the bounds, and the output is:
"com.jme.scene.BoundingSphere [Radius: 0.0 Center: com.jme.math.Vector3f [X=0.0, Y=0.0, Z=0.0]]"
protected void simpleInitGame() {
// Point to a URL of my model
URL model = HelloModelLoading.class.getClassLoader().getResource("Spaseship.3ds");
// Create something to convert .obj format to .jme
FormatConverter converter = new MaxToJme();
// Point the converter to where it will find the .mtl file from
converter.setProperty("mtllib", model);
// This byte array will hold my .jme file
ByteArrayOutputStream BO = new ByteArrayOutputStream();
try {
// Use the format converter to convert .obj to .jme
converter.convert(model.openStream(), BO);
Node maggie = (Node) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
// shrink this baby down some
maggie.setLocalScale(10f);
BoundingSphere bs = new BoundingSphere();
maggie.setModelBound(bs);
maggie.updateModelBound();
maggie.updateWorldBound();
System.out.println(bs.toString());
// Put her on the scene graph
rootNode.attachChild(maggie);
} catch (IOException e) { // Just in case anything happens
System.out.println("Damn exceptions!" + e);
e.printStackTrace();
System.exit(0);
}
}
getWorldBound() seems to be working for me.
Hellmaster.
model bounding volumes are set at the leaf level, so that convenience method you are calling at the Node level is setting a new BoundingSphere at the leafs under that Node. Your original boundingsphere object is not modified.
To Hellmaster: which object did you use to getWorldBound() in my case? maggie??
To Renanse: so, is there a method that I can access the leaf node instead of the unchanged, original one?
Thanks for you guys' replies, I found out the solution in a old thread:
http://www.jmonkeyengine.com/jmeforum/index.php?topic=7709.msg60688#msg60688