com.jme.scene
Class Node

java.lang.Object
  extended bycom.jme.scene.Spatial
      extended bycom.jme.scene.Node
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BillboardNode, BumpMapNode, CameraNode, ImposterNode, LensFlare, LightNode, LoaderNode, SimpleLightNode, Skybox, SwitchNode, TerrainPage, Transient, UIActiveArea, UIObject, WidgetAbstractContainer

public class Node
extends Spatial
implements java.io.Serializable

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.

Version:
$Id: Node.java,v 1.38 2005/02/24 22:58:00 renanse Exp $
Author:
Mark Powell, Gregg Patton
See Also:
Serialized Form

Field Summary
protected  java.util.ArrayList children
          This node's children.
 
Fields inherited from class com.jme.scene.Spatial
currentStates, defaultStateList, forceCull, forceView, frustrumIntersects, geometricalControllers, lightCombineMode, localRotation, localScale, localTranslation, name, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder
 
Constructor Summary
Node()
          Empty Constructor to be used internally only.
Node(java.lang.String name)
          Constructor instantiates a new Node with a default empty list for containing children.
 
Method Summary
protected  void applyRenderState(java.util.Stack[] states)
          Applies the stack of render states to each child by calling updateRenderState(states) on each child.
 int attachChild(Spatial child)
          attachChild attaches a child to this node.
 void detachAllChildren()
          detachAllChildren removes all children attached to this node.
 int detachChild(Spatial child)
          detachChild removes a given child from the node's list.
 Spatial detachChildAt(int index)
          detachChildAt removes a child at a given index.
 int detachChildNamed(java.lang.String childName)
          detachChild removes a given child from the node's list.
 void draw(Renderer r)
          draw calls the onDraw method for each child maintained by this node.
 void drawBounds(Renderer r)
          drawBounds calls super to set the render state then passes itself to the renderer.
 void findCollisions(Spatial scene, CollisionResults results)
          checks this spatial against a second spatial, any collisions are stored in the results object.
 void findPick(Ray toTest, PickResults results)
           
 Spatial getChild(int i)
          getChild returns a child at a given index.
 Spatial getChild(java.lang.String name)
          getChild returns the first child found with exactly the given name (case sensitive.)
 java.util.ArrayList getChildren()
           
 int getQuantity()
          getQuantity returns the number of children this node maintains.
 boolean hasChild(Spatial spat)
          determines if the provide Spatial is contained in the children list of this node.
 boolean hasCollision(Spatial scene, boolean checkTriangles)
           
 Spatial putClone(Spatial store, CloneCreator properties)
           
 Spatial setChild(int i, Spatial child)
          setChild places a child at a given index.
 void setForceView(boolean value)
          setForceView will force the node to be rendered whether it's in the camera frustum or not.
 void updateCollisionTree()
          This method updates the exact bounding tree of any this Spatial.
 void updateWorldBound()
          updateWorldBound merges the bounds of all the children maintained by this node.
 void updateWorldData(float time)
          updateWorldData updates all the children maintained by this node.
 
Methods inherited from class com.jme.scene.Spatial
addController, applyDefaultStates, calculateCollisions, calculatePick, clearCurrentState, clearCurrentStates, clearRenderState, getController, getControllers, getCurrentState, getLastFrustumIntersection, getLightCombineMode, getLocalRotation, getLocalScale, getLocalTranslation, getName, getParent, getRenderQueueMode, getRenderStateList, getTextureCombineMode, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, isForceCulled, isForceView, onDraw, onDrawBounds, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeFromParent, setForceCull, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setName, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setWorldBound, setZOrder, toString, updateGeometricState, updateRenderState, updateRenderState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

children

protected java.util.ArrayList children
This node's children.

Constructor Detail

Node

public Node()
Empty Constructor to be used internally only.


Node

public Node(java.lang.String name)
Constructor instantiates a new Node with a default empty list for containing children.

Parameters:
name - the name of the scene element. This is required for identification and comparision purposes.
Method Detail

getQuantity

public int getQuantity()
getQuantity returns the number of children this node maintains.

Returns:
the number of children this node maintains.

attachChild

public int attachChild(Spatial child)
attachChild attaches a child to this node. This node becomes the child's parent. The current number of children maintained is returned.

Parameters:
child - the child to attach to this node.
Returns:
the number of children maintained by this node.

detachChild

public int detachChild(Spatial child)
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

public int detachChildNamed(java.lang.String childName)
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

public Spatial detachChildAt(int index)
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.


setChild

public Spatial setChild(int i,
                        Spatial child)
setChild places a child at a given index. If a child is already set to that index the old child is returned.

Parameters:
i - the index to set the child to.
child - the child to attach.
Returns:
the old child at the index.

getChild

public Spatial getChild(int i)
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

public Spatial getChild(java.lang.String name)
getChild returns the first child found with exactly the given name (case sensitive.)

Parameters:
name - the name of the child to retrieve.
Returns:
the child if found, or null.

setForceView

public void setForceView(boolean value)
Description copied from class: Spatial
setForceView will force the node to be rendered whether it's in the camera frustum or not.

Specified by:
setForceView in class Spatial
Parameters:
value - true to force viewing, false otherwise.

hasChild

public boolean hasChild(Spatial spat)
determines if the provide Spatial is contained in the children list of this node.

Parameters:
spat - the spatial object to check.
Returns:
true if the object is contained, false otherwise.

updateWorldData

public void updateWorldData(float time)
updateWorldData updates all the children maintained by this node.

Overrides:
updateWorldData in class Spatial
Parameters:
time - the frame time.

draw

public void draw(Renderer r)
draw calls the onDraw method for each child maintained by this node.

Specified by:
draw in class Spatial
Parameters:
r - the renderer to draw to.
See Also:
Spatial.draw(com.jme.renderer.Renderer)

drawBounds

public void drawBounds(Renderer r)
drawBounds calls super to set the render state then passes itself to the renderer.

Specified by:
drawBounds in class Spatial
Parameters:
r - the renderer to display

applyRenderState

protected void applyRenderState(java.util.Stack[] states)
Applies the stack of render states to each child by calling updateRenderState(states) on each child.

Overrides:
applyRenderState in class Spatial
Parameters:
states - The Stack[] of render states to apply to each child.

updateWorldBound

public void updateWorldBound()
updateWorldBound merges the bounds of all the children maintained by this node. This will allow for faster culling operations.

Specified by:
updateWorldBound in class Spatial
See Also:
Spatial.updateWorldBound()

updateCollisionTree

public void updateCollisionTree()
Description copied from class: Spatial
This method updates the exact bounding tree of any this Spatial. If this spatial has children, the function is called recursivly on its children. Spatial objects, such as text, which don't make sense to have an exact bounds are ignored.

Overrides:
updateCollisionTree in class Spatial
See Also:
Spatial.updateCollisionTree()

findCollisions

public void findCollisions(Spatial scene,
                           CollisionResults results)
Description copied from class: Spatial
checks this spatial against a second spatial, any collisions are stored in the results object.

Specified by:
findCollisions in class Spatial
Parameters:
scene - the scene to test against.
results - the results of the collisions.

hasCollision

public boolean hasCollision(Spatial scene,
                            boolean checkTriangles)
Specified by:
hasCollision in class Spatial

findPick

public void findPick(Ray toTest,
                     PickResults results)
Specified by:
findPick in class Spatial

putClone

public Spatial putClone(Spatial store,
                        CloneCreator properties)
Overrides:
putClone in class Spatial

getChildren

public java.util.ArrayList getChildren()