javax.media.j3d
Class Shape3D

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

public class Shape3D
extends Leaf

A shape leaf node consisting of geometery and appearance properties.


Field Summary
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_READ
          Specifies that the node allows read access to its geometry information.
static int ALLOW_GEOMETRY_WRITE
          Specifies that the node allows write access to its geometry information.
 
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
Shape3D()
          Constructs a Shape3D node with default parameters.
Shape3D(Geometry geometry)
          Constructs and initializes a Shape3D node with the specified geometry and a null appearance component.
Shape3D(Geometry geometry, Appearance appearance)
          Constructs and initializes a Shape3D node with the specified geometry and appearance components.
 
Method Summary
 Node cloneNode(boolean forceDuplicate)
          Used to create 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 shape node.
 Bounds getCollisionBounds()
          Returns the collision bounding object of this node.
 Geometry getGeometry()
          Retrieves the geometry component of this Shape3D node.
 boolean intersect(SceneGraphPath path, PickRay pickRay, double[] dist)
          Check if the geometry component of this shape node under path intersects with the pickShape.
 boolean intersect(SceneGraphPath path, PickShape pickShape)
          Check if the geometry component of this shape node under path intersects with the pickShape.
 void setAppearance(Appearance appearance)
          Sets the appearance component of this Shape3D node.
 void setCollisionBounds(Bounds bounds)
          Sets the collision bounds of a node.
 void setGeometry(Geometry geometry)
          Sets the geometry component of the Shape3D node.
 
Methods inherited from class javax.media.j3d.Leaf
updateNodeReferences
 
Methods inherited from class javax.media.j3d.Node
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
 

Field Detail

ALLOW_GEOMETRY_READ

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

ALLOW_GEOMETRY_WRITE

public static final int ALLOW_GEOMETRY_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_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
Constructor Detail

Shape3D

public Shape3D()
Constructs a Shape3D node with default parameters. The default values are as follows: A null geometry component specifies that no geometry is drawn. A null appearance component specifies that default values are used for all appearance attributes.

Shape3D

public Shape3D(Geometry geometry)
Constructs and initializes a Shape3D node with the specified geometry and a null appearance component. A null appearance component specifies that default values are used for all appearance attributes.
Parameters:
geometry - the geometry component of the shape node

Shape3D

public Shape3D(Geometry geometry,
               Appearance appearance)
Constructs and initializes a Shape3D node with the specified geometry and appearance components.
Parameters:
geometry - the geometry component of the shape node
appearance - the appearance component of the shape node
Method Detail

setCollisionBounds

public final 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 final 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

setGeometry

public final void setGeometry(Geometry geometry)
Sets the geometry component of the Shape3D node.
Parameters:
geometry - the new geometry component for the shape node
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph

getGeometry

public final Geometry getGeometry()
Retrieves the geometry component of this Shape3D node.
Returns:
the geometry component of this shape node
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph

setAppearance

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

getAppearance

public final Appearance getAppearance()
Retrieves the appearance component of this shape node.
Returns:
the appearance component of this shape 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 shape node under path intersects with the pickShape.
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 shape node under path intersects with the pickShape.
Returns:
true if intersected else false. If return is true, dist contains the closest distance of intersection.

cloneNode

public Node cloneNode(boolean forceDuplicate)
Used to create a new instance of the node. This routine is called by cloneTree to duplicate the current node. cloneNode should be overridden by any user subclassed objects. All subclasses must have their cloneNode method consist of the following lines:

     public Node cloneNode(boolean forceDuplicate) {
         UserSubClass usc = new UserSubClass();
         usc.duplicateNode(this, forceDuplicate);
         return usc;
     }
 
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.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.

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)