org.xith3d.scenegraph
Class Node

java.lang.Object
  extended by org.xith3d.scenegraph.SceneGraphObject
      extended by org.xith3d.scenegraph.Node
All Implemented Interfaces:
org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, org.openmali.spatial.SpatialNode
Direct Known Subclasses:
GroupNode, Leaf

public abstract class Node
extends SceneGraphObject
implements org.openmali.spatial.SpatialNode

Node is the base class for all node objects in a scene graph.


Field Summary
protected  org.openmali.spatial.bounds.Bounds bounds
          The bounds of this object.
protected  boolean boundsAutoCompute
           
protected  boolean boundsDirty
           
protected static boolean globalIgnoreBounds
           
protected  BoundsTypeHint instanceBoundsTypeHint
           
protected  TransformGroup transformGroup
          Transform group for this node.
protected  org.openmali.spatial.bounds.Bounds untransformedBounds
           
 
Fields inherited from class org.xith3d.scenegraph.SceneGraphObject
XITH3D_USERDATAKEY_OLDUSERDATA
 
Constructor Summary
  Node()
          Constructs a new Node object.
protected Node(boolean initializeBounds)
          Constructs a new Node object.
 
Method Summary
 void absorbDetails(Node node)
          Turns the receiver into a shared copy of the node parameter.
 Node cloneNode(boolean forceDuplicate)
          Creates a new instance of the Node.
 void detach()
          Detaches the Node from its parent and sets the node to not live.
protected abstract  void dump(int indent)
           
 void duplicateNode(Node originalNode, boolean forceDuplicate)
          Copies all the node information from the originalNode into the current node.
 void freeOpenGLResources(Canvas3D canvas)
          This method frees OpenGL resources (names) for all Nodes in the traversal of this Node(-Group).
abstract  void freeOpenGLResources(CanvasPeer canvasPeer)
          This method frees OpenGL resources (names) for all Nodes in the traversal of this Node(-Group).
 org.openmali.spatial.bounds.Bounds getBounds()
           
 boolean getBoundsAutoCompute()
           
 org.openmali.spatial.bounds.BoundsType getBoundsType()
           
static BoundsTypeHint getBoundsTypeHint()
           
static boolean getDefaultPickable()
          Is a Node object pickable when created?
protected  java.lang.String getIndentString(int indent)
           
 InheritedNodeAttributes getInheritedNodeAttributes()
           
 ScenegraphModificationsListener getModListener()
           
 Node getOrderedChild()
           
 OrderedState getOrderedState()
           
 GroupNode getParent()
           
 BranchGroup getRoot()
           
 java.lang.Object getShadowAttachment()
           
 boolean getShowBounds()
           
 TransformGroup getTransformGroup()
          Returns the TransformGroup, which defines the Transform of this Node.
 java.lang.Object getTreeCell()
           
 org.openmali.spatial.bounds.Bounds getWorldBounds()
           
 Transform3D getWorldTransform()
           
 void getWorldTransform(Transform3D transform3D)
           
 boolean isBillboard()
           
 boolean isIgnoreBounds()
           
 boolean isOccluder()
           
 boolean isPickable()
           
 boolean isRenderable()
           
 boolean isUpdatableNode()
           
protected  void mergeInheritedClipper(Clipper clipper, ClipperInfo clipperInfo)
           
protected  void mergeInheritedNodes(InheritedNodeAttributes in)
           
protected  void mergeInheritedScissorRect(ScissorRect scissorRect)
           
static boolean popGlobalIgnoreBounds()
           
 void printBounds(boolean childrenToo)
           
static void pushGlobalIgnoreBounds(boolean val)
           
 void setBounds(org.openmali.spatial.bounds.Bounds bounds)
          Sets the bounds for this object.
 void setBoundsAutoCompute(boolean autocompute)
           
protected  void setBoundsDirty()
           
protected  void setBoundsDirtyUpward()
           
static void setBoundsTypeHint(BoundsTypeHint bth)
           
static void setDefaultPickable(boolean value)
          Each Node object will be pickable by default following this static flag.
