Class Shape3D
- Direct Known Subclasses:
ColorCube
,OrientedShape3D
,SensorBeamEcho
,SensorGnomonEcho
,Text2D
The list of geometry objects must all be of the same equivalence class, that is, the same basic type of primitive. For subclasses of GeometryArray, all point objects are equivalent, all line objects are equivalent, and all polygon objects are equivalent. For other subclasses of Geometry, only objects of the same subclass are equivalent. The equivalence classes are as follows:
- GeometryArray (point): [Indexed]PointArray
- GeometryArray (line): [Indexed]{LineArray, LineStripArray}
- GeometryArray (polygon): [Indexed]{TriangleArray, TriangleStripArray, TriangleFanArray, QuadArray}
- CompressedGeometry
- Raster
- Text3D
When Shape3D is used with multiple geometry components, Java 3D may choose to use individual geometry bounds instead of the shape's bounds for region of influence operations, such as lighting. For example, the individual characters of a Text3D shape object may be rendered with a different light set.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Specifies that this node allows reading its appearance override enable flag.static final int
Specifies that this node allows writing its appearance override enable flag.static final int
Specifies that the node allows read access to its appearance information.static final int
Specifies that the node allows write access to its appearance information.static final int
Specifies that the node allows reading its collision Boundsstatic final int
Specifies the node allows writing its collision Boundsstatic final int
Specifies that the node allows read access to its geometry information.static final int
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_LOCALE_READ, ALLOW_PARENT_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
-
Constructor Summary
ConstructorsConstructorDescriptionShape3D()
Constructs a Shape3D node with default parameters.Constructs and initializes a Shape3D node with the specified geometry component 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
Modifier and TypeMethodDescriptionvoid
addGeometry
(Geometry geometry) Appends the specified geometry component to this Shape3D node's list of geometry components.cloneNode
(boolean forceDuplicate) Used to create a new instance of the node.void
duplicateNode
(Node originalNode, boolean forceDuplicate) Copies all node information fromoriginalNode
into the current node.Returns an enumeration of this Shape3D node's list of geometry components.Retrieves the appearance component of this shape node.boolean
Retrieves the appearanceOverrideEnable flag for this node.See parent class for the documentation on getBounds().Returns the collision bounding object of this node.Retrieves the geometry component at index 0 from this Shape3D node's list of geometry components.getGeometry
(int index) Retrieves the geometry component at the specified index from this Shape3D node's list of geometry components.int
indexOfGeometry
(Geometry geometry) Retrieves the index of the specified geometry component in this Shape3D node's list of geometry components.void
insertGeometry
(Geometry geometry, int index) Inserts the specified geometry component into this Shape3D node's list of geometry components at the specified index.boolean
intersect
(SceneGraphPath path, PickRay pickRay, double[] dist) Checks whether the geometry in this shape node intersects with the specified pickRay.boolean
intersect
(SceneGraphPath path, PickShape pickShape) Checks whether the geometry in this shape node intersects with the specified pickShape.boolean
intersect
(SceneGraphPath path, PickShape pickShape, double[] dist) Checks whether the geometry in this shape node intersects with the specified pickShape.int
Returns the number of geometry components in this Shape3D node's list of geometry components.void
Removes all geometry components from this Shape3D node.void
removeGeometry
(int index) Removes the geometry component at the specified index from this Shape3D node's list of geometry components.void
removeGeometry
(Geometry geometry) Removes the specified geometry component from this Shape3D node's list of geometry components.void
setAppearance
(Appearance appearance) Sets the appearance component of this Shape3D 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
setGeometry
(Geometry geometry) Replaces the geometry component at index 0 in this Shape3D node's list of geometry components with the specified geometry component.void
setGeometry
(Geometry geometry, int index) Replaces the geometry component at the specified index in this Shape3D node's list of geometry components with the specified geometry component.Methods inherited from class javax.media.j3d.Node
cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, getBoundsAutoCompute, getCollidable, getLocale, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences
-
Field Details
-
ALLOW_GEOMETRY_READ
public static final int ALLOW_GEOMETRY_READSpecifies that the node allows read access to its geometry information.- See Also:
-
ALLOW_GEOMETRY_WRITE
public static final int ALLOW_GEOMETRY_WRITESpecifies that the node allows write access to its geometry information.- See Also:
-
ALLOW_APPEARANCE_READ
public static final int ALLOW_APPEARANCE_READSpecifies that the node allows read access to its appearance information.- See Also:
-
ALLOW_APPEARANCE_WRITE
public static final int ALLOW_APPEARANCE_WRITESpecifies that the node allows write access to its appearance information.- See Also:
-
ALLOW_COLLISION_BOUNDS_READ
public static final int ALLOW_COLLISION_BOUNDS_READSpecifies that the node allows reading its collision Bounds- See Also:
-
ALLOW_COLLISION_BOUNDS_WRITE
public static final int ALLOW_COLLISION_BOUNDS_WRITESpecifies the node allows writing its collision Bounds- See Also:
-
ALLOW_APPEARANCE_OVERRIDE_READ
public static final int ALLOW_APPEARANCE_OVERRIDE_READSpecifies that this node allows reading its appearance override enable flag.- Since:
- Java 3D 1.2
- See Also:
-
ALLOW_APPEARANCE_OVERRIDE_WRITE
public static final int ALLOW_APPEARANCE_OVERRIDE_WRITESpecifies that this node allows writing its appearance override enable flag.- Since:
- Java 3D 1.2
- See Also:
-
-
Constructor Details
-
Shape3D
public Shape3D()Constructs a Shape3D node with default parameters. The default values are as follows:-
appearance : null
geometry : { null }
collision bounds : null
appearance override enable : false
-
Shape3D
Constructs and initializes a Shape3D node with the specified geometry component and a null appearance component. The list of geometry components is initialized with the specified geometry component as the single element with an index of 0. A null appearance component specifies that default values are used for all appearance attributes.- Parameters:
geometry
- the geometry component with which to initialize this shape node.
-
Shape3D
Constructs and initializes a Shape3D node with the specified geometry and appearance components. The list of geometry components is initialized with the specified geometry component as the single element with an index of 0.- Parameters:
geometry
- the geometry component with which to initialize this shape nodeappearance
- the appearance component of the shape node
-
-
Method Details
-
setCollisionBounds
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
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
Replaces the geometry component at index 0 in this Shape3D node's list of geometry components with the specified geometry component. If there are existing geometry components in the list (besides the one being replaced), the new geometry component must be of the same equivalence class (point, line, polygon, CompressedGeometry, Raster, Text3D) as the others.- Parameters:
geometry
- the geometry component to be stored at index 0.- Throws:
IllegalArgumentException
- if the new geometry component is not of of the same equivalence class as the existing geometry components.CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph
-
getGeometry
Retrieves the geometry component at index 0 from this Shape3D node's list of geometry components.- Returns:
- the geometry component at index 0.
- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph
-
setGeometry
Replaces the geometry component at the specified index in this Shape3D node's list of geometry components with the specified geometry component. If there are existing geometry components in the list (besides the one being replaced), the new geometry component must be of the same equivalence class (point, line, polygon, CompressedGeometry, Raster, Text3D) as the others.- Parameters:
geometry
- the geometry component to be stored at the specified index.index
- the index of the geometry component to be replaced.- Throws:
IllegalArgumentException
- if the new geometry component is not of of the same equivalence class as the existing geometry components.CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph- Since:
- Java 3D 1.2
-
getGeometry
Retrieves the geometry component at the specified index from this Shape3D node's list of geometry components.- Parameters:
index
- the index of the geometry component to be returned.- Returns:
- the geometry component at the specified index.
- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph- Since:
- Java 3D 1.2
-
insertGeometry
Inserts the specified geometry component into this Shape3D node's list of geometry components at the specified index. If there are existing geometry components in the list, the new geometry component must be of the same equivalence class (point, line, polygon, CompressedGeometry, Raster, Text3D) as the others.- Parameters:
geometry
- the geometry component to be inserted at the specified index.index
- the index at which the geometry component is inserted.- Throws:
IllegalArgumentException
- if the new geometry component is not of of the same equivalence class as the existing geometry components.CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph- Since:
- Java 3D 1.2
-
removeGeometry
public void removeGeometry(int index) Removes the geometry component at the specified index from this Shape3D node's list of geometry components.- Parameters:
index
- the index of the geometry component to be removed.- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph- Since:
- Java 3D 1.2
-
getAllGeometries
Returns an enumeration of this Shape3D node's list of geometry components.- Returns:
- an Enumeration object containing all geometry components in this Shape3D node's list of geometry components.
- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph- Since:
- Java 3D 1.2
-
addGeometry
Appends the specified geometry component to this Shape3D node's list of geometry components. If there are existing geometry components in the list, the new geometry component must be of the same equivalence class (point, line, polygon, CompressedGeometry, Raster, Text3D) as the others.- Parameters:
geometry
- the geometry component to be appended.- Throws:
IllegalArgumentException
- if the new geometry component is not of of the same equivalence class as the existing geometry components.CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph- Since:
- Java 3D 1.2
-
numGeometries
public int numGeometries()Returns the number of geometry components in this Shape3D node's list of geometry components.- Returns:
- the number of geometry components in this Shape3D node's list of geometry components.
- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph- Since:
- Java 3D 1.2
-
indexOfGeometry
Retrieves the index of the specified geometry component in this Shape3D node's list of geometry components.- Parameters:
geometry
- the geometry component to be looked up.- Returns:
- the index of the specified geometry component; returns -1 if the object is not in the list.
- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph- Since:
- Java 3D 1.3
-
removeGeometry
Removes the specified geometry component from this Shape3D node's list of geometry components. If the specified object is not in the list, the list is not modified.- Parameters:
geometry
- the geometry component to be removed.- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph- Since:
- Java 3D 1.3
-
removeAllGeometries
public void removeAllGeometries()Removes all geometry components from this Shape3D node.- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph- Since:
- Java 3D 1.3
-
setAppearance
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
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
Checks whether the geometry in this shape node intersects with the specified pickShape.- Parameters:
path
- the SceneGraphPath to this shape nodepickShape
- the PickShape to be intersected- Returns:
- true if the pick shape intersects this node; false otherwise.
- Throws:
IllegalArgumentException
- if pickShape is a PickPoint. Java 3D doesn't have spatial information of the surface. Use PickBounds with BoundingSphere and a small radius, instead.CapabilityNotSetException
- if the Geometry.ALLOW_INTERSECT capability bit is not set in all of the Geometry objects referred to by this shape node.
-
intersect
Checks whether the geometry in this shape node intersects with the specified pickRay.- Parameters:
path
- the SceneGraphPath to this shape nodepickRay
- the PickRay to be intersecteddist
- the closest distance of the intersection- Returns:
- true if the pick shape intersects this node; false otherwise. If true, dist contains the closest distance of intersection.
- Throws:
CapabilityNotSetException
- if the Geometry.ALLOW_INTERSECT capability bit is not set in all of the Geometry objects referred to by this shape node.
-
intersect
Checks whether the geometry in this shape node intersects with the specified pickShape.- Parameters:
path
- the SceneGraphPath to this shape nodepickShape
- the PickShape to be intersecteddist
- the closest distance of the intersection- Returns:
- true if the pick shape intersects this node; false otherwise. If true, dist contains the closest distance of intersection.
- Throws:
IllegalArgumentException
- if pickShape is a PickPoint. Java 3D doesn't have spatial information of the surface. Use PickBounds with BoundingSphere and a small radius, instead.CapabilityNotSetException
- if the Geometry.ALLOW_INTERSECT capability bit is not set in all of the Geometry objects referred to by this shape node.- Since:
- Java 3D 1.3
-
setAppearanceOverrideEnable
public void setAppearanceOverrideEnable(boolean flag) Sets a flag that indicates whether this node's appearance can be overridden. If the flag is true, then 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:
-
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
Used to create a new instance of the node. This routine is called bycloneTree
to duplicate the current node.cloneNode
should be overridden by any user subclassed objects. All subclasses must have theircloneNode
method consist of the following lines:public Node cloneNode(boolean forceDuplicate) { UserSubClass usc = new UserSubClass(); usc.duplicateNode(this, forceDuplicate); return usc; }
-
duplicateNode
Copies all node information fromoriginalNode
into the current node. This method is called from thecloneNode
method which is, in turn, called by thecloneTree
method.For any
NodeComponent
objects contained by the object being duplicated, eachNodeComponent
object'sduplicateOnCloneTree
value is used to determine whether theNodeComponent
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 theforceDuplicate
parameter in thecloneTree
method totrue
.
NOTE: Applications should not call this method directly. It should only be called by the cloneNode method.- Overrides:
duplicateNode
in classNode
- Parameters:
originalNode
- the original node to duplicate.forceDuplicate
- when set totrue
, causes theduplicateOnCloneTree
flag to be ignored. Whenfalse
, the value of each node'sduplicateOnCloneTree
variable determines whether NodeComponent data is duplicated or copied.- Throws:
ClassCastException
- if originalNode is not an instance ofShape3D
- See Also:
-
getBounds
See parent class for the documentation on getBounds().
-