Sure,
here is an example as simple as it gets:
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.instancing.InstancedNode;
import com.jme3.scene.shape.Sphere;
public class Main extends SimpleApplication {
public static void main(String[] args){
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
Mesh mesh = new Sphere(13, 13, 0.4f, true, false);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setBoolean("UseInstancing", true);
mat.setColor("Color", ColorRGBA.Red);
InstancedNode instancedNode = new InstancedNode("Node");
instancedNode.setLocalTranslation(128, 128, 0);
Geometry geom = new Geometry("Geometry", mesh);
geom.setMaterial(mat);
geom.setLocalTranslation(0, 0, 0);
System.out.println("Geometry.WorldBound="+geom.getWorldBound());
System.out.println("@BEFORE_ATTACH Node:WorldBound="+instancedNode.getWorldBound());
instancedNode.attachChild(geom);
System.out.println("@AFTER_ATTACH Node:WorldBound="+instancedNode.getWorldBound());
instancedNode.instance();
System.out.println("@AFTER_INSTANCE Node:WorldBound="+instancedNode.getWorldBound());
rootNode.attachChild(instancedNode);
}
}
When I run the above code I get the following output:
Geometry.WorldBound=BoundingBox [Center: (0.005811617, 0.0, 0.0) xExtent: 0.3941884 yExtent: 0.39708355 zExtent: 0.4]
@BEFORE_ATTACH Node:WorldBound=null
@AFTER_ATTACH Node:WorldBound=BoundingBox [Center: (128.00581, 128.0, 0.0) xExtent: 0.3941884 yExtent: 0.39708355 zExtent: 0.4]
@AFTER_INSTANCE Node:WorldBound=BoundingBox [Center: (64.00581, 63.999996, 0.0) xExtent: 64.394196 yExtent: 64.39708 zExtent: 0.4]
The important part is the difference between @AFTER_ATTACH and @AFTER_INSTANCE. You can see the extent of the BoundingBox suddenly increase. The extent of the bounding box is dependent on the translation of the InstancedNode.
If I change the translation from (128.0, 128.0, 0.0) to (256.0, 256.0, 0.0) I get the following output:
Geometry.WorldBound=BoundingBox [Center: (0.005811617, 0.0, 0.0) xExtent: 0.3941884 yExtent: 0.39708355 zExtent: 0.4]
@BEFORE_ATTACH Node:WorldBound=null
@AFTER_ATTACH Node:WorldBound=BoundingBox [Center: (256.0058, 256.0, 0.0) xExtent: 0.3941884 yExtent: 0.39708355 zExtent: 0.4]
@AFTER_INSTANCE Node:WorldBound=BoundingBox [Center: (128.00581, 128.0, 0.0) xExtent: 128.39418 yExtent: 128.3971 zExtent: 0.4]
This seems obviously wrong to me.