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 intFlag value for the changeFlags color node changeprotected static final intFlag value for the changeFlags attrib index changeprotected static final StringMessage for when the node in setValue() is not a vertex attributeprotected static final StringMessage for when the proto is not a vertex attributeprotected static final StringMessage for when the node in setValue() is not a Geometryprotected static final StringMessage for when the proto is not a Geometryprotected intBit-flags to work out what has changed during the last frameprotected static final StringMessage for when the node in setValue() is not a Colorprotected static final StringMessage for when the proto is not a Colorprotected static final intFlag value for the changeFlags color node changeprotected static final intFlag value for the changeFlags color index changeprotected static final StringMessage for when the node in setValue() is not a Coordprotected static final StringMessage for when the proto is not a Coordprotected static final intFlag value for the changeFlags coordinate node changeprotected static final intFlag value for the changeFlags coordinate index changeprotected static final intIndex of the attribute's exposedFieldprotected static final intIndex of the ccw fieldprotected static final intIndex of the color exposedFieldprotected static final intIndex of the colorPerVertex fieldprotected static final intIndex of the coord exposedFieldprotected static final intIndex of the fogCoord exposedFieldprotected static final intIndex of the normal exposedFieldprotected static final intIndex of the normalPerVertex fieldprotected static final intIndex of the solid fieldprotected static final intIndex of the texture exposedFieldprotected static final intFlag value for the changeFlags color node changeprotected static final intFlag value for the changeFlags fog index changeprotected static final StringMessage for when the node in setValue() is not a FogCoordinateprotected static final StringMessage for when the proto is not a FogCoordinateprotected static final intThe last field index used by this classprotected booleanShould local color node be used for diffuse lightingprotected List<LocalColorsListener> The list of listeners for localColor changesprotected static final intFlag value for the changeFlags normal node changeprotected static final intFlag value for the changeFlags normal index changeprotected VRMLProtoInstanceProto version of the colorprotected VRMLProtoInstanceProto version of the coordprotected VRMLProtoInstanceProto version of the fogCoordprotected VRMLProtoInstanceProto version of the normalprotected VRMLProtoInstanceProto version of the texCoordprotected static final intFlag value for the changeFlags texCoords node changeprotected static final intFlag value for the changeFlags texCoords index changeprotected static final intFlag value for the changeFlags unlit color changestatic final intThe minimum number of vertices before using VBO'sprotected List<VRMLNodeType> List of per-vertex attribute nodes providedprotected booleanfield SFBool ccw TRUEprotected VRMLColorNodeTypeexposedField SFNode colorprotected booleanfield SFBool colorPerVertex TRUEprotected VRMLCoordinateNodeTypeexposedField SFNode coordprotected VRMLGeometricPropertyNodeTypeexposedField SFNode fogCoordprotected VRMLNormalNodeTypeexposedField SFNode normalprotected booleanfield SFBool normalPerVertex TRUEprotected booleanfield SFBool solid TRUEprotected VRMLTextureCoordinateNodeTypeexposedField 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
ConstructorsModifierConstructorDescriptionprotectedConstruct 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 TypeMethodDescriptionvoidAdd a listener for local color changes.voidAdd a listener for texture coordinate generation mode changes.protected voidSet the fields of the binadble node that has the fields set based on the fields of the passed in node.protected voidfireLocalColorsChanged(boolean enabled) Send the localColorsChanged event to LocalColorsListenersGet the components that compose a geometry object.getFieldValue(int index) Get the value of a field.intGet the number of texture coordinate sets contained by this nodeintGet the primary type of this node.getTexCoordGenMode(int setNum) Get the texture coordinate generation mode.booleanCheck to see if the colors are per vertex or per face.booleanSpecified whether this node has alpha values in the local colour information.booleanSpecified whether this node has color information.booleanCheck to see if the normals are per vertex or per face.booleanisCCW()Get the value of the CCW field.booleanSpecifies whether this node requires lighting.booleanisSolid()Get the value of the solid field.voidRemove a listener for local color changes.voidRemove a listener for texture coordinate generation mode changes.booleanCheck to see if this geometry implementation type requires unlit color values to be set.voidsendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.protected voidNotification of the color node being set.voidsetComponent(VRMLNodeType comp) Set a component that composes part of a geometry object.voidsetComponents(VRMLNodeType[] comps) Set the components the compose a geometry object.protected voidNotification of the coordinate node being set.protected voidNotification of the coordinate node being set.protected voidNotification of the normal node being set.protected voidNotification of the texture coordinate node being set.voidsetTextureCount(int count) Set the number of textures that were found on the accompanying Appearance node.voidsetUnlitColor(float[] color) Set the local colour override for this geometry.voidNotification that the construction phase of this node has finished.voidsetValue(int index, boolean value) Set the value of the field at the given index as an boolean.voidsetValue(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, updateRefsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.web3d.vrml.nodes.FrameStateListener
allEventsCompleteMethods inherited from interface org.web3d.vrml.lang.VRMLNode
getFieldDeclaration, getFieldIndex, getNodeFieldIndices, getNumFields, getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersionMethods inherited from interface org.web3d.vrml.nodes.VRMLNodeComponentListener
fieldChangedMethods 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:
hasLocalColorsin 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:
hasLocalColorAlphain 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:
addLocalColorsListenerin interfaceVRMLGeometryNodeType- Parameters:
l- The listener.
-
removeLocalColorsListener
Remove a listener for local color changes. Nulls will be ignored.- Specified by:
removeLocalColorsListenerin interfaceVRMLGeometryNodeType- Parameters:
l- The listener.
-
addTexCoordGenModeChanged
Add a listener for texture coordinate generation mode changes. Nulls and duplicates will be ignored.- Specified by:
addTexCoordGenModeChangedin interfaceVRMLGeometryNodeType- Parameters:
l- The listener.
-
removeTexCoordGenModeChanged
Remove a listener for texture coordinate generation mode changes. Nulls will be ignored.- Specified by:
removeTexCoordGenModeChangedin 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:
setTextureCountin 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:
getNumSetsin 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:
getTexCoordGenModein 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:
isSolidin interfaceVRMLGeometryNodeType- Returns:
- true This object is solid (ie single sided)
-
isCCW
public boolean isCCW()Get the value of the CCW field.- Specified by:
isCCWin interfaceVRMLGeometryNodeType- Returns:
- true Vertices are declared in counter-clockwise order
-
isLightingEnabled
public boolean isLightingEnabled()Specifies whether this node requires lighting.- Specified by:
isLightingEnabledin 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:
getComponentsin 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:
setComponentsin 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:
setComponentin 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:
hasColorPerVertexin 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:
hasNormalPerVertexin 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:
requiresUnlitColorin 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:
setUnlitColorin 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:
getPrimaryTypein 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:
setupFinishedin interfaceVRMLNodeType- Overrides:
setupFinishedin 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:
getFieldValuein interfaceVRMLNodeType- Overrides:
getFieldValuein 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:
sendRoutein interfaceVRMLNodeType- Overrides:
sendRoutein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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.
-