Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class Node

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.Node
Direct Known Subclasses:
BaseNode, Group, Leaf, Node2D, SharedNode

public abstract class Node
extends SceneGraphObject

A Node class is the base class for all renderable nodes in the SceneGraph.

Unless otherwise overridden, all nodes are only single parented and have a bounds object. By default the bounds are void (ie not even a point in space) and do not contribute this node to the scene graph's bounds.

Internationalisation Resource Names

Version:
$Revision: 1.34 $
Author:
Alan Hudson

Field Summary
protected  BoundingVolume bounds
          Bounding volume set by the user
protected  boolean implicitBounds
          Was the bounds automatically calculated?
protected static BoundingVoid INVALID_BOUNDS
          Sharable version of the null bounds object for those that need it
protected  Node parent
          The parent of this node
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler
 
Constructor Summary
protected Node()
          Construct a new instance of this node, with implicit bounds calculation.
 
Method Summary
 void boundsChanged(NodeUpdateListener l)
          Notify the node that you have updates to the node that might alter its bounds.
protected  void checkForCyclicParent(SceneGraphObject child)
          Check to see if this node is the same reference as the passed node.
 BoundingVolume getBounds()
          Get the currently set bounds for this object.
 Node getParent()
          Get the current parent of this node.
protected  void markBoundsDirty()
          Mark this node as having dirty bounds due to one of it's children having their bounds changed.
protected  void recomputeBounds()
          Internal method to recalculate the implicit bounds of this Node.
protected  void removeParent(Node p)
          Remove a parent from this node.
 void requestBoundsUpdate()
          Request a recomputation of the bounds of this object.
 void setBounds(BoundingVolume b)
          Set the bounds to the given explicit value.
protected  void setParent(Node p)
          Specify this nodes parent.
protected  void updateBounds()
          Update this node's bounds.
protected  void updateParentBounds()
          Update this node's parent bounds now.
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setLive, setUpdateHandler, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INVALID_BOUNDS

protected static final BoundingVoid INVALID_BOUNDS
Sharable version of the null bounds object for those that need it


parent

protected Node parent
The parent of this node


bounds

protected BoundingVolume bounds
Bounding volume set by the user


implicitBounds

protected boolean implicitBounds
Was the bounds automatically calculated?

Constructor Detail

Node

protected Node()
Construct a new instance of this node, with implicit bounds calculation.

Method Detail

checkForCyclicParent

protected void checkForCyclicParent(SceneGraphObject child)
                             throws CyclicSceneGraphStructureException
Check to see if this node is the same reference as the passed node. This is the upwards check to ensure that there is no cyclic scene graph structures at the point where someone adds a node to the scenegraph. When the reference and this are the same, an exception is generated. If not, then the code will find the parent of this class and invoke this same method on the parent.

Overrides:
checkForCyclicParent in class SceneGraphObject
Parameters:
child - The reference to check against this class
Throws:
CyclicSceneGraphStructureException - Equal parent and child

setParent

protected void setParent(Node p)
                  throws AlreadyParentedException
Specify this nodes parent. Should not be called directly by external callers. Setting a value of null will clear the existing parent. Bit broken right now as it doesn't handle multiple-parents like needed in a proper scene graph. If the node has a parent already, an exception is generated. Note that this method is ignored if the derived type is SharedGroup.

Parameters:
p - The new parent instance to call or null
Throws:
AlreadyParentedException - There is a valid parent already set

removeParent

protected void removeParent(Node p)
Remove a parent from this node. An alternate way to remove a parent from the list.

Parameters:
p - The new parent instance to remove from the list

getParent

public Node getParent()
Get the current parent of this node. If no parent is set, return null. Also, note that the behaviour of this method is to always return null if the derived type of this class is SharedGroup.

Returns:
The current parent instance of the node

boundsChanged

public void boundsChanged(NodeUpdateListener l)
                   throws InvalidListenerSetTimingException
Notify the node that you have updates to the node that might alter its bounds.

Parameters:
l - The change requestor
Throws:
InvalidListenerSetTimingException - If called when the node is not live or if called during one of the bounds/data changed callbacks

setBounds

public void setBounds(BoundingVolume b)
Set the bounds to the given explicit value. When set, auto computation of the bounds of this node is turned off. A value of null can be used to clear the current explicit bounds and return to auto computation.

Parameters:
b - The new bounds to use or null to clear
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener bounds changed callback method

getBounds

public BoundingVolume getBounds()
Get the currently set bounds for this object. If no explicit bounds have been set, then an implicit set of bounds is returned based on the current scene graph state.

Returns:
The current bounds of this object

updateBounds

protected void updateBounds()
Update this node's bounds. Used to propogate bounds changes from the leaves of the tree to the root. A node implementation may decide when and where to tell the parent(s)s that updates are ready, though typically it is done in an overridden version of this method.


updateParentBounds

protected void updateParentBounds()
Update this node's parent bounds now. Used to propogate bounds changes from the current level to the parent when needed. Typically used by classes that extend the core nodes that do not automatically have access to the updateBounds() method of any contained geometry, or of their own parent.


recomputeBounds

protected void recomputeBounds()
Internal method to recalculate the implicit bounds of this Node. By default the bounds are a BoundingVoid, so derived classes should override this method with something better. It does not mark this node as being dirty with it's parent.


requestBoundsUpdate

public void requestBoundsUpdate()
Request a recomputation of the bounds of this object. If this object is not currently live, you can request a recompute of the bounds to get the most current values. If this node is currently live, then the request is ignored.

This will recurse down the children asking all of them to recompute the bounds. If a child is found to be during this process, that branch will not update, and thus the value used will be the last updated (ie from the previous frame it was processed).

The default implementation in this class does nothing. A derived class should override and implement as needed.


markBoundsDirty

protected void markBoundsDirty()
Mark this node as having dirty bounds due to one of it's children having their bounds changed. Default implementation will just call the parent node and inform it that its bounds are dirty too.


Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org