Package com.ardor3d.scenegraph
Class Node
java.lang.Object
com.ardor3d.scenegraph.Spatial
com.ardor3d.scenegraph.Node
- Direct Known Subclasses:
Arrow,AxisRods,BillboardNode,CameraNode,ParticleSystem,PassNode,QuadImposterNode,RenderedText,Skybox,Skybox,SwitchNode,Terrain,UIComponent,UIHud,WaterNode
Node defines an internal node of a scene graph. The internal node maintains a collection of children and handles
merging said children into a single bound to allow for very fast culling of multiple nodes. Node allows for any
number of children to be attached.
-
Field Summary
FieldsFields inherited from class com.ardor3d.scenegraph.Spatial
_controllers, _delegateMap, _dirtyMark, _frustumIntersects, _listener, _localTransform, _name, _parent, _queueDistance, _renderStateList, _sceneHints, _userData, _worldBound, _worldTransform, ON_DIRTY_ATTACHED, ON_DIRTY_BOUNDING, ON_DIRTY_RENDERSTATE, ON_DIRTY_TRANSFORM, ON_DIRTY_TRANSFORM_ONLY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidacceptVisitor(Visitor visitor, boolean preexecute) Execute the given Visitor on this Spatial, and any Spatials managed by this Spatial as appropriate.intattachChild(Spatial child) attachChildattaches a child to this node.intattachChildAt(Spatial child, int index) attachChildAtattaches a child to this node at an index.voiddetachAllChildrenremoves all children attached to this node.intdetachChild(Spatial child) detachChildremoves a given child from the node's list.detachChildAt(int index) detachChildAtremoves a child at a given index.intdetachChildNamed(String childName) detachChildremoves a given child from the node's list.voiddrawcalls the onDraw method for each child maintained by this node.getChild(int i) getChildreturns a child at a given index.getChildreturns the first child found with exactly the given name (case sensitive.)intgetChildIndex(Spatial sp) Get the index of the specified spatial.Returns all children to this node.intgetNumberOfChildrenreturns the number of children this node maintains.booleandetermines if the provided Spatial is contained in the children list of this node.makeCopy(boolean shareGeometricData) Create a copy of this spatial.Creates and returns a new instance of this spatial.protected voidpropagateDirtyDown(EnumSet<DirtyType> dirtyTypes) Propagate the dirty mark down the tree hierarchy.voidread(InputCapsule capsule) voidSort the ligts on this spatial.voidswapChildren(int index1, int index2) Swaps two children.protected voidupdateChildren(double time) Override to allow objects like Node to update their children.voidupdateWorldBound(boolean recurse) updateWorldBoundmerges the bounds of all the children maintained by this node.protected voidupdateWorldRenderStates(boolean recurse, RenderState.StateStack stack) Called internally.voidupdateWorldTransform(boolean recurse) Updates the worldTransform.voidwrite(OutputCapsule capsule) Methods inherited from class com.ardor3d.scenegraph.Spatial
addController, addTranslation, addTranslation, applyWorldRenderStates, clearControllers, clearDirty, clearDirty, clearRenderState, getController, getControllerCount, getControllers, getCurrentRenderDelegate, getLastFrustumIntersection, getListener, getLocalLastFrustumIntersection, getLocalRenderState, getLocalRenderStates, getName, getParent, getParentHintable, getRenderDelegate, getRotation, getScale, getSceneHints, getTransform, getTranslation, getUserData, getWorldBound, getWorldRotation, getWorldScale, getWorldTransform, getWorldTranslation, hasAncestor, isDirty, localToWorld, markDirty, markDirty, onDraw, propagateBoundToRoot, propagateDirtyUp, propagateStatesFromRoot, propageEventUp, removeController, removeController, removeFromParent, setLastFrustumIntersection, setListener, setName, setParent, setRenderDelegate, setRenderState, setRotation, setRotation, setScale, setScale, setScale, setTransform, setTranslation, setTranslation, setUserData, setWorldRotation, setWorldRotation, setWorldScale, setWorldScale, setWorldScale, setWorldTransform, setWorldTranslation, setWorldTranslation, toString, updateControllers, updateGeometricState, updateGeometricState, updateWorldRenderStates, worldToLocal
-
Field Details
-
_children
This node's children.
-
-
Constructor Details
-
Node
public Node()Constructs a new Spatial. -
Node
Constructs a newNodewith a given name.- Parameters:
name- the name of the node. This is required for identification purposes.
-
Node
Constructs a newNodewith a given name.- Parameters:
name- the name of the node. This is required for identification purposes.children- the list to use for storing children. Defaults to a synchronized ArrayList, but using this constructor, you can select a different kind of list.
-
-
Method Details
-
attachChild
attachChildattaches a child to this node. This node becomes the child's parent. The current number of children maintained is returned.
If the child already had a parent it is detached from that former parent.- Parameters:
child- the child to attach to this node.- Returns:
- the number of children maintained by this node.
-
attachChildAt
attachChildAtattaches a child to this node at an index. This node becomes the child's parent. The current number of children maintained is returned.
If the child already had a parent it is detached from that former parent.- Parameters:
child- the child to attach to this node.index- the index of the child to be attached.- Returns:
- the number of children maintained by this node.
-
detachChild
detachChildremoves a given child from the node's list. This child will no longe be maintained.- Parameters:
child- the child to remove.- Returns:
- the index the child was at. -1 if the child was not in the list.
-
detachChildNamed
detachChildremoves a given child from the node's list. This child will no longe be maintained. Only the first child with a matching name is removed.- Parameters:
childName- the child to remove.- Returns:
- the index the child was at. -1 if the child was not in the list.
-
detachChildAt
detachChildAtremoves a child at a given index. That child is returned for saving purposes.- Parameters:
index- the index of the child to be removed.- Returns:
- the child at the supplied index.
-
detachAllChildren
public void detachAllChildren()detachAllChildrenremoves all children attached to this node. -
getChildIndex
Get the index of the specified spatial.- Parameters:
sp- spatial to retrieve index for.- Returns:
- the index
-
getChildren
Returns all children to this node.- Returns:
- a list containing all children to this node
-
swapChildren
public void swapChildren(int index1, int index2) Swaps two children.- Parameters:
index1- the index of the first child to swapindex2- the index of the second child to swap
-
updateChildren
protected void updateChildren(double time) Description copied from class:SpatialOverride to allow objects like Node to update their children.- Overrides:
updateChildrenin classSpatial- Parameters:
time- The time in seconds between the last two consecutive frames (time per frame). SeeReadOnlyTimer.getTimePerFrame()
-
getChild
getChildreturns a child at a given index.- Parameters:
i- the index to retrieve the child from.- Returns:
- the child at a specified index.
-
getChild
getChildreturns the first child found with exactly the given name (case sensitive.) If our children are Nodes, we will search their children as well.- Parameters:
name- the name of the child to retrieve. If null, we'll return null.- Returns:
- the child if found, or null.
-
hasChild
determines if the provided Spatial is contained in the children list of this node.- Parameters:
spat- the child object to look for.- Returns:
- true if the object is contained, false otherwise.
-
getNumberOfChildren
public int getNumberOfChildren()getNumberOfChildrenreturns the number of children this node maintains.- Returns:
- the number of children this node maintains.
-
propagateDirtyDown
Description copied from class:SpatialPropagate the dirty mark down the tree hierarchy.- Overrides:
propagateDirtyDownin classSpatial- Parameters:
dirtyTypes- the dirty types
-
updateWorldTransform
public void updateWorldTransform(boolean recurse) Description copied from class:SpatialUpdates the worldTransform.- Overrides:
updateWorldTransformin classSpatial- Parameters:
recurse- usually false when updating the tree. Set to true when you just want to update the world transforms for a branch without updating geometric state.
-
updateWorldRenderStates
Description copied from class:SpatialCalled internally. Updates the render states of this Spatial. The stack contains parent render states.- Overrides:
updateWorldRenderStatesin classSpatial- Parameters:
recurse- true to recurse down the scenegraph treestack- The parent render states, or null if we are starting at this point in the scenegraph.
-
draw
drawcalls the onDraw method for each child maintained by this node. -
updateWorldBound
public void updateWorldBound(boolean recurse) updateWorldBoundmerges the bounds of all the children maintained by this node. This will allow for faster culling operations.- Specified by:
updateWorldBoundin classSpatial- Parameters:
recurse- true to recurse down the scenegraph tree- See Also:
-
acceptVisitor
Description copied from class:SpatialExecute the given Visitor on this Spatial, and any Spatials managed by this Spatial as appropriate.- Overrides:
acceptVisitorin classSpatial- Parameters:
visitor- the Visitor object to use.preexecute- if true, we will visit this Spatial before any Spatials we manage (such as children of a Node.) If false, we will visit them first, then ourselves.
-
sortLights
public void sortLights()Description copied from class:SpatialSort the ligts on this spatial.- Overrides:
sortLightsin classSpatial
-
makeCopy
Description copied from class:SpatialCreate a copy of this spatial. -
makeInstanced
Description copied from class:SpatialCreates and returns a new instance of this spatial. Used for instanced rendering. All instances visible on the screen will be drawn in one draw call. The new instance will share all data (meshData and renderStates) with the current mesh and all other instances created from this spatial.- Overrides:
makeInstancedin classSpatial- Returns:
- an instanced copy of this node
-
getClassTag
- Specified by:
getClassTagin interfaceSavable- Overrides:
getClassTagin classSpatial- See Also:
-
write
- Specified by:
writein interfaceSavable- Overrides:
writein classSpatial- Parameters:
capsule- the capsule- Throws:
IOException- Signals that an I/O exception has occurred.- See Also:
-
read
- Specified by:
readin interfaceSavable- Overrides:
readin classSpatial- Parameters:
capsule- the input capsule- Throws:
IOException- Signals that an I/O exception has occurred.- See Also:
-