public int getChildCount(final Object parent) { if (parent instanceof UIFrame) { return 1; } if (parent instanceof Node) { final Node parentNode = (Node) parent; return parentNode.getNumberOfChildren(); } return 0; }
/** * * <code>detachAllChildren</code> removes all children attached to this node. */ public void detachAllChildren() { for (int i = getNumberOfChildren() - 1; i >= 0; i--) { detachChildAt(i); } logger.fine("All children removed."); }
/** * * <code>detachAllChildren</code> removes all children attached to this node. */ public void detachAllChildren() { for (int i = getNumberOfChildren() - 1; i >= 0; i--) { detachChildAt(i); } logger.fine("All children removed."); }
public static void trimEmptyBranches(final Spatial spatial) { if (spatial instanceof Node) { final Node node = (Node) spatial; for (int i = node.getNumberOfChildren(); --i >= 0;) { trimEmptyBranches(node.getChild(i)); } if (node.getNumberOfChildren() <= 0) { spatial.removeFromParent(); } } }
public static void trimEmptyBranches(final Spatial spatial) { if (spatial instanceof Node) { final Node node = (Node) spatial; for (int i = node.getNumberOfChildren(); --i >= 0;) { trimEmptyBranches(node.getChild(i)); } if (node.getNumberOfChildren() <= 0) { spatial.removeFromParent(); } } } }
@Override public void updateWorldTransform(final boolean recurse) { super.updateWorldTransform(recurse); if (recurse) { for (int i = getNumberOfChildren() - 1; i >= 0; i--) { _children.get(i).updateWorldTransform(true); } } }
@Override protected void propagateDirtyDown(final EnumSet<DirtyType> dirtyTypes) { super.propagateDirtyDown(dirtyTypes); for (int i = getNumberOfChildren() - 1; i >= 0; i--) { final Spatial child = _children.get(i); child.propagateDirtyDown(dirtyTypes); } }
@Override public void read(final InputCapsule capsule) throws IOException { super.read(capsule); final List<Spatial> cList = capsule.readSavableList("children", null); _children.clear(); if (cList != null) { _children.addAll(cList); } // go through children and set parent to this node for (int i = getNumberOfChildren() - 1; i >= 0; i--) { final Spatial child = _children.get(i); child._parent = this; } } }
@Override public void updateWorldTransform(final boolean recurse) { super.updateWorldTransform(recurse); if (recurse) { for (int i = getNumberOfChildren() - 1; i >= 0; i--) { _children.get(i).updateWorldTransform(true); } } }
@Override public void read(final InputCapsule capsule) throws IOException { super.read(capsule); final List<Spatial> cList = capsule.readSavableList("children", null); _children.clear(); if (cList != null) { _children.addAll(cList); } // go through children and set parent to this node for (int i = getNumberOfChildren() - 1; i >= 0; i--) { final Spatial child = _children.get(i); child._parent = this; } } }
@Override protected void updateWorldRenderStates(final boolean recurse, final RenderState.StateStack stack) { super.updateWorldRenderStates(recurse, stack); if (recurse) { for (int i = getNumberOfChildren() - 1; i >= 0; i--) { _children.get(i).updateWorldRenderStates(true, stack); } } }
@Override protected void propagateDirtyDown(final EnumSet<DirtyType> dirtyTypes) { super.propagateDirtyDown(dirtyTypes); for (int i = getNumberOfChildren() - 1; i >= 0; i--) { final Spatial child = _children.get(i); child.propagateDirtyDown(dirtyTypes); } }
@Override protected void updateWorldRenderStates(final boolean recurse, final RenderState.StateStack stack) { super.updateWorldRenderStates(recurse, stack); if (recurse) { for (int i = getNumberOfChildren() - 1; i >= 0; i--) { _children.get(i).updateWorldRenderStates(true, stack); } } }
@Override protected void updateChildren(final double time) { for (int i = getNumberOfChildren() - 1; i >= 0; i--) { final Spatial pkChild = getChild(i); if (pkChild != null) { pkChild.updateGeometricState(time, false); } } }
@Override public void sortLights() { for (int i = getNumberOfChildren() - 1; i >= 0; i--) { final Spatial pkChild = getChild(i); if (pkChild != null) { pkChild.sortLights(); } } }
@Override public void sortLights() { for (int i = getNumberOfChildren() - 1; i >= 0; i--) { final Spatial pkChild = getChild(i); if (pkChild != null) { pkChild.sortLights(); } } }
@Override protected void updateChildren(final double time) { for (int i = getNumberOfChildren() - 1; i >= 0; i--) { final Spatial pkChild = getChild(i); if (pkChild != null) { pkChild.updateGeometricState(time, false); } } }
private static Spatial makeCopy(final Spatial source, final Spatial parent, final CopyLogic logic) { final AtomicBoolean recurse = new AtomicBoolean(); final Spatial result = logic.copy(source, recurse); if (recurse.get() && source instanceof Node && result instanceof Node && ((Node) source).getNumberOfChildren() > 0) { for (final Spatial child : ((Node) source).getChildren()) { final Spatial copy = makeCopy(child, result, logic); if (copy != null) { ((Node) result).attachChild(copy); } } } return result; }
private static Spatial makeCopy(final Spatial source, final Spatial parent, final CopyLogic logic) { final AtomicBoolean recurse = new AtomicBoolean(); final Spatial result = logic.copy(source, recurse); if (recurse.get() && source instanceof Node && result instanceof Node && ((Node) source).getNumberOfChildren() > 0) { for (final Spatial child : ((Node) source).getChildren()) { final Spatial copy = makeCopy(child, result, logic); if (copy != null) { ((Node) result).attachChild(copy); } } } return result; }
/** * removes all collision trees associated with a Spatial object. * * @param object * the spatial to remove all collision trees from. */ public void removeCollisionTree(final Spatial object) { if (object instanceof Node) { final Node n = (Node) object; for (int i = n.getNumberOfChildren() - 1; i >= 0; i--) { removeCollisionTree(n.getChild(i)); } } else if (object instanceof Mesh) { removeCollisionTree((Mesh) object); } }