static void setGlobalIgnoreBounds(boolean val)
           
 void setIgnoreBounds(boolean ignoreBounds)
           
 void setIsOccluder(boolean isOccluder)
           
 void setModListener(ScenegraphModificationsListener modListener)
           
 void setOrderedChild(Node orderedChild)
           
protected  void setParent(GroupNode parent)
          Sets the parent for this Node object.
 void setPickable(boolean value)
          Sets whether this Node is attended by picking algorithms.
 void setPickableRecursive(boolean pickable)
          Sets whether this Node is attended by picking algorithms, and all its children.
static void setPickableRecursive(Node node, boolean pickable)
          Sets whether this Node is attended by picking algorithms, and all its children
 void setRenderable(boolean value)
          Sets whether this Node is excluded from rendering or not.
 void setShadowAttachment(java.lang.Object shadowAttachment)
           
 void setShowBounds(boolean show)
           
protected  void setTransformGroup(TransformGroup tg)
           
 void setTreeCell(java.lang.Object treeCell)
           
 Node sharedCopy()
          Creates a shared copy of this Node.
 Node sharedCopy(CopyListener listener)
          Creates a shared copy of this Node.
abstract  boolean traverse(DetailedTraversalCallback callback)
          Traverses the scenegraph from this node on.
 boolean traverse(TraversalCallback callback)
          Traverses the scenegraph from this node on.
protected  void unmergeInheritedFog(Fog fog)
           
protected  void unmergeInheritedLight(Light light)
           
protected  void unmergeInheritedNodes(InheritedNodeAttributes in)
           
 void updateBounds(boolean onlyDirty)
          Update bounds sets the bounds and virutal world bounds of all nodes recursively.
protected  void updateBoundsCheap(boolean onlyDirty, boolean childrenToo, boolean parentToo, boolean onlyWorld)
          Update bounds sets the bounds and virutal world bounds of all nodes recursively.
protected  void updateOrderedChild()
          Steps down from the nodes.
 void updateTransformGroup()
          Never use this method on your own!
 void updateWorldTransform()
          If this is a TansformGroup, then it will multiply the transform against the parent transform and store it into the world-transform matrix.
 
Methods inherited from class org.xith3d.scenegraph.SceneGraphObject
getName, getUserData, getUserData, getUserDataMap, isLive, setLive, setName, setUserData, setUserData, setUserDataRecursive, setUserDataRecursive, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

boundsAutoCompute

protected transient boolean boundsAutoCompute

transformGroup

protected TransformGroup transformGroup
Transform group for this node. The universe maintains this transform when the graph is parsed. We are putting a pointer here so that we do not need to replicate a transform3d all over the place


bounds

protected org.openmali.spatial.bounds.Bounds bounds
The bounds of this object.


untransformedBounds

protected org.openmali.spatial.bounds.Bounds untransformedBounds

instanceBoundsTypeHint

protected BoundsTypeHint instanceBoundsTypeHint

boundsDirty

protected boolean boundsDirty

globalIgnoreBounds

protected static boolean globalIgnoreBounds
Constructor Detail

Node

protected Node(boolean initializeBounds)
Constructs a new Node object.


Node

public Node()
Constructs a new Node object.

Method Detail

setTreeCell

public void setTreeCell(java.lang.Object treeCell)
Specified by:
setTreeCell in interface org.openmali.spatial.SpatialNode

getTreeCell

public java.lang.Object getTreeCell()
Specified by:
getTreeCell in interface org.openmali.spatial.SpatialNode

setBoundsTypeHint

public static void setBoundsTypeHint(BoundsTypeHint bth)

getBoundsTypeHint

public static BoundsTypeHint getBoundsTypeHint()

isBillboard

public final boolean isBillboard()

isUpdatableNode

public final boolean isUpdatableNode()

getDefaultPickable

public static boolean getDefaultPickable()
Is a Node object pickable when created?


setPickable

public void setPickable(boolean value)
Sets whether this Node is attended by picking algorithms.

Parameters:
value - if false, this Node is ignored by picking algorithms

isPickable

public final boolean isPickable()
Returns:
whether this Node is attended by picking algorithms

setPickableRecursive

public static final void setPickableRecursive(Node node,
                                              boolean pickable)
Sets whether this Node is attended by picking algorithms, and all its children

