/** * Retrieve the spatial with given reference class. * * @param root The root <code>Node</code> to stop check at. * @param spatial The <code>Spatial</code> to check. * @param reference The <code>Class</code> reference of the expected object. * @return The <code>Spatial</code> that is of the given reference <code>Class</code>. */ private Spatial validateClass(Node root, Spatial spatial, Class<? extends Spatial> reference) { if (spatial.getClass().equals(reference)) { return spatial; } else { while (spatial.getParent() != null) { spatial = spatial.getParent(); if (spatial == root) { return null; // TODO Should throw an exception here saying reached parent. } else if (spatial.getClass().equals(reference)) { return spatial; } } // TODO Should throw an exception here saying that cannot find the referencing class. } return null; }
/** * Validates that the 'skins' node is either null or contains only Geometry children. * * @throws IllegalStateException if 'skins' contains a non-Geometry child. */ protected void validateSkins() { if (skins == null || skins.getQuantity() < 1) return; for (Spatial child : skins.getChildren()) if (!(child instanceof Geometry)) throw new IllegalStateException( "'skins' contains non-Geometry child: " + child.getName() + " of type " + child.getClass().getName()); }
public static void printStructure(Spatial s) { if (s.getParent() != null) { logger.debug( s.getParent().getName() + "." + s.getName() + " (" + s.getClass().getName() + ")"); } else { logger.debug("Printing Structure of " + s.getName()); } if (s instanceof Node) { if (((Node) s).getChildren() != null) { for (Spatial child : ((Node) s).getChildren()) { printStructure(child); } } } }
/** * Configurable method to print information about an object. * * @param toUse * @param s * @param recursive * @param translation * @param rotation * @param scale */ public static void printInformation( Logger toUse, Spatial s, boolean recursive, boolean translation, boolean rotation, boolean scale) { logger.info(s.getClass().getSimpleName() + ": " + s.getName()); if (translation) toUse.info( s.getName() + " Translation: " + s.getLocalTranslation().x + "," + s.getLocalTranslation().y + "," + s.getLocalTranslation().z); if (rotation) { float[] angles = s.getLocalRotation().toAngles(null); toUse.info(s.getName() + " Rotation: " + angles[0] + "," + angles[1] + "," + angles[2]); } if (scale) toUse.info( s.getName() + " Scale: " + s.getLocalScale().x + "," + s.getLocalScale().y + "," + s.getLocalScale().z); if (recursive) { if (s instanceof Node) { if (((Node) s).getQuantity() > 0) { for (Spatial child : ((Node) s).getChildren()) { printInformation(toUse, child, recursive, translation, rotation, scale); } } } } }