Package com.jme3.scene
Class SceneGraphIterator
java.lang.Object
com.jme3.scene.SceneGraphIterator
Iterates over the scene graph with the depth-first traversal method.
This method of scene traversal allows for more control of the iteration
process than Spatial.depthFirstTraversal(com.jme3.scene.SceneGraphVisitor)
because it implements Iterator
(enabling it to be used in for-loops).
-
Constructor Summary
ConstructorDescriptionSceneGraphIterator
(Spatial main) Instantiates a newSceneGraphIterator
instance that starts iterating at the given main spatial. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
SceneGraphIterator
Instantiates a newSceneGraphIterator
instance that starts iterating at the given main spatial.- Parameters:
main
- the main spatial to start iteration from
-
-
Method Details
-
iterator
-
hasNext
public boolean hasNext() -
next
-
current
Gets the spatial the iterator is currently on.- Returns:
- current spatial
-
ignoreChildren
public void ignoreChildren()Makes this iterator ignore all children of the current spatial. The children of the current spatial will not be iterated through. -
getDepth
public int getDepth()Gets the current depth of the iterator.The depth is how far away from the main spatial the current spatial is. So, the main spatial's depth is 0, all its children's depths is 1, and all their children's depths is 2, etc.
- Returns:
- current depth, or distance from the main spatial.
-