Class BaseElevationGrid
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.geom3d.BaseElevationGrid
- All Implemented Interfaces:
VRMLNode,FrameStateListener,VRMLComponentGeometryNodeType,VRMLGeometryNodeType,VRMLNodeType
- Direct Known Subclasses:
NRElevationGrid,OGLElevationGrid
public abstract class BaseElevationGrid
extends AbstractNode
implements VRMLComponentGeometryNodeType
Common renderer-independent implementation of an ElevationGrid
TODO: Needed Listeners: solid Needed Observers: color, normal, texCoord
- Version:
- $Revision: 1.20 $
- Author:
- Alan Hudson
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intIndex of the ccw fieldprotected static final intIndex of the color fieldprotected static final intIndex of the colorPerVertex fieldprotected static final intIndex of the creaseAngle fieldprotected static final intIndex of the height fieldprotected static final intIndex of the normal fieldprotected static final intIndex of the normalPerVertex fieldprotected static final intIndex of the set_height fieldprotected static final intIndex of the solid fieldprotected static final intIndex of the texCoord fieldprotected static final intIndex of the xDimension fieldprotected static final intIndex of the xSpacing fieldprotected static final intIndex of the zDimension fieldprotected static final intIndex of the zSpacing fieldprotected intThe number of active items in the height fieldprotected 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 VRMLProtoInstanceProto version of the colorprotected VRMLProtoInstanceProto version of the normalprotected VRMLProtoInstanceProto version of the texCoordprotected booleanfield SFBool ccw TRUEprotected VRMLColorNodeTypeexposedField SFNode colorprotected booleanfield SFBool normalPerVertex TRUEprotected floatfield SFFloat creaseAngle 0protected float[]field MFFloat height []protected VRMLNormalNodeTypeexposedField SFNode normalprotected booleanfield SFBool normalPerVertex TRUEprotected booleanThe solid field valueprotected VRMLTextureCoordinateNodeTypeexposedField SFNode texCoordprotected intfield SFInt32 xDimension 0protected floatfield SFFloat xSpacing 0.0protected intfield SFInt32 zDimension 0protected floatfield SFFloat zSpacing 0.0Fields 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 node.protectedConstruct a new instance of this node based on the details from the given node. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a listener for local color changes.voidAdd a listener for texture coordinate generation mode changes.protected voidfireLocalColorsChanged(boolean enabled) Send the localColorsChanged event to LocalColorsListenersGet the components that compose a geometry object.getFieldDeclaration(int index) Get the declaration of the field at the given index.intgetFieldIndex(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).intGet the number of fields.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.voidsetComponent(VRMLNodeType comp) Set a component that composes part of a geometry object.voidsetComponents(VRMLNodeType[] comps) Set the components that compose a geometry object.protected voidsetHeight(float[] value, int numValid) Set the height field.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 a float.voidsetValue(int index, float value) Set the value of the field at the given index as a float.voidsetValue(int index, float[] value, int numValid) Set the value of the field at the given index as an array of floats.voidsetValue(int index, int value) Set the value of the field at the given index as an int.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, 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
getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersionMethods 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, updateRefCount
-
Field Details
-
FIELD_SET_HEIGHT
protected static final int FIELD_SET_HEIGHTIndex of the set_height field- See Also:
-
FIELD_COLOR
protected static final int FIELD_COLORIndex of the color field- See Also:
-
FIELD_NORMAL
protected static final int FIELD_NORMALIndex of the normal field- See Also:
-
FIELD_TEXCOORD
protected static final int FIELD_TEXCOORDIndex of the texCoord 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_CREASEANGLE
protected static final int FIELD_CREASEANGLEIndex of the creaseAngle field- See Also:
-
FIELD_HEIGHT
protected static final int FIELD_HEIGHTIndex of the height field- See Also:
-
FIELD_NORMALPERVERTEX
protected static final int FIELD_NORMALPERVERTEXIndex of the normalPerVertex field- See Also:
-
FIELD_SOLID
protected static final int FIELD_SOLIDIndex of the solid field- See Also:
-
FIELD_XDIMENSION
protected static final int FIELD_XDIMENSIONIndex of the xDimension field- See Also:
-
FIELD_XSPACING
protected static final int FIELD_XSPACINGIndex of the xSpacing field- See Also:
-
FIELD_ZDIMENSION
protected static final int FIELD_ZDIMENSIONIndex of the zDimension field- See Also:
-
FIELD_ZSPACING
protected static final int FIELD_ZSPACINGIndex of the zSpacing field- See Also:
-
LAST_ELEVATIONGRID_INDEX
protected static final int LAST_ELEVATIONGRID_INDEXThe last field index used by this class- See Also:
-
pColor
Proto version of the color -
vfColor
exposedField SFNode color -
pNormal
Proto version of the normal -
vfNormal
exposedField SFNode normal -
pTexCoord
Proto version of the texCoord -
vfTexCoord
exposedField SFNode texCoord -
vfCcw
protected boolean vfCcwfield SFBool ccw TRUE -
vfHeight
protected float[] vfHeightfield MFFloat height [] -
heightLen
protected int heightLenThe number of active items in the height field -
vfCreaseAngle
protected float vfCreaseAnglefield SFFloat creaseAngle 0 -
vfColorPerVertex
protected boolean vfColorPerVertexfield SFBool normalPerVertex TRUE -
vfNormalPerVertex
protected boolean vfNormalPerVertexfield SFBool normalPerVertex TRUE -
vfSolid
protected boolean vfSolidThe solid field value -
vfXDimension
protected int vfXDimensionfield SFInt32 xDimension 0 -
vfXSpacing
protected float vfXSpacingfield SFFloat xSpacing 0.0 -
vfZDimension
protected int vfZDimensionfield SFInt32 zDimension 0 -
vfZSpacing
protected float vfZSpacingfield SFFloat zSpacing 0.0 -
localColors
protected boolean localColorsShould local color node be used for diffuse lighting -
localColorsListeners
The list of listeners for localColor changes
-
-
Constructor Details
-
BaseElevationGrid
protected BaseElevationGrid()Construct a default instance of this node. -
BaseElevationGrid
Construct a new instance of this node based on the details from the given node. If the node is not the same type, an exception will be thrown.- Parameters:
node- The node to copy- Throws:
IllegalArgumentException- Incorrect Node Type
-
-
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.
-
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
-
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:
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
-
isSolid
public boolean isSolid()Description copied from interface:VRMLGeometryNodeTypeGet 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
-
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
-
getComponents
Get the components that compose a geometry object.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 that compose a geometry object.- Specified by:
setComponentsin interfaceVRMLComponentGeometryNodeType- Parameters:
comps- An array of geometric properties- Throws:
InvalidFieldValueException- The node does not match the required type.
-
setComponent
Set a component that composes part of a geometry object.- Specified by:
setComponentin interfaceVRMLComponentGeometryNodeType- Parameters:
comp- A geometric property- Throws:
InvalidFieldValueException- The node does not match the required 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
-
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:
getFieldIndexin 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:
getNodeFieldIndicesin 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:
getFieldDeclarationin 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:
getNumFieldsin 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:
getPrimaryTypein 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:
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 a float. This would be used to set SFFloat 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 index is not a valid fieldInvalidFieldValueException- The field value is not legal for the field specified.
-
setValue
Set the value of the field at the given index as an int. This would be used to set SFInt32 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 index is not a valid fieldInvalidFieldValueException- The field value is not legal for the field specified.
-
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:
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 index is not a valid fieldInvalidFieldValueException- The field value is not legal for the field specified.
-
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 MFDouble, SFVec2d, SFVec3d etc 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 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
-
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.
-
fireLocalColorsChanged
protected void fireLocalColorsChanged(boolean enabled) Send the localColorsChanged event to LocalColorsListeners- Parameters:
enabled- Whether local colors are used.
-
setHeight
protected void setHeight(float[] value, int numValid) Set the height field.- Parameters:
value- The new valuenumValid- The number of valid entries
-