Class BaseComponentGeometryNode
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.BaseComponentGeometryNode
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLComponentGeometryNodeType
,VRMLGeometryNodeType
,VRMLNodeComponentListener
,VRMLNodeType
- Direct Known Subclasses:
BaseIndexedGeometryNode
,BaseIndexedQuadSet
,BaseIndexedTriangleGeometryNode
,BaseLineSet
,BasePointSetGeometryNode
,BaseQuadSet
,BaseTriangleGeometryNode
public abstract class BaseComponentGeometryNode
extends AbstractNode
implements VRMLComponentGeometryNodeType, VRMLNodeComponentListener
An abstract implementation of any node that uses component nodes to provide
coordinate, normal and texture information.
- Version:
- $Revision: 1.20 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
Flag value for the changeFlags color node changeprotected static final int
Flag value for the changeFlags attrib index changeprotected static final String
Message for when the node in setValue() is not a vertex attributeprotected static final String
Message for when the proto is not a vertex attributeprotected static final String
Message for when the node in setValue() is not a Geometryprotected static final String
Message for when the proto is not a Geometryprotected int
Bit-flags to work out what has changed during the last frameprotected static final String
Message for when the node in setValue() is not a Colorprotected static final String
Message for when the proto is not a Colorprotected static final int
Flag value for the changeFlags color node changeprotected static final int
Flag value for the changeFlags color index changeprotected static final String
Message for when the node in setValue() is not a Coordprotected static final String
Message for when the proto is not a Coordprotected static final int
Flag value for the changeFlags coordinate node changeprotected static final int
Flag value for the changeFlags coordinate index changeprotected static final int
Index of the attribute's exposedFieldprotected static final int
Index of the ccw fieldprotected static final int
Index of the color exposedFieldprotected static final int
Index of the colorPerVertex fieldprotected static final int
Index of the coord exposedFieldprotected static final int
Index of the fogCoord exposedFieldprotected static final int
Index of the normal exposedFieldprotected static final int
Index of the normalPerVertex fieldprotected static final int
Index of the solid fieldprotected static final int
Index of the texture exposedFieldprotected static final int
Flag value for the changeFlags color node changeprotected static final int
Flag value for the changeFlags fog index changeprotected static final String
Message for when the node in setValue() is not a FogCoordinateprotected static final String
Message for when the proto is not a FogCoordinateprotected static final int
The last field index used by this classprotected boolean
Should local color node be used for diffuse lightingprotected List
<LocalColorsListener> The list of listeners for localColor changesprotected static final int
Flag value for the changeFlags normal node changeprotected static final int
Flag value for the changeFlags normal index changeprotected VRMLProtoInstance
Proto version of the colorprotected VRMLProtoInstance
Proto version of the coordprotected VRMLProtoInstance
Proto version of the fogCoordprotected VRMLProtoInstance
Proto version of the normalprotected VRMLProtoInstance
Proto version of the texCoordprotected static final int
Flag value for the changeFlags texCoords node changeprotected static final int
Flag value for the changeFlags texCoords index changeprotected static final int
Flag value for the changeFlags unlit color changestatic final int
The minimum number of vertices before using VBO'sprotected List
<VRMLNodeType> List of per-vertex attribute nodes providedprotected boolean
field SFBool ccw TRUEprotected VRMLColorNodeType
exposedField SFNode colorprotected boolean
field SFBool colorPerVertex TRUEprotected VRMLCoordinateNodeType
exposedField SFNode coordprotected VRMLGeometricPropertyNodeType
exposedField SFNode fogCoordprotected VRMLNormalNodeType
exposedField SFNode normalprotected boolean
field SFBool normalPerVertex TRUEprotected boolean
field SFBool solid TRUEprotected VRMLTextureCoordinateNodeType
exposedField SFNode texCoordFields 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 instance of this class with the bind flag set to false and no time information set (effective value of zero). -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener for local color changes.void
Add a listener for texture coordinate generation mode changes.protected void
Set the fields of the binadble node that has the fields set based on the fields of the passed in node.protected void
fireLocalColorsChanged
(boolean enabled) Send the localColorsChanged event to LocalColorsListenersGet the components that compose a geometry object.getFieldValue
(int index) Get the value of a field.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
Check to see if the colors are per vertex or per face.boolean
Specified whether this node has alpha values in the local colour information.boolean
Specified whether this node has color information.boolean
Check to see if the normals are per vertex or per face.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.boolean
Check to see if this geometry implementation type requires unlit color values to be set.void
sendRoute
(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.protected void
Notification of the color node being set.void
setComponent
(VRMLNodeType comp) Set a component that composes part of a geometry object.void
setComponents
(VRMLNodeType[] comps) Set the components the compose a geometry object.protected void
Notification of the coordinate node being set.protected void
Notification of the coordinate node being set.protected void
Notification of the normal node being set.protected void
Notification of the texture coordinate node being set.void
setTextureCount
(int count) Set the number of textures that were found on the accompanying Appearance node.void
setUnlitColor
(float[] color) Set the local colour override for this geometry.void
Notification that the construction phase of this node has finished.void
setValue
(int index, boolean value) Set the value of the field at the given index as an boolean.void
setValue
(int index, VRMLNodeType child) Set the value of the field at the given index as a node.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, setDEF, setErrorReporter, setFrameStateManager, setMetadataObject, setUserData, setValue, 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
getFieldDeclaration, getFieldIndex, getNodeFieldIndices, getNumFields, getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersion
Methods inherited from interface org.web3d.vrml.nodes.VRMLNodeComponentListener
fieldChanged
Methods inherited from interface org.web3d.vrml.nodes.VRMLNodeType
addNodeListener, clearRemovedLayerIds, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, hasFieldChanged, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setFrameStateManager, setMetadataObject, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Field Details
-
VBO_MIN_VERTICES
public static final int VBO_MIN_VERTICESThe minimum number of vertices before using VBO's- See Also:
-
FIELD_COORD
protected static final int FIELD_COORDIndex of the coord exposedField- See Also:
-
FIELD_COLOR
protected static final int FIELD_COLORIndex of the color exposedField- See Also:
-
FIELD_NORMAL
protected static final int FIELD_NORMALIndex of the normal exposedField- See Also:
-
FIELD_TEXCOORD
protected static final int FIELD_TEXCOORDIndex of the texture exposedField- See Also:
-
FIELD_SOLID
protected static final int FIELD_SOLIDIndex of the solid field- See Also:
-
FIELD_CCW
protected static final int FIELD_CCWIndex of the ccw field- See Also:
-
FIELD_COLORPERVERTEX
protected static final int FIELD_COLORPERVERTEXIndex of the colorPerVertex field- See Also:
-
FIELD_NORMALPERVERTEX
protected static final int FIELD_NORMALPERVERTEXIndex of the normalPerVertex field- See Also:
-
FIELD_FOG_COORD
protected static final int FIELD_FOG_COORDIndex of the fogCoord exposedField- See Also:
-
FIELD_ATTRIBS
protected static final int FIELD_ATTRIBSIndex of the attribute's exposedField- See Also:
-
LAST_GEOMETRY_INDEX
protected static final int LAST_GEOMETRY_INDEXThe last field index used by this class- See Also:
-
COORDS_CHANGED
protected static final int COORDS_CHANGEDFlag value for the changeFlags coordinate node change- See Also:
-
NORMALS_CHANGED
protected static final int NORMALS_CHANGEDFlag value for the changeFlags normal node change- See Also:
-
TEXCOORDS_CHANGED
protected static final int TEXCOORDS_CHANGEDFlag value for the changeFlags texCoords node change- See Also:
-
COLORS_CHANGED
protected static final int COLORS_CHANGEDFlag value for the changeFlags color node change- See Also:
-
FOG_CHANGED
protected static final int FOG_CHANGEDFlag value for the changeFlags color node change- See Also:
-
ATTRIB_CHANGED
protected static final int ATTRIB_CHANGEDFlag value for the changeFlags color node change- See Also:
-
UNLIT_COLORS_CHANGED
protected static final int UNLIT_COLORS_CHANGEDFlag value for the changeFlags unlit color change- See Also:
-
COORDS_INDEX_CHANGED
protected static final int COORDS_INDEX_CHANGEDFlag value for the changeFlags coordinate index change- See Also:
-
NORMALS_INDEX_CHANGED
protected static final int NORMALS_INDEX_CHANGEDFlag value for the changeFlags normal index change- See Also:
-
TEXCOORDS_INDEX_CHANGED
protected static final int TEXCOORDS_INDEX_CHANGEDFlag value for the changeFlags texCoords index change- See Also:
-
COLORS_INDEX_CHANGED
protected static final int COLORS_INDEX_CHANGEDFlag value for the changeFlags color index change- See Also:
-
FOG_INDEX_CHANGED
protected static final int FOG_INDEX_CHANGEDFlag value for the changeFlags fog index change- See Also:
-
ATTRIB_INDEX_CHANGED
protected static final int ATTRIB_INDEX_CHANGEDFlag value for the changeFlags attrib index change- See Also:
-
BAD_PROTO_MSG
-
BAD_NODE_MSG
Message for when the node in setValue() is not a Geometry- See Also:
-
COORD_PROTO_MSG
-
COORD_NODE_MSG
Message for when the node in setValue() is not a Coord- See Also:
-
COLOR_PROTO_MSG
-
COLOR_NODE_MSG
Message for when the node in setValue() is not a Color- See Also:
-
FOG_PROTO_MSG
Message for when the proto is not a FogCoordinate- See Also:
-
FOG_NODE_MSG
Message for when the node in setValue() is not a FogCoordinate- See Also:
-
ATTRIB_PROTO_MSG
Message for when the proto is not a vertex attribute- See Also:
-
ATTRIB_NODE_MSG
Message for when the node in setValue() is not a vertex attribute- See Also:
-
pColor
Proto version of the color -
vfColor
exposedField SFNode color -
pCoord
Proto version of the coord -
vfCoord
exposedField SFNode coord -
pNormal
Proto version of the normal -
vfNormal
exposedField SFNode normal -
pTexCoord
Proto version of the texCoord -
vfTexCoord
exposedField SFNode texCoord -
pFogCoord
Proto version of the fogCoord -
vfFogCoord
exposedField SFNode fogCoord -
vfColorPerVertex
protected boolean vfColorPerVertexfield SFBool colorPerVertex TRUE -
vfNormalPerVertex
protected boolean vfNormalPerVertexfield SFBool normalPerVertex TRUE -
vfSolid
protected boolean vfSolidfield SFBool solid TRUE -
vfCcw
protected boolean vfCcwfield SFBool ccw TRUE -
changeFlags
protected int changeFlagsBit-flags to work out what has changed during the last frame -
vfAttribs
List of per-vertex attribute nodes provided -
localColors
protected boolean localColorsShould local color node be used for diffuse lighting -
localColorsListeners
The list of listeners for localColor changes
-
-
Constructor Details
-
BaseComponentGeometryNode
Construct a default instance of this class with the bind flag set to false and no time information set (effective value of zero).- Parameters:
name
- The name of the type of 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.
-
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.The default implementation does nothing. Individual node implementations should process this as needed
- 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
-
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
-
copy
Set the fields of the binadble node that has the fields set based on the fields of the passed in node. This directly copies the bind state, so could cause some interesting problems. Not sure what we should do with this currently.- Parameters:
node
- The bindable node to copy info from
-
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.- Specified by:
isCCW
in interfaceVRMLGeometryNodeType
- Returns:
- true Vertices are declared in counter-clockwise order
-
isLightingEnabled
public boolean isLightingEnabled()Specifies whether this node requires lighting.- Specified by:
isLightingEnabled
in interfaceVRMLGeometryNodeType
- Returns:
- Should lighting be enabled
-
getComponents
Get the components that compose a geometry object.This method will return either VRMLGeometricPropertyNodeType or VRMLProtoInstance. With a proto you can use getImplementationNode to get a node conforming to the VRMLGeometricPropertyNodeType interface.
If there are no components then a zero length array will be returned.
- Specified by:
getComponents
in interfaceVRMLComponentGeometryNodeType
- Returns:
- VRMLNodeType[] The components
-
setComponents
Set the components the compose a geometry object. To clear all the components, pass a null parameter.- Specified by:
setComponents
in interfaceVRMLComponentGeometryNodeType
- Parameters:
comps
- An array of geometric properties- Throws:
InvalidFieldValueException
- The node is not a known or supported field for this node
-
setComponent
Set a component that composes part of a geometry object.- Specified by:
setComponent
in interfaceVRMLComponentGeometryNodeType
- Parameters:
comp
- A geometric property- Throws:
InvalidFieldValueException
- The node is not a known or supported field for this node
-
hasColorPerVertex
public boolean hasColorPerVertex()Check to see if the colors are per vertex or per face.- Specified by:
hasColorPerVertex
in interfaceVRMLComponentGeometryNodeType
- Returns:
- true The colors are per vertex
-
hasNormalPerVertex
public boolean hasNormalPerVertex()Check to see if the normals are per vertex or per face.- Specified by:
hasNormalPerVertex
in interfaceVRMLComponentGeometryNodeType
- Returns:
- true The normals are per vertex
-
requiresUnlitColor
public boolean requiresUnlitColor()Check to see if this geometry implementation type requires unlit color values to be set. For the most part this will always return false, but some will need it (points and lines). This value should be constant for the geometry regardless of whether a Color component has been provided or not. It is up to the implementation to decide when to pass these values on to the underlying rendering structures or not.The default implementation returns false. Override if different behaviour is needed.
- Specified by:
requiresUnlitColor
in interfaceVRMLComponentGeometryNodeType
- Returns:
- true if we need unlit colour information
-
setUnlitColor
public void setUnlitColor(float[] color) Set the local colour override for this geometry. Typically used to set the emissiveColor from the Material node into the geometry for the line and point-type geometries which are unlit in the X3D/VRML model.The default implementation does nothing. Override to do something useful.
- Specified by:
setUnlitColor
in interfaceVRMLComponentGeometryNodeType
- Parameters:
color
- The colour value to use
-
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
-
setupFinished
public void setupFinished()Notification that the construction phase of this node has finished. If the node would like to do any internal processing, such as setting up geometry, then go for it now.- Specified by:
setupFinished
in interfaceVRMLNodeType
- Overrides:
setupFinished
in classAbstractNode
-
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
-
sendRoute
Send a routed value from this node to the given destination node. The route should use the appropriate setValue() method of the destination node. It should not attempt to cast the node up to a higher level. Routing should also follow the standard rules for the loop breaking and other appropriate rules for the specification.- Specified by:
sendRoute
in interfaceVRMLNodeType
- Overrides:
sendRoute
in classAbstractNode
- Parameters:
time
- The time that this route occurred (not necessarily epoch time. Should be treated as a relative value only)srcIndex
- The index of the field in this node that the value should be sent fromdestNode
- The node reference that we will be sending the value todestIndex
- The index of the field in the destination node that the value should be sent to.
-
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 knowInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, VRMLNodeType child) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a node. This would be used to set SFNode field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setchild
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The node does not match the required type.
-
setCoordinateNode
Notification of the coordinate node being set. If the passed value is null then that clears the node. The node passed is the actual geometry, not any proto wrapper, that will have been previously stripped. The default implementation does nothing.- Parameters:
node
- The node to use
-
setColorNode
Notification of the color node being set. If the passed value is null then that clears the node. The node passed is the actual color, not any proto wrapper, that will have been previously stripped. The default implementation does nothing.- Parameters:
node
- The node to use
-
setNormalNode
Notification of the normal node being set. If the passed value is null then that clears the node. The node passed is the actual normal, not any proto wrapper, that will have been previously stripped. The default implementation does nothing.- Parameters:
node
- The node to use
-
setTexCoordNode
Notification of the texture coordinate node being set. If the passed value is null then that clears the node. The node passed is the actual texCoord, not any proto wrapper, that will have been previously stripped. The default implementation does nothing.- Parameters:
node
- The node to use
-
setFogCoordinateNode
Notification of the coordinate node being set. If the passed value is null then that clears the node. The node passed is the actual geometry, not any proto wrapper, that will have been previously stripped. The default implementation does nothing.- Parameters:
node
- The node to use
-
fireLocalColorsChanged
protected void fireLocalColorsChanged(boolean enabled) Send the localColorsChanged event to LocalColorsListeners- Parameters:
enabled
- Whether local colors are used.
-