javax.media.j3d
Class Behavior

java.lang.Object
  |
  +--javax.media.j3d.SceneGraphObject
        |
        +--javax.media.j3d.Node
              |
              +--javax.media.j3d.Leaf
                    |
                    +--javax.media.j3d.Behavior
Direct Known Subclasses:
Billboard, Interpolator, LOD

public abstract class Behavior
extends Leaf

Behavior is an abstract class that contains the framework for all behavioral components in Java 3D.


Fields inherited from class javax.media.j3d.Node
ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_PICK, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
 
Constructor Summary
Behavior()
          Constructs a Behavior node with default parameters.
 
Method Summary
 void duplicateNode(Node originalNode, boolean forceDuplicate)
          Copies all node information from originalNode into the current node.
 boolean getEnable()
          Retrieves the state of the Behavior enable flag.
 BoundingLeaf getSchedulingBoundingLeaf()
          Retrieves the Behavior node's scheduling bounding leaf.
 Bounds getSchedulingBounds()
          Retrieves the Behavior node's scheduling bounds.
protected  View getView()
          Returns the primary view associated with this behavior.
abstract  void initialize()
          Initialize this behavior.
 void postId(int postId)
          Post the specified Id.
abstract  void processStimulus(java.util.Enumeration criteria)
          Process a stimulus meant for this behavior.
 void setEnable(boolean state)
          Enables or disables this Behavior.
 void setSchedulingBoundingLeaf(BoundingLeaf region)
          Set the Behavior's scheduling region to the specified bounding leaf.
 void setSchedulingBounds(Bounds region)
          Set the Behavior's scheduling region to the specified bounds.
 void updateNodeReferences(NodeReferenceTable referenceTable)
          Callback used to allow a node to check if any scene graph objects referenced by that node have been duplicated via a call to cloneTree.
protected  void wakeupOn(WakeupCondition criteria)
          Defines this behavior's wakeup criteria.
 
Methods inherited from class javax.media.j3d.Node
cloneNode, cloneTree, cloneTree, cloneTree, getBounds, getBoundsAutoCompute, getCollidable, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
 
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, duplicateSceneGraphObject, getCapability, getUserData, isCompiled, isLive, setCapability, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Behavior

public Behavior()
Constructs a Behavior node with default parameters. The default values are as follows:
Method Detail

initialize

public abstract void initialize()
Initialize this behavior. Classes that extend Behavior must provide their own initialize method.
NOTE: Applications should not call this method. It is called by the Java 3D behavior scheduler.

processStimulus

public abstract void processStimulus(java.util.Enumeration criteria)
Process a stimulus meant for this behavior. This method is invoked if the Behavior's wakeup criteria are satisfied and the ViewPlatform's activation region intersect with the Behavior's scheduling region. Classes that extend Behavior must provide their own processStimulus method.
NOTE: Applications should not call this method. It is called by the Java 3D behavior scheduler.
Parameters:
criteria - an enumeration of triggered wakeup criteria for this behavior

setSchedulingBounds

public final void setSchedulingBounds(Bounds region)
Set the Behavior's scheduling region to the specified bounds. This is used when the scheduling bounding leaf is set to null.
Parameters:
region - the bounds that contains the Behavior's new scheduling region.

getSchedulingBounds

public final Bounds getSchedulingBounds()
Retrieves the Behavior node's scheduling bounds.
Returns:
this Behavior's scheduling bounds information

setSchedulingBoundingLeaf

public final void setSchedulingBoundingLeaf(BoundingLeaf region)
Set the Behavior's scheduling region to the specified bounding leaf. When set to a value other than null, this overrides the scheduling bounds object.
Parameters:
region - the bounding leaf node used to specify the Behavior node's new scheduling region.

getSchedulingBoundingLeaf

public final BoundingLeaf getSchedulingBoundingLeaf()
Retrieves the Behavior node's scheduling bounding leaf.
Returns:
this Behavior's scheduling bounding leaf information

wakeupOn

protected void wakeupOn(WakeupCondition criteria)
Defines this behavior's wakeup criteria. This method may only be called from a Behavior object's initialize or processStimulus methods to (re)arm the next wakeup. It should be the last thing done by those methods.
Parameters:
criteria - the wakeup criteria for this behavior
Throws:
java.lang.IllegalStateException - if this method is called by a method other than initialize or processStimulus

postId

public void postId(int postId)
Post the specified Id. Behaviors use this method to cause sequential scheduling of other behavior object.
Parameters:
postId - the Id being posted

setEnable

public void setEnable(boolean state)
Enables or disables this Behavior. The default state is enabled.
Parameters:
state - true or false to enable or disable this Behavior

getEnable

public boolean getEnable()
Retrieves the state of the Behavior enable flag.
Returns:
the Behavior enable state

getView

protected View getView()
Returns the primary view associated with this behavior. This method is useful with certain types of behaviors (e.g., Billboard, LOD) that rely on per-View information and with behaviors in general in regards to scheduling (the distance from the view platform determines the active behaviors). The "primary" view is defined to be the first View attached to a live ViewPlatform, if there is more than one active View. So, for instance, Billboard behaviors would be oriented toward this primary view, in the case of multiple active views into the same scene graph.

duplicateNode

public void duplicateNode(Node originalNode,
                          boolean forceDuplicate)
Copies all node information from originalNode into the current node. This method is called from the cloneNode method which is, in turn, called by the cloneTree method.

For any NodeComponent objects contained by the object being duplicated, each NodeComponent object's duplicateOnCloneTree value is used to determine whether the NodeComponent should be duplicated in the new node or if just a reference to the current node should be placed in the new node. This flag can be overridden by setting the forceDuplicate parameter in the cloneTree method to true.

Overrides:
duplicateNode in class Node
Parameters:
originalNode - the original node to duplicate.
forceDuplicate - when set to true, causes the duplicateOnCloneTree flag to be ignored. When false, the value of each node's duplicateOnCloneTree variable determines whether NodeComponent data is duplicated or copied.
See Also:
Node.cloneTree(), Node.cloneNode(boolean), NodeComponent.setDuplicateOnCloneTree(boolean)

updateNodeReferences

public void updateNodeReferences(NodeReferenceTable referenceTable)
Callback used to allow a node to check if any scene graph objects referenced by that node have been duplicated via a call to cloneTree. This method is called by cloneTree after all nodes in the sub-graph have been duplicated. The cloned Leaf node's method will be called and the Leaf node can then look up any object references by using the getNewObjectReference method found in the NodeReferenceTable object. If a match is found, a reference to the corresponding object in the newly cloned sub-graph is returned. If no corresponding reference is found, either a DanglingReferenceException is thrown or a reference to the original object is returned depending on the value of the allowDanglingReferences parameter passed in the cloneTree call.
Overrides:
updateNodeReferences in class Leaf
Parameters:
referenceTable - a NodeReferenceTableObject that contains the getNewObjectReference method needed to search for new object instances.
See Also:
NodeReferenceTable, Node.cloneTree(), DanglingReferenceException