Hi,everyone;
I got a problem when test the demo of JME jmetestrendererTestMilkJmeWrite.java
I can't get WorldBound of Node at first,however got it when updating.
public class TestMilkJmeWrite2 extends SimpleGame{
Node i=null;
private static final Logger logger = Logger
.getLogger(TestMilkJmeWrite.class.getName());
public static void main(String[] args) {
new TestMilkJmeWrite2().start();
}
protected void simpleInitGame() {
try {
ResourceLocatorTool.addResourceLocator(
ResourceLocatorTool.TYPE_TEXTURE,
new SimpleResourceLocator(TestMilkJmeWrite.class
.getClassLoader().getResource(
"jmetest/data/model/msascii/")));
} catch (URISyntaxException e1) {
logger.log(Level.WARNING, "unable to setup texture directory.", e1);
}
MilkToJme converter=new MilkToJme();
URL MSFile=TestMilkJmeWrite.class.getClassLoader().getResource(
"jmetest/data/model/msascii/run.ms3d");
ByteArrayOutputStream BO=new ByteArrayOutputStream();
try {
converter.convert(MSFile.openStream(),BO);
} catch (IOException e) {
logger.info("IO problem writting the file!!!");
logger.info(e.getMessage());
System.exit(0);
}
try {
i=(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
} catch (IOException e) {
logger.info("darn exceptions:" + e.getMessage());
}
i.setLocalScale(.1f);
i.setModelBound(new BoundingSphere());
i.updateModelBound();
rootNode.attachChild(i);
//create a sphere to compare
Sphere target;
target = new Sphere("my sphere", 15, 15, 1);
target.setModelBound(new BoundingSphere());
target.updateModelBound();
rootNode.attachChild(target);
System.out.println("bbb"+i.getWorldBound());//print null
System.out.println("target"+target.getWorldBound());//print BoundingShpere
}
protected void simpleUpdate(){
System.out.println("bbb"+i.getWorldBound());//print BoundingShpere
}
}
Run results:
bbbnull
targetcom.jme.scene.BoundingSphere [Radius: 1.00002 Center: com.jme.math.Vector3f [X=5.9604645E-8, Y=1.4901161E-8, Z=0.0]]
cccom.jme.scene.BoundingSphere [Radius: 3.866392 Center: com.jme.math.Vector3f [X=0.13460055, Y=3.7336762, Z=0.31864902]]
cccom.jme.scene.BoundingSphere [Radius: 4.024398 Center: com.jme.math.Vector3f [X=0.29568264, Y=-0.016815811, Z=0.1889005]]
......
So,I want to know how can I get WorldBound at first.
Thanks!