javax.media.j3d
Class Morph

java.lang.Object
  |
  +--javax.media.j3d.SceneGraphObject
        |
        +--javax.media.j3d.Node
              |
              +--javax.media.j3d.Leaf
                    |
                    +--javax.media.j3d.Morph

public class Morph
extends Leaf

The Morph leaf node permits an application to morph between multiple GeometryArrays. The Morph node contains a single Appearance node, an array of GeometryArray objects, and an array of corresponding weights. The Morph node combines these GeometryArrays into an aggregate shape based on each GeometryArray's corresponding weight. Typically, Behavior nodes will modify the weights to achieve various morphing effects.


Field Summary
static int ALLOW_APPEARANCE_OVERRIDE_READ
          Specifies that this node allows reading its appearance override enable flag.
static int ALLOW_APPEARANCE_OVERRIDE_WRITE
          Specifies that this node allows writing its appearance override enable flag.
static int ALLOW_APPEARANCE_READ
          Specifies that the node allows read access to its appearance information.
static int ALLOW_APPEARANCE_WRITE
          Specifies that the node allows write access to its appearance information.
static int ALLOW_COLLISION_BOUNDS_READ
          Specifies that the node allows reading its collision Bounds.
static int ALLOW_COLLISION_BOUNDS_WRITE
          Specifies the node allows writing its collision Bounds.
static int ALLOW_GEOMETRY_ARRAY_READ
          Specifies that the node allows read access to its geometry information.
static int ALLOW_GEOMETRY_ARRAY_WRITE
          Specifies that the node allows write access to its geometry information.
static int ALLOW_WEIGHTS_READ
          Specifies that the node allows read access to its morph weight vector.
static int ALLOW_WEIGHTS_WRITE
          Specifies that the node allows write access to its morph weight vector.
 
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_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
 
Constructor Summary
Morph(GeometryArray[] geometryArrays)
          Constructs and initializes a Morph node with the specified array of GeometryArray objects.
Morph(GeometryArray[] geometryArrays, Appearance appearance)
          Constructs and initializes a Morph node with the specified array of GeometryArray objects and the specified appearance object.
 
Method Summary
 Node cloneNode(boolean forceDuplicate)
          Creates a new instance of the node.
 void duplicateNode(Node originalNode, boolean forceDuplicate)
          Copies all node information from originalNode into the current node.
 Appearance getAppearance()
          Retrieves the appearance component of this morph node.
 boolean getAppearanceOverrideEnable()
          Retrieves the appearanceOverrideEnable flag for this node.
 Bounds getCollisionBounds()
          Returns the collision bounding object of this node.
 GeometryArray getGeometryArray(int index)
          Retrieves the geometryArray component of this Morph node.
 double[] getWeights()
          Retrieves the Morph node's morph weight vector.
 boolean intersect(SceneGraphPath path, PickRay pickRay, double[] dist)
          Check if the geometry component of this morph node under path intersects with the pickShape.
 boolean intersect(SceneGraphPath path, PickShape pickShape)
          Check if the geometry component of this morph node under path intersects with the pickShape.
 void setAppearance(Appearance appearance)
          Sets the appearance component of this Morph node.
 void setAppearanceOverrideEnable(boolean flag)
          Sets a flag that indicates whether this node's appearance can be overridden.
 void setCollisionBounds(Bounds bounds)
          Sets the collision bounds of a node.
 void setGeometryArrays(GeometryArray[] geometryArrays)
          Sets the geometryArrays component of the Morph node.
 void setWeights(double[] weights)
          Sets this Morph node's morph weight vector.
 
Methods inherited from class javax.media.j3d.Node
cloneTree, cloneTree, cloneTree, 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, updateNodeReferences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALLOW_GEOMETRY_ARRAY_READ

public static final int ALLOW_GEOMETRY_ARRAY_READ
Specifies that the node allows read access to its geometry information.

ALLOW_GEOMETRY_ARRAY_WRITE

public static final int ALLOW_GEOMETRY_ARRAY_WRITE
Specifies that the node allows write access to its geometry information.

ALLOW_APPEARANCE_READ

public static final int ALLOW_APPEARANCE_READ
Specifies that the node allows read access to its appearance information.

ALLOW_APPEARANCE_WRITE

public static final int ALLOW_APPEARANCE_WRITE
Specifies that the node allows write access to its appearance information.

ALLOW_WEIGHTS_READ

public static final int ALLOW_WEIGHTS_READ
Specifies that the node allows read access to its morph weight vector.

ALLOW_WEIGHTS_WRITE

public static final int ALLOW_WEIGHTS_WRITE
Specifies that the node allows write access to its morph weight vector.

ALLOW_COLLISION_BOUNDS_READ

public static final int ALLOW_COLLISION_BOUNDS_READ
Specifies that the node allows reading its collision Bounds.

ALLOW_COLLISION_BOUNDS_WRITE

public static final int ALLOW_COLLISION_BOUNDS_WRITE
Specifies the node allows writing its collision Bounds.

ALLOW_APPEARANCE_OVERRIDE_READ

public static final int ALLOW_APPEARANCE_OVERRIDE_READ
Specifies that this node allows reading its appearance override enable flag.
Since:
Java 3D 1.2

ALLOW_APPEARANCE_OVERRIDE_WRITE

public static final int ALLOW_APPEARANCE_OVERRIDE_WRITE
Specifies that this node allows writing its appearance override enable flag.
Since:
Java 3D 1.2
Constructor Detail

