Class BaseGeoElevationGrid
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.geospatial.BaseGeoElevationGrid
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLComponentGeometryNodeType
,VRMLGeometryNodeType
,VRMLNodeType
- Direct Known Subclasses:
NRGeoElevationGrid
,OGLGeoElevationGrid
Common renderer-independent implementation of a GeoElevationGrid
TODO: Needed Listeners: solid Needed Observers: color, normal, texCoord
- Version:
- $Revision: 1.15 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
Index of the ccw fieldprotected static final int
Index of the color fieldprotected static final int
Index of the colorPerVertex fieldprotected static final int
Index of the creaseAngle fieldprotected static final int
Index of the geoGridOrigin fieldprotected static final int
Index of the geoOrigin fieldprotected static final int
Index of the geoSystem fieldprotected static final int
Index of the height fieldprotected static final int
Index of the normal fieldprotected static final int
Index of the normalPerVertex fieldprotected static final int
Index of the set_height fieldprotected static final int
Index of the solid fieldprotected static final int
Index of the texCoord fieldprotected static final int
Index of the xDimension fieldprotected static final int
Index of the xSpacing fieldprotected static final int
Index of the yScale fieldprotected static final int
Index of the zDimension fieldprotected static final int
Index of the zSpacing fieldprotected boolean
Flag to say if the translation geo coords need to be swapped before conversion.protected org.opengis.referencing.operation.MathTransform
Transformation used to make the coordinates to the local system.protected int
The number of active items in the height fieldprotected static final int
The last field index used by this classprotected double[]
The origin in useprotected boolean
Should local color node be used for diffuse lightingprotected List
<LocalColorsListener> The list of listeners for localColor changesprotected double[]
The calculated local version of the points taking into account both the projection information and the GeoOrigin setting.protected OriginManager
Manager for precision controlprotected VRMLProtoInstance
Proto version of the colorprotected VRMLProtoInstance
Proto version of the geoOriginprotected VRMLProtoInstance
Proto version of the normalprotected VRMLProtoInstance
Proto version of the texCoordprotected static final String
Message when the mathTransform.transform() failsprotected boolean
Flag indicating that the OriginManager is enabledprotected boolean
field SFBool ccw TRUEprotected VRMLColorNodeType
exposedField SFNode colorprotected boolean
field SFBool normalPerVertex TRUEprotected double
field SFDouble creaseAngle 0protected double[]
field MFDouble geoGridOrigin 0 0 0protected VRMLNodeType
field SFNode geoOriginprotected String[]
field MFString geoSystem ["GD","WE"]protected double[]
field MFDouble height []protected VRMLNormalNodeType
exposedField SFNode normalprotected boolean
field SFBool normalPerVertex TRUEprotected boolean
The solid field valueprotected VRMLTextureCoordinateNodeType
exposedField SFNode texCoordprotected int
field SFInt32 xDimension 0protected double
field SFDouble xSpacing 0.0protected float
field SFFloat yScale 1.0protected int
field SFInt32 zDimension 0protected double
field SFDouble 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
ConstructorsConstructorDescriptionConstruct a default instance of this 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.protected void
fireLocalColorsChanged
(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.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.int[]
Get the secondary 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.void
setComponent
(VRMLNodeType comp) Set a component that composes part of a geometry object.void
setComponents
(VRMLNodeType[] comps) Set the components that compose a geometry object.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 a float.void
setValue
(int index, double value) Set the value of the field at the given index as a float.void
setValue
(int index, double[] value, int numValid) Set the value of the field at the given index as an array of floats.void
setValue
(int index, float value) Set the value of the field at the given index as a float.void
setValue
(int index, int value) Set the value of the field at the given index as an int.void
Set the value of the field at the given index as an array of strings.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, getUserData, getVRMLNodeName, hasFieldChanged, isDEF, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setErrorReporter, setFrameStateManager, setMetadataObject, setUserData, 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
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, setDEF, setFrameStateManager, setMetadataObject, 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_GEO_GRID_ORIGIN
protected static final int FIELD_GEO_GRID_ORIGINIndex of the geoGridOrigin field- See Also:
-
FIELD_GEO_ORIGIN
protected static final int FIELD_GEO_ORIGINIndex of the geoOrigin field- See Also:
-
FIELD_GEO_SYSTEM
protected static final int FIELD_GEO_SYSTEMIndex of the geoSystem 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:
-
FIELD_YSCALE
protected static final int FIELD_YSCALEIndex of the yScale field- See Also:
-
LAST_ELEVATIONGRID_INDEX
protected static final int LAST_ELEVATIONGRID_INDEXThe last field index used by this class- See Also:
-
TRANSFORM_ERR_MSG
Message when the mathTransform.transform() fails- 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 double[] vfHeightfield MFDouble height [] -
heightLen
protected int heightLenThe number of active items in the height field -
vfCreaseAngle
protected double vfCreaseAnglefield SFDouble 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 double vfXSpacingfield SFDouble xSpacing 0.0 -
vfZDimension
protected int vfZDimensionfield SFInt32 zDimension 0 -
vfZSpacing
protected double vfZSpacingfield SFDouble zSpacing 0.0 -
vfYScale
protected float vfYScalefield SFFloat yScale 1.0 -
vfGeoGridOrigin
protected double[] vfGeoGridOriginfield MFDouble geoGridOrigin 0 0 0 -
vfGeoSystem
field MFString geoSystem ["GD","WE"] -
pGeoOrigin
Proto version of the geoOrigin -
vfGeoOrigin
field SFNode geoOrigin -
localCoords
protected double[] localCoordsThe calculated local version of the points taking into account both the projection information and the GeoOrigin setting. -
geoTransform
protected org.opengis.referencing.operation.MathTransform geoTransformTransformation used to make the coordinates to the local system. Does not include the geoOrigin offset calcs. -
geoCoordSwap
protected boolean geoCoordSwapFlag to say if the translation geo coords need to be swapped before conversion. -
localColors
protected boolean localColorsShould local color node be used for diffuse lighting -
localColorsListeners
The list of listeners for localColor changes -
originManager
Manager for precision control -
useOriginManager
protected boolean useOriginManagerFlag indicating that the OriginManager is enabled -
local_origin
protected double[] local_originThe origin in use
-
-
Constructor Details
-
BaseGeoElevationGrid
public BaseGeoElevationGrid()Construct a default instance of this node. -
BaseGeoElevationGrid
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:
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()Description copied from interface:VRMLGeometryNodeType
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
-
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
-
getComponents
Get the components that compose a geometry object.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 that compose a geometry object.- Specified by:
setComponents
in 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:
setComponent
in 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:
setupFinished
in interfaceVRMLNodeType
- Overrides:
setupFinished
in 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:
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
-
getSecondaryType
public int[] getSecondaryType()Get the secondary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getSecondaryType
in interfaceVRMLNode
- Overrides:
getSecondaryType
in classAbstractNode
- Returns:
- The secondary 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
-
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 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 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:
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 index is not a valid fieldInvalidFieldValueException
- The field value is not legal for the field specified.
-
setValue
public void setValue(int index, double value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a float. This would be used to set SFDouble and SFTime 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 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:
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 index is not a valid fieldInvalidFieldValueException
- The field value is not legal for the field specified.
-
setValue
public void setValue(int index, double[] 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
-
setValue
public void setValue(int index, String[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an array of strings. This would be used to set the MFString field type "type".- 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 knowInvalidFieldValueException
- The value provided is not in range or not appropriate for this fieldInvalidFieldAccessException
- 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:
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.
-
fireLocalColorsChanged
protected void fireLocalColorsChanged(boolean enabled) Send the localColorsChanged event to LocalColorsListeners- Parameters:
enabled
- Whether local colors are used.
-