j3d.org Aviatrix3D

org.j3d.aviatrix3d
Class SharedNode

java.lang.Object
  extended byorg.j3d.aviatrix3d.SceneGraphObject
      extended byorg.j3d.aviatrix3d.Node
          extended byorg.j3d.aviatrix3d.SharedNode
All Implemented Interfaces:
PickableObject

public class SharedNode
extends Node
implements PickableObject

A node that can have multiple parents, thus allowing a graph structure to the scene graph.

Normal nodes cannot have more than one parent, so this class provides the ability to have more than one. In doing so, it overrides the normal methods provided by Node to provide the shared functionality. It provides a compliment to the SharedGroup for parts of the scene graph where you want to share a common piece, but really don't need the grouping functionality.

Using this node in preference to SharedGroup has several performance benefits. For example, when performing picking, the picking implementation can just ignore this node altogether as it knows the bounds are identical to it's child.

Version:
$Revision: 1.5 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class org.j3d.aviatrix3d.Node
bounds, implicitBounds, INVALID_BOUNDS, parent
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, updateHandler, WRITE_TIMING_MSG
 
Fields inherited from interface org.j3d.aviatrix3d.PickableObject
COLLIDABLE_OBJECT, GENERAL_OBJECT, PROXIMITY_OBJECT, VISIBLE_OBJECT
 
Constructor Summary
SharedNode()
          The default constructor
 
Method Summary
protected  void checkForCyclicParent(SceneGraphObject child)
          Check to see if this node is the same reference as the passed node.
 Node getChild()
          Get the currently set child of this node.
 Node getParent()
          Overridden to always return null.
 void getParents(Node[] parents)
          Get the listing of the number of parents that this node currently has.
 int getPickMask()
          Get the current pickable state mask of this object.
protected  void markBoundsDirty()
          Mark this node as having dirty bounds due to one of it's children having their bounds changed.
 int numParents()
          Request the number of parents this node currently contains
 void pickBatch(PickRequest[] reqs, int numRequests)
          Check for all intersections against this geometry and it's children to see if there is an intersection with the given set of requests.
 void pickSingle(PickRequest req)
          Check for all intersections against this geometry and it's children to see if there is an intersection with the given set of requests.
 void postRender(net.java.games.jogl.GL gl, net.java.games.jogl.GLU glu)
           
protected  void recomputeBounds()
          Internal method to recalculate the implicit bounds of this Node.
protected  void removeParent(Node p)
          Remove a parent from this shared group.
 void render(net.java.games.jogl.GL gl, net.java.games.jogl.GLU glu)
          Set up the rendering state now.
 void setChild(Node child)
          Set the child to be the new value.
protected  void setLive(boolean state)
          Notification that this object is live now.
protected  void setParent(Node p)
          Specify this nodes parent, overridden to provide behaviour that appends the node to the list rather than replacing it.
 void setPickMask(int state)
          Set the node as being pickable currently using the given bit mask.
protected  void setUpdateHandler(NodeUpdateHandler handler)
          Set the scenegraph update handler for this node.
protected  void updateBounds()
          Update this node's bounds and then call the parent to update it's bounds.
 
Methods inherited from class org.j3d.aviatrix3d.Node
boundsChanged, getBounds, setBounds
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, dataChanged, getUserData, isLive, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SharedNode

public SharedNode()
The default constructor

Method Detail

markBoundsDirty

protected void markBoundsDirty()
Mark this node as having dirty bounds due to one of it's children having their bounds changed.

Overrides:
markBoundsDirty in class Node

recomputeBounds

protected void recomputeBounds()
Internal method to recalculate the implicit bounds of this Node. By default the bounds are a point sphere, so derived classes should override this method with something better.

Overrides:
recomputeBounds in class Node

updateBounds

protected void updateBounds()
Update this node's bounds and then call the parent to update it'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.

Overrides:
updateBounds in class Node

render

