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 intIndex of the avatarSize fieldprotected static final intIndex of the headlight fieldprotected static final intIndex of the speed fieldprotected static final intIndex of the transitionTime fieldprotected static final intIndex of the transitionType fieldprotected static final intIndex of the type fieldprotected static final intIndex of the visibilityLimit fieldprotected static final intThe last field index used by this classprotected static final intNumber of fields constantprotected intThe number of active items in the avatar size fieldprotected intThe number of active items in the transitionType fieldprotected intThe number of active items in the type fieldprotected float[]SFFloat list of avatar informationprotected booleanSFBool indicating if the headlight should be onprotected floatSFFloat 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 floatSFFloat 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, vfIsBoundFields 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, vrmlMinorVersionFields 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
ConstructorsModifierConstructorDescriptionprotectedConstruct a default node with all of the values set to the given types.protectedConstruct a new instance of this node based on the details from the given node. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd 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.intgetFieldIndex(String fieldName) Get the index of the given field name.getFieldValue(int index) Get the value of a field.booleanGet 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).intGet the number of fields.intGet the number of valid navigation types in the result from getType().intGet the primary type of this node.floatgetSpeed()Get the speed that we are currently moving at.String[]getType()Get the list of navigation types that are to be used.floatGet the visibility limit that we are currently operating at.voidRemove the listener for navigation info changes.voidsendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.voidsetAvatarSize(float[] size, int numValid) Set the dimensions of the avatar in use.voidsetHeadlight(boolean enable) Set the statte of the headlight to the new value.voidsetSpeed(float newSpeed) Set the speed to move at.voidsetTransitionType(String[] types, int numValid) Set the transition type to the new value(s).voidSet the navigation type to the new value(s).voidsetValue(int index, boolean value) Set the value of the field at the given index as an boolean.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.voidSet the value of the field at the given index as an array of strings.voidsetVersion(int major, int minor, boolean isStatic) Set the version of VRML that this node should represent.voidsetVisibilityLimit(float limit) Set the visibility limie to move at.voidsetWorldLocation(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, setVRMLClockMethods 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, 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.nodes.VRMLBindableNodeType
addBindableNodeListener, getBindTime, getIsBound, removeBindableNodeListener, setBind, setOnStackMethods inherited from interface org.web3d.vrml.lang.VRMLNode
getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserDataMethods 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:
getTypein 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:
getNumTypesin 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:
setWorldLocationin 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:
setTypein 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:
getAvatarSizein 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:
setAvatarSizein 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:
getSpeedin interfaceVRMLNavigationInfoNodeType- Returns:
- The current movement speed.
-
setSpeed
Set the speed to move at. The speed value must be non-negative.- Specified by:
setSpeedin 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:
getVisibilityLimitin 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:
setVisibilityLimitin 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:
getHeadlightin 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:
setHeadlightin 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:
setVersionin interfaceVRMLNode- Overrides:
setVersionin 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:
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 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:
sendRoutein interfaceVRMLNodeType- Overrides:
sendRoutein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
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 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:
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 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:
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 not in range or not appropriate for this field
-