Class BaseGeoLOD
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.BaseGroupingNode
org.web3d.vrml.renderer.common.nodes.geospatial.BaseGeoLOD
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLBoundedNodeType
,VRMLChildNodeType
,VRMLExternalNodeType
,VRMLGroupingNodeType
,VRMLMultiExternalNodeType
,VRMLNodeType
,VRMLViewDependentNodeType
,VRMLWorldRootChildNodeType
,OriginListener
public abstract class BaseGeoLOD
extends BaseGroupingNode
implements VRMLViewDependentNodeType, VRMLMultiExternalNodeType, OriginListener
Common base implementation of a GeoLOD node.
Internally the LOD keeps both the basic range and the values squared. This makes computation much faster, eliminating the need to take expensive square-roots each frame. The basic (X3D) definition of GeoLOD is:
GeoLOD : X3DGroupingNode { SFNode [in,out] metadata NULL [X3DMetadataObject] MFNode [out] children [] [X3DChildNode] SFInt32 [out] level_changed SFVec3d [] center 0 0 0 (-inf,inf) MFString [] child1Url [] [urn] MFString [] child2Url [] [urn] MFString [] child3Url [] [urn] MFString [] child4Url [] [urn] MFNode [] geoOrigin NULL [GeoOrigin] MFString [] geoSystem ["GD",WE"] SFFloat [] range 10 [0,inf) MFString [] rootUrl [] [urn] MFNode [] rootNode NULL [X3DChildNode] SFVec3f [] bboxCenter 0 0 0 (-inf,inf) SFVec3f [] bboxSize -1 -1 -1 [0,inf) or -1 -1 -1 SFBool bboxDisplay FALSE }
- Version:
- $Revision: 1.18 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected double[]
The tile center coordinate, in gccprotected boolean
The index of the currently active objectprotected VRMLScene[]
The scenes that represents the childXUrl after loading.protected static final int
Index of the center fieldprotected static final int
Index of the child1Url fieldprotected static final int
Index of the child2Url fieldprotected static final int
Index of the child3Url fieldprotected static final int
Index of the child4Url fieldprotected static final int
Index of the geoOrigin fieldprotected static final int
Index of the geoSystem fieldprotected static final int
The index of the level_changed fieldprotected static final int
The index of the range fieldprotected static final int
Index of the rootNode fieldprotected static final int
Index of the rootUrl fieldprotected static final int
The last field index used by this classprotected SceneWrapper[]
The scene wrappers for loaded scenesprotected String[]
List of loaded URI stringsprotected int[]
The state of the load for the various fieldsprotected double[]
The origin in useprotected double[]
Local version of the center position post coord conversionprotected VRMLNodeType[]
Internal scratch var for dealing with added/removed childrenprotected static final int
Number of fields constantprotected OriginManager
Manager for precision controlprotected VRMLProtoInstance
Proto version of the geoOriginprotected VRMLScene
The main scene that represents the rootUrl after loading.protected SceneWrapper
The scene wrapper for the rootprotected boolean
Flag to indicate if we've checked the URLs for relative referencesprotected boolean
Flag indicating that the OriginManager is enabledprotected double[]
field SFVec3d centerprotected String[]
field MFString child1Urlprotected String[]
field MFString child2Urlprotected String[]
field MFString child3Urlprotected String[]
field MFString child4Urlprotected VRMLNodeType
field SFNode geoOriginprotected String[]
field MFString geoSystem ["GD","WE"]protected int
The value of the outputOnly field level_changedprotected float
field SFFloat rangeprotected List
<VRMLNodeType> field MFNode rootNodeprotected String[]
field MFString rootUrlprotected String
The world URL for correcting relative URL valuesFields inherited from class org.web3d.vrml.renderer.common.nodes.BaseGroupingNode
childCount, FIELD_ADDCHILDREN, FIELD_BBOX_CENTER, FIELD_BBOX_DISPLAY, FIELD_BBOX_SIZE, FIELD_CHILDREN, FIELD_REMOVECHILDREN, FIELD_VISIBLE, hasBindables, LAST_GROUP_INDEX, shareCount, USE_BIND_MSG, vfBboxCenter, vfBboxDisplay, vfBboxSize, vfChildren, vfVisible
Fields inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
errorReporter, FIELD_METADATA, fieldLocalData, hasChanged, inSetup, isDEF, isStatic, LAST_NODE_INDEX, layerIds, nodeName, pMetadata, refCounts, removedLayerIds, stateManager, STATIC_SCENE_GRAPH, vfMetadata, vrmlMajorVersion, vrmlMinorVersion
Fields inherited from interface org.web3d.vrml.nodes.VRMLExternalNodeType
LOAD_COMPLETE, LOAD_FAILED, LOADING, NOT_LOADED
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Construct a default instance of this node.protected
BaseGeoLOD
(VRMLNodeType node) Construct a new instance of this node based on the details from the given node. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener to this node instance for the content state changes.protected void
addRootNode
(VRMLNodeType node) Add a single child node to the list of available children.void
Add a listener to this node instance.boolean
checkValidContentType
(int index, String mimetype) Check to see if the given MIME type is one that would be supported as content coming into this node.protected void
Clear the child node list of all children in the VRML node.protected void
fireContentStateChanged
(int index) Send a notification to the registered listeners that the content state has been changed.protected void
fireUrlChanged
(int index) Send a notification to the registered listeners that a field has been changed.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
getLoadState
(int index) Ask the state of the load of this node.int[]
Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode).int
Get the number of fields.Class[]
getPreferredClassTypes
(int index) Get the list of preferred content class types in order of preference.int[]
Get the secondary type of this node.String[]
getUrl
(int index) Get the list of URI's currently registered with this node for the given field index.int[]
Get the list of field index values that require external content.Get the world URL so set for this node.protected void
loadScene
(boolean children) Load a scene into memory.void
Notification that the origin has changed.void
Remove a listener from this node instance for the content state changes.void
Remove a listener from this node instance.void
setLoadedURI
(int fieldIdx, String uri) Notify the node which URL was used to load the content.void
setLoadState
(int index, int state) Set the load state of the node.void
setShared
(boolean used) Adjust the sharing count up or down one increment depending on the flag.void
Notification that the construction phase of this node has finished.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 an array of floats.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.void
setValue
(int index, VRMLNodeType[] children, int numValid) Set the value of the field at the given index as an array of nodes.void
setWorldUrl
(String url) Set the world URL so that any relative URLs may be corrected to the fully qualified version.void
updateRefCount
(int layer, boolean add) Change the reference count up or down by one for a given layer ID.Methods inherited from class org.web3d.vrml.renderer.common.nodes.BaseGroupingNode
addChild, addChildNode, clearChildren, containsBindableNodes, copy, getBboxCenter, getBboxDisplay, getBboxSize, getChildren, getChildrenSize, getPrimaryType, getVisible, isShared, removeChildNode, sendRoute, setBboxCenter, setBboxDisplay, setBboxSize, setChildren, setChildren, setDEF, setValue, setValue, setVisible
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, setErrorReporter, setFrameStateManager, setMetadataObject, setUserData, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setVersion, throwInitOnlyWriteException, throwInputOnlyWriteException, throwInvalidNodeException, throwInvalidProtoException, throwOutputOnlyWriteException, 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.nodes.VRMLMultiExternalNodeType
setContent
Methods inherited from interface org.web3d.vrml.lang.VRMLNode
getPrimaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersion
Methods inherited from interface org.web3d.vrml.nodes.VRMLNodeType
addNodeListener, clearRemovedLayerIds, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, hasFieldChanged, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, sendRoute, setDEF, setFrameStateManager, setMetadataObject, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue
-
Field Details
-
FIELD_ROOT_NODE
protected static final int FIELD_ROOT_NODEIndex of the rootNode field- See Also:
-
FIELD_ROOT_URL
protected static final int FIELD_ROOT_URLIndex of the rootUrl field- See Also:
-
FIELD_CHILD1_URL
protected static final int FIELD_CHILD1_URLIndex of the child1Url field- See Also:
-
FIELD_CHILD2_URL
protected static final int FIELD_CHILD2_URLIndex of the child2Url field- See Also:
-
FIELD_CHILD3_URL
protected static final int FIELD_CHILD3_URLIndex of the child3Url field- See Also:
-
FIELD_CHILD4_URL
protected static final int FIELD_CHILD4_URLIndex of the child4Url 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_CENTER
protected static final int FIELD_CENTERIndex of the center field- See Also:
-
FIELD_RANGE
protected static final int FIELD_RANGEThe index of the range field- See Also:
-
FIELD_LEVEL_CHANGED
protected static final int FIELD_LEVEL_CHANGEDThe index of the level_changed field- See Also:
-
LAST_LOD_INDEX
protected static final int LAST_LOD_INDEXThe last field index used by this class- See Also:
-
NUM_FIELDS
protected static final int NUM_FIELDSNumber of fields constant- See Also:
-
vfCenter
protected double[] vfCenterfield SFVec3d center -
vfRange
protected float vfRangefield SFFloat range -
vfChild1Url
field MFString child1Url -
vfChild2Url
field MFString child2Url -
vfChild3Url
field MFString child3Url -
vfChild4Url
field MFString child4Url -
vfRootUrl
field MFString rootUrl -
vfGeoSystem
field MFString geoSystem ["GD","WE"] -
pGeoOrigin
Proto version of the geoOrigin -
vfGeoOrigin
field SFNode geoOrigin -
vfRootNode
field MFNode rootNode -
vfLevelChanged
protected int vfLevelChangedThe value of the outputOnly field level_changed -
nodeTmp
Internal scratch var for dealing with added/removed children -
localCenter
protected double[] localCenterLocal version of the center position post coord conversion -
worldURL
The world URL for correcting relative URL values -
urlRelativeCheck
protected boolean urlRelativeCheckFlag to indicate if we've checked the URLs for relative references -
loadState
protected int[] loadStateThe state of the load for the various fields -
childrenShown
protected boolean childrenShownThe index of the currently active object -
loadedUri
List of loaded URI strings -
childScenes
The scenes that represents the childXUrl after loading. -
loadedScenes
The scene wrappers for loaded scenes -
rootScene
The main scene that represents the rootUrl after loading. -
rootSceneWrapper
The scene wrapper for the root -
originManager
Manager for precision control -
useOriginManager
protected boolean useOriginManagerFlag indicating that the OriginManager is enabled -
local_origin
protected double[] local_originThe origin in use -
center
protected double[] centerThe tile center coordinate, in gcc
-
-
Constructor Details
-
BaseGeoLOD
protected BaseGeoLOD()Construct a default instance of this node. The defaults are set by the VRML specification. -
BaseGeoLOD
Construct a new instance of this node based on the details from the given node. If the node is not a group node, an exception will be thrown. It does not copy the children nodes, just this node.- Parameters:
node
- The node to copy- Throws:
IllegalArgumentException
- The node is not a Group node
-
-
Method Details
-
updateRefCount
public void updateRefCount(int layer, boolean add) Change the reference count up or down by one for a given layer ID. If there is no reference to the given layer ID previously, add one now. A listing of the layer IDs that reference this node can be retrieved throughAbstractNode.getLayerIds()
.- Specified by:
updateRefCount
in interfaceVRMLNodeType
- Overrides:
updateRefCount
in classBaseGroupingNode
- Parameters:
layer
- The id of the layer to modify the ref count onadd
- true to increment the reference count, false to decrement
-
getUrlFieldIndexes
public int[] getUrlFieldIndexes()Get the list of field index values that require external content. These will be used to query for the URL values later.- Specified by:
getUrlFieldIndexes
in interfaceVRMLMultiExternalNodeType
- Returns:
- A list of field indexes requiring textures
-
getUrl
Get the list of URI's currently registered with this node for the given field index.- Specified by:
getUrl
in interfaceVRMLMultiExternalNodeType
- Parameters:
index
- The field index we want the URLs for- Returns:
- The list of URLs at that index
- Throws:
InvalidFieldException
- The index does not match something with URLs.
-
getLoadState
public int getLoadState(int index) Ask the state of the load of this node. The value will be one of the constants defined above.- Specified by:
getLoadState
in interfaceVRMLMultiExternalNodeType
- Parameters:
index
- The field index we want to set the state for- Returns:
- The current load state of the node
-
setLoadState
public void setLoadState(int index, int state) Set the load state of the node. The value must be one of the constants defined above.- Specified by:
setLoadState
in interfaceVRMLMultiExternalNodeType
- Parameters:
index
- The field index we want to set the state for.state
- The new state of the node
-
checkValidContentType
Check to see if the given MIME type is one that would be supported as content coming into this node. As all external types are images, we always report the same type here.- Specified by:
checkValidContentType
in interfaceVRMLMultiExternalNodeType
- Parameters:
index
- The field index we want to check content type for.mimetype
- The type to check for- Returns:
- true if this is OK, false if not
-
getPreferredClassTypes
Get the list of preferred content class types in order of preference. As all types are images, this always returns the image class types.- Specified by:
getPreferredClassTypes
in interfaceVRMLMultiExternalNodeType
- Parameters:
index
- THe field index for the preferred types.- Returns:
- A list of preferred class types
- Throws:
InvalidFieldException
- The field index is not valid for the query
-
setLoadedURI
Notify the node which URL was used to load the content. It will be the complete URI with path, query and references parts. This method will be called before setContent.- Specified by:
setLoadedURI
in interfaceVRMLMultiExternalNodeType
- Parameters:
fieldIdx
- The field index that was loadeduri
- The URI used to load this content
-
addUrlListener
Add a listener to this node instance. If the listener is already added or null the request is silently ignored.- Specified by:
addUrlListener
in interfaceVRMLExternalNodeType
- Parameters:
ul
- The listener instance to add
-
removeUrlListener
Remove a listener from this node instance. If the listener is null or not registered, the request is silently ignored.- Specified by:
removeUrlListener
in interfaceVRMLExternalNodeType
- Parameters:
ul
- The listener to be removed
-
addContentStateListener
Add a listener to this node instance for the content state changes. If the listener is already added or null the request is silently ignored.- Specified by:
addContentStateListener
in interfaceVRMLExternalNodeType
- Parameters:
l
- The listener instance to add
-
removeContentStateListener
Remove a listener from this node instance for the content state changes. If the listener is null or not registered, the request is silently ignored.- Specified by:
removeContentStateListener
in interfaceVRMLExternalNodeType
- Parameters:
l
- The listener to be removed
-
setWorldUrl
Set the world URL so that any relative URLs may be corrected to the fully qualified version. Guaranteed to be non-null.- Specified by:
setWorldUrl
in interfaceVRMLExternalNodeType
- Parameters:
url
- The world URL.
-
getWorldUrl
Get the world URL so set for this node.- Specified by:
getWorldUrl
in interfaceVRMLExternalNodeType
- Returns:
- url The world URL.
-
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 classBaseGroupingNode
-
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.
-
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 classBaseGroupingNode
- Parameters:
index
- The index of the field to change.- Returns:
- The class representing the field value
- Throws:
InvalidFieldException
- The field index is not known
-
setValue
public void setValue(int index, float value) throws InvalidFieldException, InvalidFieldValueException 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 node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is not in range or not appropriate for this field
-
setValue
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 known
-
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 classBaseGroupingNode
- 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.
-
setValue
public void setValue(int index, VRMLNodeType[] children, int numValid) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an array of nodes. This would be used to set MFNode field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classBaseGroupingNode
- Parameters:
index
- The index of destination field to setchildren
- 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
-
originChanged
public void originChanged()Notification that the origin has changed.- Specified by:
originChanged
in interfaceOriginListener
-
clearRootNodes
protected void clearRootNodes()Clear the child node list of all children in the VRML node. Override to provide.renderer-specific behaviour, but remember to also call this implementation too. -
addRootNode
Add a single child node to the list of available children. Override to provide.renderer-specific behaviour, but remember to also call this implementation too.- Parameters:
node
- The node to add- Throws:
InvalidFieldValueException
- This is a bindable node shared
-
fireUrlChanged
protected void fireUrlChanged(int index) Send a notification to the registered listeners that a field has been changed. If no listeners have been registered, then this does nothing, so always call it regardless.- Parameters:
index
- The index of the field that changed
-
fireContentStateChanged
protected void fireContentStateChanged(int index) Send a notification to the registered listeners that the content state has been changed. If no listeners have been registered, then this does nothing, so always call it regardless.- Parameters:
index
- The index of the field that changed
-
loadScene
Load a scene into memory. This will either be the root or the children.- Parameters:
children
- True if loading the children, false for the root.- Throws:
IllegalArgumentException