Class BaseExtrusion
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLGeometryNodeType
,VRMLNodeType
- Direct Known Subclasses:
NRExtrusion
,OGLExtrusion
The cross-sections of an Extrusion can be scaled and rotated at each spine point to produce a wide variety of shapes. For each spine point, the cross-section shape is scaled by the vfScale parameter, translated by the spine parameter, and then oriented using the orientation parameter. Corresponding vertices of the first and second cross-sections are then connected, forming a quadrilateral polygon between each pair of vertices.
- Version:
- $Revision: 1.19 $
- Author:
- Andrzej Kapolka, additional commenting by Eric Fickenscher
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
Field Index for beginCapprotected static final int
Field Index for ccwprotected static final int
Field Index for convexprotected static final int
Field Index for creaseAngleprotected static final int
Field Index for crossSectionprotected static final int
Field Index for endCapprotected static final int
Field Index for orientationprotected static final int
Field Index for scaleprotected static final int
Field Index for set_crossSectionprotected static final int
Field Index for set_orientationprotected static final int
Field Index for set_scaleprotected static final int
Field Index for set_spineprotected static final int
Field Index for solidprotected static final int
Field Index for spineprotected static final int
The last index in this nodeprotected static final int
Number of fields constantprotected int
This int keeps track of the number of valid items in vfCrossSection.protected int
This int keeps track of the number of valid items in vfOrientation.protected int
This int keeps track of the number of valid items in vfScale.protected int
This int keeps track of the number of valid items in vfSpine.protected boolean
This field specifies if the extruded shape is open or closed at one end.protected boolean
This field specifies the vertex ordering - if TRUE, the right-hand rule is used, meaning the vertices are ordered in a counter-clockwise direction.protected boolean
This field specifies if the cross-section is convex or concave.protected float
creaseAngle specifies an angle threshold.protected float[]
This is an array of floats that represents the extrusion's 2D cross-section.protected boolean
This field specifies if the extruded shape is open or closed at one end.protected float[]
This field specifies cross-section rotation.protected float[]
This field specifies scaling of the cross-sections.protected boolean
This field specifies if the extruded shape is solid or not.protected float[]
This field represents the placement of the cross-sections in 3D space.Fields inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
errorReporter, FIELD_METADATA, fieldLocalData, hasChanged, inSetup, isDEF, isStatic, LAST_NODE_INDEX, layerIds, nodeName, pMetadata, refCounts, removedLayerIds, stateManager, STATIC_SCENE_GRAPH, vfMetadata, vrmlMajorVersion, vrmlMinorVersion
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Construct a default extrusion instanceBaseExtrusion
(VRMLNodeType node) Construct a new instance of this node based on the details from the given node. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener for local color changes.void
Add a listener for texture coordinate generation mode changes.getFieldDeclaration
(int index) Get the declaration of the field at the given index.int
getFieldIndex
(String fieldName) Get the index of the given field name.getFieldValue
(int index) Get the value of a field.int[]
Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode).int
Get the number of fields.int
Get the number of texture coordinate sets contained by this nodeint
Get the primary type of this node.getTexCoordGenMode
(int setNum) Get the texture coordinate generation mode.boolean
Specified whether this node has alpha values in the local colour information.boolean
Specified whether this node has color information.boolean
isCCW()
Get the value of the CCW field.boolean
Specifies whether this node requires lighting.boolean
isSolid()
Get the value of the solid field.void
Remove a listener for local color changes.void
Remove a listener for texture coordinate generation mode changes.void
setTextureCount
(int count) Set the number of textures that were found on the accompanying Appearance node.void
setValue
(int index, boolean value) Set the value of the field at the given index as an boolean.void
setValue
(int index, float value) Set the value of the field at the given index as a float.void
setValue
(int index, float[] value, int numValid) Set the value of the field at the given index as an array of floats.Methods inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
addNodeListener, allEventsComplete, checkNodeType, checkSecondaryType, checkSecondaryType, clearRemovedLayerIds, fireFieldChanged, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, getSecondaryType, getUserData, getVRMLNodeName, hasFieldChanged, isDEF, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, sendRoute, setDEF, setErrorReporter, setFrameStateManager, setMetadataObject, setupFinished, setUserData, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setVersion, throwInitOnlyWriteException, throwInputOnlyWriteException, throwInvalidNodeException, throwInvalidProtoException, throwOutputOnlyWriteException, updateRefCount, updateRefs
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.web3d.vrml.nodes.FrameStateListener
allEventsComplete
Methods inherited from interface org.web3d.vrml.lang.VRMLNode
getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersion
Methods inherited from interface org.web3d.vrml.nodes.VRMLNodeType
addNodeListener, clearRemovedLayerIds, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, hasFieldChanged, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, sendRoute, setDEF, setFrameStateManager, setMetadataObject, setupFinished, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Field Details
-
FIELD_BEGIN_CAP
protected static final int FIELD_BEGIN_CAPField Index for beginCap- See Also:
-
FIELD_CCW
protected static final int FIELD_CCWField Index for ccw- See Also:
-
FIELD_CONVEX
protected static final int FIELD_CONVEXField Index for convex- See Also:
-
FIELD_CREASE_ANGLE
protected static final int FIELD_CREASE_ANGLEField Index for creaseAngle- See Also:
-
FIELD_CROSS_SECTION
protected static final int FIELD_CROSS_SECTIONField Index for crossSection- See Also:
-
FIELD_END_CAP
protected static final int FIELD_END_CAPField Index for endCap- See Also:
-
FIELD_ORIENTATION
protected static final int FIELD_ORIENTATIONField Index for orientation- See Also:
-
FIELD_SCALE
protected static final int FIELD_SCALEField Index for scale- See Also:
-
FIELD_SOLID
protected static final int FIELD_SOLIDField Index for solid- See Also:
-
FIELD_SPINE
protected static final int FIELD_SPINEField Index for spine- See Also:
-
FIELD_SET_CROSS_SECTION
protected static final int FIELD_SET_CROSS_SECTIONField Index for set_crossSection- See Also:
-
FIELD_SET_ORIENTATION
protected static final int FIELD_SET_ORIENTATIONField Index for set_orientation- See Also:
-
FIELD_SET_SCALE
protected static final int FIELD_SET_SCALEField Index for set_scale- See Also:
-
FIELD_SET_SPINE
protected static final int FIELD_SET_SPINEField Index for set_spine- See Also:
-
LAST_EXTRUSION_INDEX
protected static final int LAST_EXTRUSION_INDEXThe last index in this node- See Also:
-
NUM_FIELDS
protected static final int NUM_FIELDSNumber of fields constant- See Also:
-
vfCCW
protected boolean vfCCWThis field specifies the vertex ordering - if TRUE, the right-hand rule is used, meaning the vertices are ordered in a counter-clockwise direction.SFBool ccw
-
vfConvex
protected boolean vfConvexThis field specifies if the cross-section is convex or concave. If FALSE, the cross-section is concave; the browser will split the cross-section into smaller convex cross sections.SFBool convex
-
vfCreaseAngle
protected float vfCreaseAnglecreaseAngle specifies an angle threshold. If two adjacent faces make an angle bigger than the creaseAngle, viewer will clearly see where the two faces meet - the edge linking the two faces is sharp. Otherwise the edge linking the two faces will be smooth.SFFloat creaseAngle
-
vfCrossSection
protected float[] vfCrossSectionThis is an array of floats that represents the extrusion's 2D cross-section. The 2D cross- section is replicated once for each 'spine' point, and manipulated with the 'scale' and 'orientation' fields.This float array represents a 2D cross-section in the y=0 plane. Thus, every two float values constitute a point (index [0] is the "x" value of the first point, index [1] is the "z" value of the first point; index [2] is the "x" value of the second point, etc.). When the final two values match the first two values, the 2D cross-section is closed (the first and last points are the same). If crossSection is not a closed curve, note that beginCaps or endCaps can still be generated by adding a final point to the crossSection that is equal to the initial point. A simple case of a capped open surface is a shape analogous to a soda can sliced in half vertically.
MFVec2f crossSection
-
numCrossSection
protected int numCrossSectionThis int keeps track of the number of valid items in vfCrossSection. Since vfCrossSection represents a number of points in a 2D plane, there are two values needed to represent each point. Thus, the number of points is always equal to half the length of vfCrossSection. -
vfBeginCap
protected boolean vfBeginCapThis field specifies if the extruded shape is open or closed at one end. If TRUE, the 'beginning' spine point will be closed. If vfEndCap is also TRUE, then user will _not_ be able to see into the object.SFBool beginCap
-
vfEndCap
protected boolean vfEndCapThis field specifies if the extruded shape is open or closed at one end. If TRUE, the final 'end spine point will be closed. If vfBeginCap is also TRUE, then user will _not_ be able to see into the object.SFBool endCap
-
vfOrientation
protected float[] vfOrientationThis field specifies cross-section rotation. The final orientation of each cross-section is computed by first orienting it relative to the spine segments on either side of the point at which the cross- section is placed (the "spine-aligned cross-section plane", or SCP) and then rotating it according to the appropriate orientation value.Each orientation value is defined by four float values. The first three floats specify an axis corresponding to a ray cast from the relative-to-the-SCP origin through an x-, y-, and z- point. The fourth float specifies the amount (in radians) of rotation around this axis; 3.14 corresponds to 180 degrees of rotation, .523 corresponds to 60 degrees of rotation, etc.
As is the case with the 'scale' field, if the number of orientation values is greater than the number of spine points, the excess values are ignored. If there is only one orientation value, it is applied at all spine points.
MFRotation orientation
-
numOrientation
protected int numOrientationThis int keeps track of the number of valid items in vfOrientation. Since orientation specifies a rotation around an axis, four float values are needed - the first three specify the axis of rotation via x-, y-, and z- values (ie: yaw, pitch, and roll), and the fourth float value specifies the amount (in radians) of rotation around this axis. Thus, the the number of orientation points is always equal to one- fourth the length of vfOrientation. -
vfScale
protected float[] vfScaleThis field specifies scaling of the cross-sections. Since the cross-section represents a 2-dimensional shape, two values are needed to scale a cross-section. Each cross-section is scaled about its relative origin by the appropriate scale parameter (the first value scales in X, second values scales in Z).As is the case with the 'orientation' field, if the number of scale values is greater than the number of spine points, the excess values are ignored. If there is only one scale value, it is applied at all spine points.
MFVec2f scale
-
numScale
protected int numScaleThis int keeps track of the number of valid items in vfScale. Since vfScale specifies the scaling of a two-dimensional object, two float values are needed - the first specifies the amount of scaling in the x-direction and the second specifies the amount of scaling in the z-direction. Thus, the number of scale points is always equal to one-half the length of vfScale. -
vfSolid
protected boolean vfSolidThis field specifies if the extruded shape is solid or not. If TRUE, the object is treated as a solid, which means that the _inside_ surfaces will not be rendered. IE, if the ends are not capped and vfSolid is TRUE, user will only see the faces of the object that directly face the viewer. If FALSE, the extruded shape is treated as hollow, and user will see all faces of the shape if the ends are not capped.SFBool solid
-
vfSpine
protected float[] vfSpineThis field represents the placement of the cross-sections in 3D space. In other words, the spine defines the path that the cross-section will travel. The corners of each cross-section are connected to matching corners of adjacent cross-sections, thus defining a volume.In a two-point spine, the cross-section is oriented so that the y-axis coincides with the direction defined by the two spine points. When using more spine points, this holds true for the first spine point, and second and subsequent spine points should orient the cross-section so that it is perpendicular to the tangent of the spine.
Every three values constitute a point (indices [0],[1], and [2] represent the first point, indices [3],[4], and [5] represent the second point, etc.). The simplest spine consists of only two points.
MFVec3f spine
-
numSpine
protected int numSpineThis int keeps track of the number of valid items in vfSpine. Since vfSpine represents a number of points in a 3D plane, there are three values needed to represent each point. Thus, the number of spine points is always equal to one-third the length of vfSpine.
-
-
Constructor Details
-
BaseExtrusion
protected BaseExtrusion()Construct a default extrusion instance -
BaseExtrusion
Construct a new instance of this node based on the details from the given node. If the node is not a Box node, an exception will be thrown.- Parameters:
node
- The node to copy- Throws:
IllegalArgumentException
- The node is not a Group node
-
-
Method Details
-
hasLocalColors
public boolean hasLocalColors()Specified whether this node has color information. If so, then it will be used for diffuse terms instead of materials.- Specified by:
hasLocalColors
in interfaceVRMLGeometryNodeType
- Returns:
- true Use local color information for diffuse lighting.
-
hasLocalColorAlpha
public boolean hasLocalColorAlpha()Specified whether this node has alpha values in the local colour information. If so, then it will be used for to override the material's transparency value.- Specified by:
hasLocalColorAlpha
in interfaceVRMLGeometryNodeType
- Returns:
- true when the local color value has inbuilt alpha
-
addLocalColorsListener
Add a listener for local color changes. Nulls and duplicates will be ignored.- Specified by:
addLocalColorsListener
in interfaceVRMLGeometryNodeType
- Parameters:
l
- The listener.
-
removeLocalColorsListener
Remove a listener for local color changes. Nulls will be ignored.- Specified by:
removeLocalColorsListener
in interfaceVRMLGeometryNodeType
- Parameters:
l
- The listener.
-
addTexCoordGenModeChanged
Add a listener for texture coordinate generation mode changes. Nulls and duplicates will be ignored.- Specified by:
addTexCoordGenModeChanged
in interfaceVRMLGeometryNodeType
- Parameters:
l
- The listener.
-
removeTexCoordGenModeChanged
Remove a listener for texture coordinate generation mode changes. Nulls will be ignored.- Specified by:
removeTexCoordGenModeChanged
in interfaceVRMLGeometryNodeType
- Parameters:
l
- The listener.
-
getTexCoordGenMode
Get the texture coordinate generation mode. NULL is returned if the texture coordinates are not generated.- Specified by:
getTexCoordGenMode
in interfaceVRMLGeometryNodeType
- Parameters:
setNum
- The set which this tex gen mode refers- Returns:
- The mode or NULL
-
setTextureCount
public void setTextureCount(int count) Set the number of textures that were found on the accompanying Appearance node. Used to set the number of texture coordinates that need to be passed in to the renderer when no explicit texture coordinates were given.- Specified by:
setTextureCount
in interfaceVRMLGeometryNodeType
- Parameters:
count
- The number of texture coordinate sets to add
-
getNumSets
public int getNumSets()Get the number of texture coordinate sets contained by this node- Specified by:
getNumSets
in interfaceVRMLGeometryNodeType
- Returns:
- the number of texture coordinate sets
-
isSolid
public boolean isSolid()Get the value of the solid field.- Specified by:
isSolid
in interfaceVRMLGeometryNodeType
- Returns:
- true This object is solid (ie single sided)
-
isCCW
public boolean isCCW()Get the value of the CCW field. If the node does not have one, this will return true.- Specified by:
isCCW
in interfaceVRMLGeometryNodeType
- Returns:
- true if the vertices are CCW ordered
-
isLightingEnabled
public boolean isLightingEnabled()Specifies whether this node requires lighting.- Specified by:
isLightingEnabled
in interfaceVRMLGeometryNodeType
- Returns:
- Should lighting be enabled
-
getFieldIndex
Get the index of the given field name. If the name does not exist for this node then return a value of -1.- Specified by:
getFieldIndex
in interfaceVRMLNode
- Parameters:
fieldName
- The name of the field we want the index from- Returns:
- The index of the field name or -1
-
getNodeFieldIndices
public int[] getNodeFieldIndices()Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode). Used for blind scene graph traversal without needing to spend time querying for all fields etc. If a node does not have any fields that contain nodes, this shall return null. The field list covers all field types, regardless of whether they are readable or not at the VRML-level.- Specified by:
getNodeFieldIndices
in interfaceVRMLNode
- Returns:
- The list of field indices that correspond to SF/MFnode fields or null if none
-
getFieldDeclaration
Get the declaration of the field at the given index. This allows for reverse lookup if needed. If the field does not exist, this will give a value of null.- Specified by:
getFieldDeclaration
in interfaceVRMLNode
- Parameters:
index
- The index of the field to get information- Returns:
- A representation of this field's information
-
getNumFields
public int getNumFields()Get the number of fields.- Specified by:
getNumFields
in interfaceVRMLNode
- Returns:
- The number of fields.
-
getPrimaryType
public int getPrimaryType()Get the primary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getPrimaryType
in interfaceVRMLNode
- Returns:
- The primary type
-
getFieldValue
Get the value of a field. If the field is a primitive type, it will return a class representing the value. For arrays or nodes it will return the instance directly.- Specified by:
getFieldValue
in interfaceVRMLNodeType
- Overrides:
getFieldValue
in classAbstractNode
- Parameters:
index
- The index of the field to change.- Returns:
- The class representing the field value
- Throws:
InvalidFieldException
- The field index is not known
-
setValue
public void setValue(int index, boolean value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as an boolean. This would be used to set SFBool field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, float value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a float. This would be used to set SFFloat field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, float[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an array of floats. This would be used to set MFFloat, SFVec2f, SFVec3f and SFRotation field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the nodenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-