Class BaseNavigationInfo
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.BaseBindableNode
org.web3d.vrml.renderer.common.nodes.navigation.BaseNavigationInfo
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLBindableNodeType
,VRMLChildNodeType
,VRMLNavigationInfoNodeType
,VRMLNodeType
,VRMLTimeDependentNodeType
,VRMLWorldRootChildNodeType
- Direct Known Subclasses:
NRNavigationInfo
,OGLNavigationInfo
public abstract class BaseNavigationInfo
extends BaseBindableNode
implements VRMLNavigationInfoNodeType
Common base implementation of a NavigationInfo node.
- Version:
- $Revision: 1.25 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List
<NavigationInfoChangeListener> The listener for navigation info changesprotected static final int
Index of the avatarSize fieldprotected static final int
Index of the headlight fieldprotected static final int
Index of the speed fieldprotected static final int
Index of the transitionTime fieldprotected static final int
Index of the transitionType fieldprotected static final int
Index of the type fieldprotected static final int
Index of the visibilityLimit fieldprotected static final int
The last field index used by this classprotected static final int
Number of fields constantprotected int
The number of active items in the avatar size fieldprotected int
The number of active items in the transitionType fieldprotected int
The number of active items in the type fieldprotected float[]
SFFloat list of avatar informationprotected boolean
SFBool indicating if the headlight should be onprotected float
SFFloat current speed we are to travel through the world atprotected float[]
SFFloat list of transition time informationprotected String[]
MFString of the way to transition between viewpointsprotected String[]
MFString of the different navigation modes to useprotected float
SFFloat Culling visibility limitFields inherited from class org.web3d.vrml.renderer.common.nodes.BaseBindableNode
FIELD_BIND, FIELD_BIND_TIME, FIELD_IS_BOUND, isOnStack, LAST_BINDABLE_INDEX, vfBindTime, vfIsBound
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.VRMLNavigationInfoNodeType
NAV_TYPE_ANY, NAV_TYPE_EXAMINE, NAV_TYPE_FLY, NAV_TYPE_LOOKAT, NAV_TYPE_NONE, NAV_TYPE_WALK, TRANSITION_TYPE_ANIMATE, TRANSITION_TYPE_LINEAR, TRANSITION_TYPE_TELEPORT
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Construct a default node with all of the values set to the given types.protected
Construct a new instance of this node based on the details from the given node. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener for navigation info changes.float[]
Get the dimensions of the avatar in use.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.boolean
Get the status of the headlight that we are operating with.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 valid navigation types in the result from getType().int
Get the primary type of this node.float
getSpeed()
Get the speed that we are currently moving at.String[]
getType()
Get the list of navigation types that are to be used.float
Get the visibility limit that we are currently operating at.void
Remove the listener for navigation info changes.void
sendRoute
(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.void
setAvatarSize
(float[] size, int numValid) Set the dimensions of the avatar in use.void
setHeadlight
(boolean enable) Set the statte of the headlight to the new value.void
setSpeed
(float newSpeed) Set the speed to move at.void
setTransitionType
(String[] types, int numValid) Set the transition type to the new value(s).void
Set the navigation type to the new value(s).void
setValue
(int index, boolean value) Set the value of the field at the given index as an boolean.void
setValue
(int index, float value) Set the value of the field at the given index as a float.void
setValue
(int index, float[] value, int numValid) 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
setVersion
(int major, int minor, boolean isStatic) Set the version of VRML that this node should represent.void
setVisibilityLimit
(float limit) Set the visibility limie to move at.void
setWorldLocation
(javax.vecmath.Vector3f wcpos) Sets the current position in world coordinates.Methods inherited from class org.web3d.vrml.renderer.common.nodes.BaseBindableNode
addBindableNodeListener, copy, fireIsBoundChanged, getBindTime, getIsBound, getSecondaryType, removeBindableNodeListener, setBind, setOnStack, setVRMLClock
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, setupFinished, setUserData, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, 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.nodes.VRMLBindableNodeType
addBindableNodeListener, getBindTime, getIsBound, removeBindableNodeListener, setBind, setOnStack
Methods inherited from interface org.web3d.vrml.lang.VRMLNode
getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData
Methods inherited from interface org.web3d.vrml.nodes.VRMLNodeType
addNodeListener, clearRemovedLayerIds, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, hasFieldChanged, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setFrameStateManager, setMetadataObject, setupFinished, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Field Details
-
FIELD_AVATAR_SIZE
protected static final int FIELD_AVATAR_SIZEIndex of the avatarSize field- See Also:
-
FIELD_HEADLIGHT
protected static final int FIELD_HEADLIGHTIndex of the headlight field- See Also:
-
FIELD_SPEED
protected static final int FIELD_SPEEDIndex of the speed field- See Also:
-
FIELD_TYPE
protected static final int FIELD_TYPEIndex of the type field- See Also:
-
FIELD_VISIBILITY_LIMIT
protected static final int FIELD_VISIBILITY_LIMITIndex of the visibilityLimit field- See Also:
-
FIELD_TRANSITION_TYPE
protected static final int FIELD_TRANSITION_TYPEIndex of the transitionType field- See Also:
-
FIELD_TRANSITION_TIME
protected static final int FIELD_TRANSITION_TIMEIndex of the transitionTime field- See Also:
-
LAST_NAVINFO_INDEX
protected static final int LAST_NAVINFO_INDEXThe last field index used by this class- See Also:
-
NUM_FIELDS
protected static final int NUM_FIELDSNumber of fields constant- See Also:
-
vfAvatarSize
protected float[] vfAvatarSizeSFFloat list of avatar information -
vfTransitionTime
protected float[] vfTransitionTimeSFFloat list of transition time information -
numAvatarSize
protected int numAvatarSizeThe number of active items in the avatar size field -
vfHeadlight
protected boolean vfHeadlightSFBool indicating if the headlight should be on -
vfSpeed
protected float vfSpeedSFFloat current speed we are to travel through the world at -
vfType
MFString of the different navigation modes to use -
vfTransitionType
MFString of the way to transition between viewpoints -
numType
protected int numTypeThe number of active items in the type field -
numTransitionType
protected int numTransitionTypeThe number of active items in the transitionType field -
vfVisibilityLimit
protected float vfVisibilityLimitSFFloat Culling visibility limit -
changeListener
The listener for navigation info changes
-
-
Constructor Details
-
BaseNavigationInfo
protected BaseNavigationInfo()Construct a default node with all of the values set to the given types. -
BaseNavigationInfo
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
-
getType
Get the list of navigation types that are to be used. It may contain some or all of the constants above. The array will always be non-null.- Specified by:
getType
in interfaceVRMLNavigationInfoNodeType
- Returns:
- The list of navigation types set
-
getNumTypes
public int getNumTypes()Get the number of valid navigation types in the result from getType().- Specified by:
getNumTypes
in interfaceVRMLNavigationInfoNodeType
- Returns:
- The number of elements in getType().
-
setWorldLocation
public void setWorldLocation(javax.vecmath.Vector3f wcpos) Sets the current position in world coordinates.- Specified by:
setWorldLocation
in interfaceVRMLNavigationInfoNodeType
- Parameters:
wcpos
- Location of the user in world coordinates(x,y,z)
-
setType
Set the navigation type to the new value(s). The array must be non-null. If the underlying implementation does not support any of the types requested, it shall default to the type NONE. If the array is empty, it defaults to NONE.- Specified by:
setType
in interfaceVRMLNavigationInfoNodeType
- Parameters:
types
- The list of types to now use in order of preferencenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldValueException
- The list was null or empty
-
setTransitionType
Set the transition type to the new value(s). The array must be non-null. If the underlying implementation does not support any of the types requested, it shall default to the type LINEAR. If the array is empty, it defaults to LINEAR.- Parameters:
types
- The list of types to now use in order of preferencenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldValueException
- The list was null or empty
-
getAvatarSize
public float[] getAvatarSize()Get the dimensions of the avatar in use.- Specified by:
getAvatarSize
in interfaceVRMLNavigationInfoNodeType
- Returns:
- A list of floats describing the dimension of the avatar.
-
setAvatarSize
Set the dimensions of the avatar in use. The array must have at least three values in it as required by the specification.- Specified by:
setAvatarSize
in interfaceVRMLNavigationInfoNodeType
- Parameters:
size
- The new size values to usenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldValueException
- The array did not contain 3 values
-
getSpeed
public float getSpeed()Get the speed that we are currently moving at.- Specified by:
getSpeed
in interfaceVRMLNavigationInfoNodeType
- Returns:
- The current movement speed.
-
setSpeed
Set the speed to move at. The speed value must be non-negative.- Specified by:
setSpeed
in interfaceVRMLNavigationInfoNodeType
- Parameters:
newSpeed
- The new speed value to use- Throws:
InvalidFieldValueException
- The speed was negative
-
getVisibilityLimit
public float getVisibilityLimit()Get the visibility limit that we are currently operating at.- Specified by:
getVisibilityLimit
in interfaceVRMLNavigationInfoNodeType
- Returns:
- The current movement visibility limit.
-
setVisibilityLimit
Set the visibility limie to move at. The visibility limit value must be non-negative.- Specified by:
setVisibilityLimit
in interfaceVRMLNavigationInfoNodeType
- Parameters:
limit
- The new visibility limit value to use- Throws:
InvalidFieldValueException
- The visibility limit was negative
-
getHeadlight
public boolean getHeadlight()Get the status of the headlight that we are operating with. A true value represents the headlight being on.- Specified by:
getHeadlight
in interfaceVRMLNavigationInfoNodeType
- Returns:
- true if the headlight is to be used
-
setHeadlight
public void setHeadlight(boolean enable) Set the statte of the headlight to the new value.- Specified by:
setHeadlight
in interfaceVRMLNavigationInfoNodeType
- Parameters:
enable
- True if we are to use the headlight
-
setVersion
public void setVersion(int major, int minor, boolean isStatic) Set the version of VRML that this node should represent. Different versions have different capabilities, even within the same node.- Specified by:
setVersion
in interfaceVRMLNode
- Overrides:
setVersion
in classAbstractNode
- Parameters:
major
- The major version number of this sceneminor
- The minor version number of this sceneisStatic
- true if this node is under a StaticGroup and won't change after the setup is finished
-
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
-
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 classBaseBindableNode
- 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 classBaseBindableNode
- 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 headlight and bind.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classBaseBindableNode
- 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 not in range or not appropriate for this field
-
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 speed and visibilityLimit.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knowInvalidFieldValueException
- The value provided is not in range or not appropriate for this field
-
setValue
public void setValue(int index, float[] value, int numValid) 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 field type avatarSize.- 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 field
-
setValue
public void setValue(int index, String[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException 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 knownInvalidFieldValueException
- The value provided is not in range or not appropriate for this field
-