public void render(net.java.games.jogl.GL gl,
                   net.java.games.jogl.GLU glu)
Set up the rendering state now.

Overrides:
render in class Node
Parameters:
gl - The gl context to draw with
glu - The utility context to draw with

postRender

public void postRender(net.java.games.jogl.GL gl,
                       net.java.games.jogl.GLU glu)
Overrides:
postRender in class Node

setParent

protected void setParent(Node p)
                  throws AlreadyParentedException,
                         InvalidNodeTypeException
Specify this nodes parent, overridden to provide behaviour that appends the node to the list rather than replacing it. The parent must be a group node in this case.

Overrides:
setParent in class Node
Parameters:
p - The new parent instance to add to the list
Throws:
AlreadyParentedException - There is a valid parent already set
InvalidNodeTypeException - Not a group node

removeParent

protected void removeParent(Node p)
Remove a parent from this shared group. Since setParent() cannot be used to remove a parent from the graph, you'll need to use this method to remove the parent.

Overrides:
removeParent in class Node
Parameters:
p - The new parent instance to remove from the list

getParent

public Node getParent()
Overridden to always return null.

Overrides:
getParent in class Node
Returns:
null

numParents

public int numParents()
Request the number of parents this node currently contains

Returns:
a positive number

getParents

public void getParents(Node[] parents)
Get the listing of the number of parents that this node currently has. The provided array must be at least big enough to copy all the values into it.

Parameters:
parents - An array to copy the parent listing into

setLive

protected void setLive(boolean state)
Notification that this object is live now.

Overrides:
setLive in class Node
Parameters:
state - true if this should be marked as live now

setUpdateHandler

protected void setUpdateHandler(NodeUpdateHandler handler)
Set the scenegraph update handler for this node. It will notify all its children of the value. A null value will clear the current handler.

Overrides:
setUpdateHandler in class SceneGraphObject
Parameters:
handler - The instance to use as a handler

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 Node
Parameters:
child - The reference to check against this class
Throws:
CyclicSceneGraphStructureException - Equal parent and child

setPickMask

public void setPickMask(int state)
Set the node as being pickable currently using the given bit mask. A mask of 0 will completely disable picking.

Specified by:
setPickMask in interface PickableObject
Parameters:
state - A bit mask of available options to pick for

getPickMask

public int getPickMask()
Get the current pickable state mask of this object. A value of zero means it is completely unpickable.

Specified by:
getPickMask in interface PickableObject
Returns:
A bit mask of available options to pick for

pickBatch

public void pickBatch(PickRequest[] reqs,
                      int numRequests)
               throws NotPickableException,
                      InvalidPickTimingException
Check for all intersections against this geometry and it's children to see if there is an intersection with the given set of requests.

Specified by:
pickBatch in interface PickableObject
Parameters:
reqs - The list of picks to be made, starting at this object
numRequests - The number of valid pick requests to process
Throws:
NotPickableException - This object has been marked as non pickable, but you decided to try to call the method anyway
InvalidPickTimingException - An attempt was made to pick outside of the ApplicationUpdateObserver callback method

pickSingle

public void pickSingle(PickRequest req)
                throws NotPickableException,
                       InvalidPickTimingException
Check for all intersections against this geometry and it's children to see if there is an intersection with the given set of requests.

Specified by:
pickSingle in interface PickableObject
Parameters:
req - The details of the pick to be made
Throws:
NotPickableException - This object has been marked as non pickable, but you decided to try to call the method anyway
InvalidPickTimingException - An attempt was made to pick outside of the ApplicationUpdateObserver callback method

setChild

public void setChild(Node child)
Set the child to be the new value. If the existing child is set, it is replaced by this current child. Setting a value of null will remove the old one.

Parameters:
child - The new instance to set or null

getChild

public Node getChild()
Get the currently set child of this node. If there is none set, the return null.

Returns:
The current child or null

j3d.org Aviatrix3D

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