Package com.sun.j3d.utils.geometry
Class Primitive
java.lang.Object
javax.media.j3d.SceneGraphObject
javax.media.j3d.Node
javax.media.j3d.Group
com.sun.j3d.utils.geometry.Primitive
Base class for all Java 3D primitives. By default all primitives
with the same parameters share their geometry (e.g., you can have 50
shperes in your scene, but the geometry is stored only once). A
change to one primitive will effect all shared nodes. Another
implication of this implementation is that the capabilities of the
geometry are shared, and once one of the shared nodes is live, the
capabilities cannot be set. Use the GEOMETRY_NOT_SHARED flag if
you do not wish to share geometry among primitives with the same
parameters.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSpecifies that the ALLOW_APPEARANCE_READ and ALLOW_APPEARANCE_WRITE bits are to be set on the generated geometry's Shape3D nodes.static final intSpecifies that the ALLOW_INTERSECT capability bit should be set on the generated geometry.static final intSpecifies that normals are generated along with the positions.static final intSpecifies that normals are to be flipped along the surface.static final intSpecifies that texture coordinates are generated along with the positions.static final intSpecifies that texture coordinates are to be Y up.static final intSpecifies that the geometry being created will not be shared by another scene graph node.Fields inherited from class javax.media.j3d.Group
ALLOW_CHILDREN_EXTEND, ALLOW_CHILDREN_READ, ALLOW_CHILDREN_WRITE, ALLOW_COLLISION_BOUNDS_READ, ALLOW_COLLISION_BOUNDS_WRITEFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcacheGeometry(int kind, float a, float b, float c, int d, int e, int flags, com.sun.j3d.utils.geometry.GeomBuffer geo) static voidClear the shared geometry cache for all Primitive types.Gets the appearance of the primitive (defaults to first subpart).abstract AppearancegetAppearance(int partId) Gets the appearance of the specified part of the primitive.protected com.sun.j3d.utils.geometry.GeomBuffergetCachedGeometry(int kind, float a, float b, float c, int d, int e, int flags) intReturns the total number of triangles in this primitive.intReturns the total number of vertices in this primitive.intReturns the flags of primitive (generate normal, textures, caching, etc).abstract Shape3DgetShape(int partid) Obtains a shape node of a subpart of the primitive.voidSets the main appearance of the primitive (all subparts) to a default white appearance.voidsetAppearance(int partid, Appearance ap) Sets the appearance of a subpart given a partid.abstract voidSets the main appearance of the primitive (all subparts) to same appearance.voidsetNumTriangles(int num) Deprecated.The number of triangles is an immutable attribute.voidsetNumVertices(int num) Deprecated.The number of vertices is an immutable attribute.voidsetPrimitiveFlags(int fl) Deprecated.The primitive flags must be set at construction time via one of the subclass constructors.Methods inherited from class javax.media.j3d.Group
addChild, cloneNode, getAllChildren, getAlternateCollisionTarget, getChild, getCollisionBounds, indexOfChild, insertChild, moveTo, numChildren, removeAllChildren, removeChild, removeChild, setAlternateCollisionTarget, setChild, setCollisionBoundsMethods inherited from class javax.media.j3d.Node
cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocale, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickableMethods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences
-
Field Details
-
GENERATE_NORMALS
public static final int GENERATE_NORMALSSpecifies that normals are generated along with the positions.- See Also:
-
GENERATE_TEXTURE_COORDS
public static final int GENERATE_TEXTURE_COORDSSpecifies that texture coordinates are generated along with the positions.- See Also:
-
GENERATE_NORMALS_INWARD
public static final int GENERATE_NORMALS_INWARDSpecifies that normals are to be flipped along the surface.- See Also:
-
GENERATE_TEXTURE_COORDS_Y_UP
public static final int GENERATE_TEXTURE_COORDS_Y_UPSpecifies that texture coordinates are to be Y up.- Since:
- Java 3D 1.5.1
- See Also:
-
GEOMETRY_NOT_SHARED
public static final int GEOMETRY_NOT_SHAREDSpecifies that the geometry being created will not be shared by another scene graph node. By default all primitives created with the same parameters share their geometry (e.g., you can have 50 spheres in your scene, but the geometry is stored only once). A change to one primitive will effect all shared nodes. You specify this flag if you do not wish to share any geometry among primitives of the same parameters.- See Also:
-
ENABLE_GEOMETRY_PICKING
public static final int ENABLE_GEOMETRY_PICKINGSpecifies that the ALLOW_INTERSECT capability bit should be set on the generated geometry. This allows the object to be picked using Geometry based picking.- See Also:
-
ENABLE_APPEARANCE_MODIFY
public static final int ENABLE_APPEARANCE_MODIFYSpecifies that the ALLOW_APPEARANCE_READ and ALLOW_APPEARANCE_WRITE bits are to be set on the generated geometry's Shape3D nodes.- See Also:
-
-
Constructor Details
-
Primitive
public Primitive()Constructs a default primitive.
-
-
Method Details
-
getNumTriangles
public int getNumTriangles()Returns the total number of triangles in this primitive.- Returns:
- the total number of triangles in this primitive
-
setNumTriangles
public void setNumTriangles(int num) Deprecated.The number of triangles is an immutable attribute. -
getNumVertices
public int getNumVertices()Returns the total number of vertices in this primitive.- Returns:
- the total number of vertices in this primitive
-
setNumVertices
public void setNumVertices(int num) Deprecated.The number of vertices is an immutable attribute. -
getPrimitiveFlags
public int getPrimitiveFlags()Returns the flags of primitive (generate normal, textures, caching, etc). -
setPrimitiveFlags
public void setPrimitiveFlags(int fl) Deprecated.The primitive flags must be set at construction time via one of the subclass constructors. -
getShape
Obtains a shape node of a subpart of the primitive.- Parameters:
partid- identifier for a given subpart of the primitive.
-
getAppearance
Gets the appearance of the primitive (defaults to first subpart). -
getAppearance
Gets the appearance of the specified part of the primitive.- Parameters:
partId- identifier for a given subpart of the primitive- Returns:
- The appearance object associated with the partID. If an invalid partId is passed in, null is returned.
- Since:
- Java 3D 1.2.1
-
setAppearance
Sets the appearance of a subpart given a partid. -
setAppearance
Sets the main appearance of the primitive (all subparts) to same appearance. -
setAppearance
public void setAppearance()Sets the main appearance of the primitive (all subparts) to a default white appearance. -
cacheGeometry
protected void cacheGeometry(int kind, float a, float b, float c, int d, int e, int flags, com.sun.j3d.utils.geometry.GeomBuffer geo) -
getCachedGeometry
protected com.sun.j3d.utils.geometry.GeomBuffer getCachedGeometry(int kind, float a, float b, float c, int d, int e, int flags) -
clearGeometryCache
public static void clearGeometryCache()Clear the shared geometry cache for all Primitive types. Existing Shapes with shared geometry will continue to share the geometry. New Primitives will create new shared geometry.- Since:
- Java 3D 1.3.2
-