Parameters:
pickable - if false, this Node and all its children, recursively, are ignored by picking algorithms

setPickableRecursive

public final void setPickableRecursive(boolean pickable)
Sets whether this Node is attended by picking algorithms, and all its children.

Parameters:
pickable - if false, this Node and all its children, recursively are ignored by picking algorithms

setRenderable

public final void setRenderable(boolean value)
Sets whether this Node is excluded from rendering or not.

Parameters:
value - if false, this Node is excluded from rendering

isRenderable

public final boolean isRenderable()
Returns:
false, if this Node is excluded from rendering

getInheritedNodeAttributes

public final InheritedNodeAttributes getInheritedNodeAttributes()

setModListener

public void setModListener(ScenegraphModificationsListener modListener)

getModListener

public final ScenegraphModificationsListener getModListener()

setIgnoreBounds

public void setIgnoreBounds(boolean ignoreBounds)

isIgnoreBounds

public final boolean isIgnoreBounds()

setGlobalIgnoreBounds

public static void setGlobalIgnoreBounds(boolean val)

pushGlobalIgnoreBounds

public static void pushGlobalIgnoreBounds(boolean val)

popGlobalIgnoreBounds

public static boolean popGlobalIgnoreBounds()

mergeInheritedNodes

protected void mergeInheritedNodes(InheritedNodeAttributes in)

unmergeInheritedNodes

protected void unmergeInheritedNodes(InheritedNodeAttributes in)

unmergeInheritedLight

protected void unmergeInheritedLight(Light light)

unmergeInheritedFog

protected void unmergeInheritedFog(Fog fog)

mergeInheritedScissorRect

protected void mergeInheritedScissorRect(ScissorRect scissorRect)

mergeInheritedClipper

protected void mergeInheritedClipper(Clipper clipper,
                                     ClipperInfo clipperInfo)
Parameters:
clipper -
clipperInfo -

setBoundsAutoCompute

public final void setBoundsAutoCompute(boolean autocompute)

getBoundsAutoCompute

public final boolean getBoundsAutoCompute()

getWorldTransform

public final void getWorldTransform(Transform3D transform3D)

getWorldTransform

public Transform3D getWorldTransform()

getShowBounds

public final boolean getShowBounds()

setShowBounds

public void setShowBounds(boolean show)

setBounds

public void setBounds(org.openmali.spatial.bounds.Bounds bounds)
Sets the bounds for this object.


getBoundsType

public final org.openmali.spatial.bounds.BoundsType getBoundsType()

getWorldBounds

public final org.openmali.spatial.bounds.Bounds getWorldBounds()
Specified by:
getWorldBounds in interface org.openmali.spatial.SpatialNode

getBounds

public final org.openmali.spatial.bounds.Bounds getBounds()
Returns:
the bounds for this object.

getParent

public final GroupNode getParent()
Returns:
the parent of this Node or returns null if there is no parent.

getRoot

public final BranchGroup getRoot()
Returns:
the root BranchGroup of this Node.

getOrderedChild

public final Node getOrderedChild()

setOrderedChild

public final void setOrderedChild(Node orderedChild)

getOrderedState

public final OrderedState getOrderedState()

setTransformGroup

protected final void setTransformGroup(TransformGroup tg)

getTransformGroup

public final TransformGroup getTransformGroup()
Returns the TransformGroup, which defines the Transform of this Node. So it does not return itself, if it is a TransformGroup.

Returns:
the TransformGroup which defines this nodes Transform, null if no TransformGroup is its parent

setBoundsDirty

protected void setBoundsDirty()

setBoundsDirtyUpward

protected void setBoundsDirtyUpward()

detach

public final void detach()
Detaches the Node from its parent and sets the node to not live.


setParent

protected void setParent(GroupNode parent)
Sets the parent for this Node object. If the parent is live then this node and any children it has are made live. If the parent is null then this node and any children it has are made not live.

Throws:
IllegalSceneGraphOperation - if the Node already has a parent

printBounds

public void printBounds(boolean childrenToo)

updateBoundsCheap

protected void updateBoundsCheap(boolean onlyDirty,
                                 boolean childrenToo,
                                 boolean parentToo,
                                 boolean onlyWorld)