Morph

public Morph(GeometryArray[] geometryArrays)
Constructs and initializes a Morph node with the specified array of GeometryArray objects. Default values are used for all other parameters as follows:

A null appearance object specifies that default values are used for all appearance attributes.

Parameters:
geometryArrays - the geometry components of the morph
Throws:
java.lang.IllegalArgumentException - if vertexFormat of all GeometryArrays is NOT same or vertexCount of all GeometryArrays is NOT same or all GeometryArrays are NOT of same type(tstrip, lines etc) or texCoordSetCount of all GeometryArrays is NOT same..

Morph

public Morph(GeometryArray[] geometryArrays,
             Appearance appearance)
Constructs and initializes a Morph node with the specified array of GeometryArray objects and the specified appearance object.
Parameters:
geometryArrays - the geometry components of the Morph node
appearance - the appearance component of the Morph node
Throws:
java.lang.IllegalArgumentException - if vertexFormat of all GeometryArrays is NOT same or vertexCount of all GeometryArrays is NOT same or all GeometryArrays are NOT of same type(tstrip, lines etc) or texCoordSetCount of all GeometryArrays is NOT same.
Method Detail

setCollisionBounds

public void setCollisionBounds(Bounds bounds)
Sets the collision bounds of a node.
Parameters:
bounds - the collision bounding object for a node
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph

getCollisionBounds

public Bounds getCollisionBounds()
Returns the collision bounding object of this node.
Returns:
the node's collision bounding object
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph

setGeometryArrays

public void setGeometryArrays(GeometryArray[] geometryArrays)
Sets the geometryArrays component of the Morph node.
Parameters:
geometryArrays - the new geometryArrays component for the Morph node
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalArgumentException - if vertexFormat of all GeometryArrays is NOT same or vertexCount of all GeometryArrays is NOT same or all GeometryArrays are NOT of same type(tstrip, lines etc).

getGeometryArray

public GeometryArray getGeometryArray(int index)
Retrieves the geometryArray component of this Morph node.
Parameters:
index - the index of GeometryArray to be returned
Returns:
the geometryArray component of this Morph node
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph

setAppearance

public void setAppearance(Appearance appearance)
Sets the appearance component of this Morph node. A null appearance component specifies that default values are used for all appearance attributes.
Parameters:
appearance - the new appearance component for this Morph node
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph

getAppearance

public Appearance getAppearance()
Retrieves the appearance component of this morph node.
Returns:
the appearance component of this morph node
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph

intersect

public boolean intersect(SceneGraphPath path,
                         PickShape pickShape)
Check if the geometry component of this morph node under path intersects with the pickShape.
Parameters:
pickShape - the PickShape object
Returns:
true if intersected else false.
Throws:
java.lang.IllegalArgumentException - if pickShape is a PickPoint. Java 3D doesn't have spatial information of the surface. Should use PickBounds with BoundingSphere and set radius to a epsilon tolerance.

intersect

public boolean intersect(SceneGraphPath path,
                         PickRay pickRay,
                         double[] dist)
Check if the geometry component of this morph node under path intersects with the pickShape.
Parameters:
path - the SceneGraphPath
pickRay - the PickRay
dist - the closest distance of the intersection
Returns:
true if intersected else false. If return is true, dist contains the closest distance of intersection.

setWeights

public void setWeights(double[] weights)
Sets this Morph node's morph weight vector. The Morph node "weights" the corresponding GeometryArray by the amount specified. The weights apply a morph weight vector component that creates the desired morphing effect. The length of the weights parameter must be equal to the length of the array with which this Morph node was created, otherwise an IllegalArgumentException is thown.
Parameters:
weights - the morph weight vector that the morph node will use in combining the node's geometryArrays. The morph node will "weight" the corresponding GeometryArray by the amount specified. N.B.: the sum of the weights should equal 1.0
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
java.lang.IllegalArgumentException - if sum of all 'weights' is NOT 1.0 or number of weights is NOT exqual to number of GeometryArrays.

getWeights

public double[] getWeights()
Retrieves the Morph node's morph weight vector.
Returns:
the morph weight vector component of this morph node
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph

setAppearanceOverrideEnable

public void setAppearanceOverrideEnable(boolean flag)
Sets a flag that indicates whether this node's appearance can be overridden. If the flag is true, this node's appearance may be overridden by an AlternateAppearance leaf node, regardless of the value of the ALLOW_APPEARANCE_WRITE capability bit. The default value is false.
Parameters:
flag - the apperance override enable flag
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
Since:
Java 3D 1.2
See Also:
AlternateAppearance

getAppearanceOverrideEnable

public boolean getAppearanceOverrideEnable()
Retrieves the appearanceOverrideEnable flag for this node.
Returns:
true if the appearance can be overridden; false otherwise.
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
Since:
Java 3D 1.2

cloneNode

public Node cloneNode(boolean forceDuplicate)
Creates a new instance of the node. This routine is called by cloneTree to duplicate the current node.
Overrides:
cloneNode in class Node
Parameters:
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), Node.duplicateNode(javax.media.j3d.Node, boolean), NodeComponent.setDuplicateOnCloneTree(boolean)

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.
NOTE: Applications should not call this method directly. It should only be called by the cloneNode method.

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.
Throws:
ClassCastException - if originalNode is not an instance of Morph
See Also:
Node.cloneTree(), Node.cloneNode(boolean), NodeComponent.setDuplicateOnCloneTree(boolean)