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
Fields 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
acceptVisitor
(Visitor visitor, boolean preexecute) Execute the given Visitor on this Spatial, and any Spatials managed by this Spatial as appropriate.int
attachChild
(Spatial child) attachChild
attaches a child to this node.int
attachChildAt
(Spatial child, int index) attachChildAt
attaches a child to this node at an index.void
detachAllChildren
removes all children attached to this node.int
detachChild
(Spatial child) detachChild
removes a given child from the node's list.detachChildAt
(int index) detachChildAt
removes a child at a given index.int
detachChildNamed
(String childName) detachChild
removes a given child from the node's list.void
draw
calls the onDraw method for each child maintained by this node.getChild
(int i) getChild
returns a child at a given index.getChild
returns the first child found with exactly the given name (case sensitive.)int
getChildIndex
(Spatial sp) Get the index of the specified spatial.Returns all children to this node.int
getNumberOfChildren
returns the number of children this node maintains.boolean
determines 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 void
propagateDirtyDown
(EnumSet<DirtyType> dirtyTypes) Propagate the dirty mark down the tree hierarchy.void
read
(InputCapsule capsule) void
Sort the ligts on this spatial.void
swapChildren
(int index1, int index2) Swaps two children.protected void
updateChildren
(double time) Override to allow objects like Node to update their children.void
updateWorldBound
(boolean recurse) updateWorldBound
merges the bounds of all the children maintained by this node.protected void
updateWorldRenderStates
(boolean recurse, RenderState.StateStack stack) Called internally.void
updateWorldTransform
(boolean recurse) Updates the worldTransform.void
write
(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 newNode
with a given name.- Parameters:
name
- the name of the node. This is required for identification purposes.
-
Node
Constructs a newNode
with 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
attachChild
attaches 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
attachChildAt
attaches 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
detachChild
removes 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
detachChild
removes 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
detachChildAt
removes 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()detachAllChildren
removes 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:Spatial
Override to allow objects like Node to update their children.- Overrides:
updateChildren
in classSpatial
- Parameters:
time
- The time in seconds between the last two consecutive frames (time per frame). SeeReadOnlyTimer.getTimePerFrame()
-
getChild
getChild
returns a child at a given index.- Parameters:
i
- the index to retrieve the child from.- Returns:
- the child at a specified index.
-
getChild
getChild
returns 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()getNumberOfChildren
returns the number of children this node maintains.- Returns:
- the number of children this node maintains.
-
propagateDirtyDown
Description copied from class:Spatial
Propagate the dirty mark down the tree hierarchy.- Overrides:
propagateDirtyDown
in classSpatial
- Parameters:
dirtyTypes
- the dirty types
-
updateWorldTransform
public void updateWorldTransform(boolean recurse) Description copied from class:Spatial
Updates the worldTransform.- Overrides:
updateWorldTransform
in 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:Spatial
Called internally. Updates the render states of this Spatial. The stack contains parent render states.- Overrides:
updateWorldRenderStates
in 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
draw
calls the onDraw method for each child maintained by this node. -
updateWorldBound
public void updateWorldBound(boolean recurse) updateWorldBound
merges the bounds of all the children maintained by this node. This will allow for faster culling operations.- Specified by:
updateWorldBound
in classSpatial
- Parameters:
recurse
- true to recurse down the scenegraph tree- See Also:
-
acceptVisitor
Description copied from class:Spatial
Execute the given Visitor on this Spatial, and any Spatials managed by this Spatial as appropriate.- Overrides:
acceptVisitor
in 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:Spatial
Sort the ligts on this spatial.- Overrides:
sortLights
in classSpatial
-
makeCopy
Description copied from class:Spatial
Create a copy of this spatial. -
makeInstanced
Description copied from class:Spatial
Creates 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:
makeInstanced
in classSpatial
- Returns:
- an instanced copy of this node
-
getClassTag
- Specified by:
getClassTag
in interfaceSavable
- Overrides:
getClassTag
in classSpatial
- See Also:
-
write
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classSpatial
- Parameters:
capsule
- the capsule- Throws:
IOException
- Signals that an I/O exception has occurred.- See Also:
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classSpatial
- Parameters:
capsule
- the input capsule- Throws:
IOException
- Signals that an I/O exception has occurred.- See Also:
-