Update bounds sets the bounds and virutal world bounds of all nodes recursively.

Parameters:
onlyDirty - Only update those nodes which have been marked as dirty.
childrenToo - if false, the children bounds are not updated
parentToo - if false, the parent Node will not be updated
onlyWorld - if true, only the vworld bounds are updated

updateBounds

public void updateBounds(boolean onlyDirty)
Update bounds sets the bounds and virutal world bounds of all nodes recursively.

Parameters:
onlyDirty - Only update those nodes which have been marked as dirty.

setIsOccluder

public final void setIsOccluder(boolean isOccluder)

isOccluder

public final boolean isOccluder()

setShadowAttachment

public final void setShadowAttachment(java.lang.Object shadowAttachment)

getShadowAttachment

public final java.lang.Object getShadowAttachment()

updateWorldTransform

public void updateWorldTransform()
If this is a TansformGroup, then it will multiply the transform against the parent transform and store it into the world-transform matrix. Never use this method on your own! It's just for internal use.


updateTransformGroup

public final void updateTransformGroup()
Never use this method on your own! It's just for internal use.


updateOrderedChild

protected final void updateOrderedChild()
Steps down from the nodes.


cloneNode

public Node cloneNode(boolean forceDuplicate)
Creates a new instance of the Node.


duplicateNode

public void duplicateNode(Node originalNode,
                          boolean forceDuplicate)
Copies all the node information from the originalNode into the current node. This method is called from the cloneNode method which is called from the cloneTree method. This method is empty - it doesn't do anything

Parameters:
originalNode -
forceDuplicate -

sharedCopy

public Node sharedCopy(CopyListener listener)
Creates a shared copy of this Node. A shared copy is one where the geometry and appearance is shared, but everything else is copied. This is a replacement for shared groups because of performance considerations. If you are loading the same model many times then this can save on memory and load times. The only allowable within the subtree are groups and shapes. This also copies a shapes bounds and turns autocomute off so that it is fast to insert the model into the scene.

Parameters:
listener -
Returns:
a shared copy of this Node
See Also:
absorbDetails(Node)

sharedCopy

public Node sharedCopy()
Creates a shared copy of this Node. A shared copy is one where the geometry and appearance is shared, but everything else is copied. This is a replacement for shared groups because of performance considerations. If you are loading the same model many times then this can save on memory and load times. The only allowable within the subtree are groups and shapes. This also copies a shapes bounds and turns autocomute off so that it is fast to insert the model into the scene.

Returns:
a shared copy of this Node
See Also:
absorbDetails(Node)

absorbDetails

public void absorbDetails(Node node)
Turns the receiver into a shared copy of the node parameter. This is precisely the inverse operation of sharedCopy; i.e., shared copy creates a new node, but absorbDetails turns the current node into a copy exactly equivalent to what would be returned, if you created a new copy via the sharedCopy() method.

Parameters:
node - the node to copy.
See Also:
sharedCopy()

setDefaultPickable

public static void setDefaultPickable(boolean value)
Each Node object will be pickable by default following this static flag.

Parameters:
value - pickable by default?

freeOpenGLResources

public abstract void freeOpenGLResources(CanvasPeer canvasPeer)
This method frees OpenGL resources (names) for all Nodes in the traversal of this Node(-Group).

Parameters:
canvasPeer -

freeOpenGLResources

public final void freeOpenGLResources(Canvas3D canvas)
This method frees OpenGL resources (names) for all Nodes in the traversal of this Node(-Group).

Parameters:
canvas -

getIndentString

protected final java.lang.String getIndentString(int indent)

dump

protected abstract void dump(int indent)

traverse

public boolean traverse(TraversalCallback callback)
Traverses the scenegraph from this node on. If this Node is a Group it will recusively run through each child.

Parameters:
callback - the listener is notified of any traversed Node on the way
Returns:
if false, the whole traversal will stop

traverse

public abstract boolean traverse(DetailedTraversalCallback callback)
Traverses the scenegraph from this node on. If this Node is a Group it will recusively run through each child.

Parameters:
callback - the listener is notified of any traversed Node on the way
Returns:
if false, the whole traversal will stop