Problem with BoundingVolumes

It seems that jme is unable to use boundingspheres for not centerd models?

Is this true?



I have some models that are a few hundred to thousand meters of their center, however the generated boundingspheres for those always have 0,0,0 as center (like the node). The radius itself seems fine however.



The same problem applies for Boundingboxes for some reasons, the min max seems valid, but the center is 0,0,0

Ok, there seems to be really a bug somewhere,



http://aurora42.de/jamwiki-1.2/uploads/en/2012/4/error-29183358.png



The Meshes itself have a correct Bound, however the worldbounds are all false





Frame generated with this:

[java]

private void exportNodeTree(final Spatial rootnode, final String string) {

final JFrame frame = new JFrame(“SceneGraph: " + string);

frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

final DefaultMutableTreeNode masterdescriptor = new DefaultMutableTreeNode(string);

final JTree tree = new JTree(masterdescriptor);

frame.add(new JScrollPane(tree));

this.addAllChilds(rootnode, masterdescriptor);

frame.pack();

frame.setLocationByPlatform(true);

frame.setVisible(true);

}



private void addAllChilds(final Spatial current, final DefaultMutableTreeNode descriptor) {

final BoundingVolume wbound = current.getWorldBound();

String bs = " Bounding: “;

if (wbound == null) {

bs += " none!!!”;

} else {

if (wbound.getType().equals(Type.Sphere)) {

final BoundingSphere bss = (BoundingSphere) wbound;

bs += “Sphere:” + bss.getRadius();

bs += “center:” + bss.getCenter();

} else {

final BoundingBox bss = (BoundingBox) wbound;

bs += “Box:” + bss.getMin(null) + " -> " + bss.getMax(null);

bs += “center:” + bss.getCenter();

}

}



if (current instanceof Geometry) {

final BoundingVolume lbound = ((Geometry) current).getMesh().getBound();

if (lbound.getType().equals(Type.Sphere)) {

final BoundingSphere bss = (BoundingSphere) lbound;

bs += “LSphere:” + bss.getRadius();

bs += “Lcenter:” + bss.getCenter();

} else {

final BoundingBox bss = (BoundingBox) lbound;

bs += “LBox:” + bss.getMin(null) + " -> " + bss.getMax(null);

bs += “Lcenter:” + bss.getCenter();

}

}



final DefaultMutableTreeNode bdescr = new DefaultMutableTreeNode(current + " lpos:” + current.getLocalTranslation() + " cullhint:" + current.getCullHint() + " Tris:" + current.getTriangleCount() + bs);

descriptor.add(bdescr);

if (current instanceof Node) {

final Node node = (Node) current;

for (final Spatial child : node.getChildren()) {

this.addAllChilds(child, bdescr);

}

}

}

[/java]

Facepalm O.o found it., For some reason i had a 0,0,0,0 quaternion stored



suggested patch to help others is:



(cant submit a svn patch sorry)



In boundingvolume at line ~291

Code:
++ assert !trans.getRotation().equals(new Quaternion(0, 0, 0, 0)) : "Invalid rotation";

I don’t get it, was it a problem in your game or in JME?

The problem was that i had a 0,0,0,0 quaternion somehow in the database. (and jme has no assertion that warns me about this when applying it)

oh ok :stuck_out_tongue: