public static Node getClodNodeFromParent(Node meshParent) {
// Create a node to hold my cLOD mesh objects
Node clodNode = new Node("Clod node");
// For each mesh in maggie
for (int i = 0; i < meshParent.getQuantity(); i++){
final Spatial child = meshParent.getChild(i);
if(child instanceof Node) {
clodNode.attachChild(getClodNodeFromParent((Node)child));
}
else if ( child instanceof TriMesh ) {
// Create an AreaClodMesh for that mesh. Let it compute records automatically
AreaClodMesh acm = new AreaClodMesh("part"+i,(TriMesh)child, null);
acm.setModelBound(new BoundingSphere());
acm.updateModelBound();
// Allow 1/2 of a triangle in every pixel on the screen in the bounds.
acm.setTrisPerPixel(.5f);
// Force a move of 2 units before updating the mesh geometry
acm.setDistanceTolerance(2);
// Give the clodMesh node the material state that the original had.
acm.setRenderState(child.getRenderState(RenderState.RS_MATERIAL));
// Attach clod node.
clodNode.attachChild(acm);
}
else
{
System.err.println("Unhandled Spatial type: " + child.getClass());
}
}
return clodNode;
}