Class BaseHIDSensor
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.extensions.BaseHIDSensor
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLChildNodeType
,VRMLDeviceSensorNodeType
,VRMLNodeType
,VRMLSensorNodeType
,VRMLWorldRootChildNodeType
- Direct Known Subclasses:
BaseGamepadSensor
,BaseJoystickSensor
,BaseWheelSensor
Common base implementation of a GamepadSensor
This node is an custom extension to Xj3D node.
- Version:
- $Revision: 1.3 $
- Author:
- Alan Hudson
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
Index of the axisMaxValue fieldprotected static final int
Index of the axisMinValue fieldprotected static final int
Index of the axisName fieldprotected static final int
Index of the axisResolution fieldprotected static final int
Index of the axisValue fieldprotected static final int
Index of the axisWrap fieldprotected static final int
Index of the enabled fieldprotected static final int
Index of the isActive fieldprotected static final int
Index of the manufacturerName fieldprotected static final int
Index of the name fieldprotected static final int
Index of the numAxes fieldprotected static final int
Index of the numOutputs fieldprotected static final int
Index of the outputMaxValue fieldprotected static final int
Index of the outputMinValue fieldprotected static final int
Index of the outputName fieldprotected static final int
Index of the outputResolution fieldprotected static final int
Index of the outputValue fieldprotected static final int
Index of the axisWrap fieldprotected static final int
The last field index used by this classprotected float[]
eventOut MFFloat axisMaxValueprotected float[]
eventOut MFFloat axisMinValueprotected String[]
eventOut MFString axisNameprotected float[]
eventOut MFFloat axisResolutionprotected float[]
eventOut MFFloat axisValueprotected boolean[]
eventOut MFBool axisWrapprotected boolean
exposedField SFBool enabledprotected boolean
eventOut SFBool isActiveprotected String
eventOut SFString manufacturerNameprotected String
field SFString nameprotected int
eventOut SFInt numAxesprotected int
eventOut SFInt numOutputsprotected float[]
eventOut MFFloat outputMaxValueprotected float[]
eventOut MFFloat outputMinValueprotected String[]
eventOut MFString outputNameprotected float[]
eventOut MFFloat outputResolutionprotected float[]
eventIn MFFloat outputValueprotected boolean[]
eventOut MFBoolean outputWrapFields 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
ConstructorsConstructorDescriptionBaseHIDSensor
(String nodeName) Construct a default node with an empty info array any the title set to the empty string. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
copy
(VRMLNodeType node) Construct a new instance of this node based on the details from the given node.boolean
Accessor method to get current value of field enabled, default value istrue
.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 current value of the isActive fieldgetName()
Get the name field.int
Get the number of fields.int
Get the primary type of this node.void
sendRoute
(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.void
setEnabled
(boolean state) Set a new state for the enabled field.protected void
Set a new state for the name field.void
setValue
(int index, boolean value) Set the value of the field at the given index as a boolean.void
Set the value of the field at the given index as a String.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, setupFinished, setUserData, setValue, setValue, setValue, setValue, setValue, 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.nodes.VRMLDeviceSensorNodeType
setDevice, update
Methods inherited from interface org.web3d.vrml.lang.VRMLNode
getNodeFieldIndices, getSecondaryType, 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, setupFinished, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Field Details
-
FIELD_NAME
protected static final int FIELD_NAMEIndex of the name field- See Also:
-
FIELD_OUTPUT_VALUE
protected static final int FIELD_OUTPUT_VALUEIndex of the outputValue field- See Also:
-
FIELD_IS_ACTIVE
protected static final int FIELD_IS_ACTIVEIndex of the isActive field- See Also:
-
FIELD_AXIS_VALUE
protected static final int FIELD_AXIS_VALUEIndex of the axisValue field- See Also:
-
FIELD_AXIS_MIN_VALUE
protected static final int FIELD_AXIS_MIN_VALUEIndex of the axisMinValue field- See Also:
-
FIELD_AXIS_MAX_VALUE
protected static final int FIELD_AXIS_MAX_VALUEIndex of the axisMaxValue field- See Also:
-
FIELD_AXIS_NAME
protected static final int FIELD_AXIS_NAMEIndex of the axisName field- See Also:
-
FIELD_AXIS_RESOLUTION
protected static final int FIELD_AXIS_RESOLUTIONIndex of the axisResolution field- See Also:
-
FIELD_AXIS_WRAP
protected static final int FIELD_AXIS_WRAPIndex of the axisWrap field- See Also:
-
FIELD_MANUFACTURER_NAME
protected static final int FIELD_MANUFACTURER_NAMEIndex of the manufacturerName field- See Also:
-
FIELD_NUM_AXES
protected static final int FIELD_NUM_AXESIndex of the numAxes field- See Also:
-
FIELD_NUM_OUTPUTS
protected static final int FIELD_NUM_OUTPUTSIndex of the numOutputs field- See Also:
-
FIELD_OUTPUT_NAME
protected static final int FIELD_OUTPUT_NAMEIndex of the outputName field- See Also:
-
FIELD_OUTPUT_MIN_VALUE
protected static final int FIELD_OUTPUT_MIN_VALUEIndex of the outputMinValue field- See Also:
-
FIELD_OUTPUT_MAX_VALUE
protected static final int FIELD_OUTPUT_MAX_VALUEIndex of the outputMaxValue field- See Also:
-
FIELD_OUTPUT_RESOLUTION
protected static final int FIELD_OUTPUT_RESOLUTIONIndex of the outputResolution field- See Also:
-
FIELD_OUTPUT_WRAP
protected static final int FIELD_OUTPUT_WRAPIndex of the axisWrap field- See Also:
-
FIELD_ENABLED
protected static final int FIELD_ENABLEDIndex of the enabled field- See Also:
-
LAST_HIDSENSOR_INDEX
protected static final int LAST_HIDSENSOR_INDEXThe last field index used by this class- See Also:
-
vfEnabled
protected boolean vfEnabledexposedField SFBool enabled -
vfName
field SFString name -
vfIsActive
protected boolean vfIsActiveeventOut SFBool isActive -
vfAxisValue
protected float[] vfAxisValueeventOut MFFloat axisValue -
vfAxisMinValue
protected float[] vfAxisMinValueeventOut MFFloat axisMinValue -
vfAxisMaxValue
protected float[] vfAxisMaxValueeventOut MFFloat axisMaxValue -
vfAxisName
eventOut MFString axisName -
vfAxisResolution
protected float[] vfAxisResolutioneventOut MFFloat axisResolution -
vfAxisWrap
protected boolean[] vfAxisWrapeventOut MFBool axisWrap -
vfManufacturerName
eventOut SFString manufacturerName -
vfNumAxes
protected int vfNumAxeseventOut SFInt numAxes -
vfNumOutputs
protected int vfNumOutputseventOut SFInt numOutputs -
vfOutputValue
protected float[] vfOutputValueeventIn MFFloat outputValue -
vfOutputMinValue
protected float[] vfOutputMinValueeventOut MFFloat outputMinValue -
vfOutputMaxValue
protected float[] vfOutputMaxValueeventOut MFFloat outputMaxValue -
vfOutputName
eventOut MFString outputName -
vfOutputResolution
protected float[] vfOutputResolutioneventOut MFFloat outputResolution -
vfOutputWrap
protected boolean[] vfOutputWrapeventOut MFBoolean outputWrap
-
-
Constructor Details
-
BaseHIDSensor
Construct a default node with an empty info array any the title set to the empty string.- Parameters:
nodeName
-
-
-
Method Details
-
copy
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
- The node is not the same type
-
getName
Get the name field.- Specified by:
getName
in interfaceVRMLDeviceSensorNodeType
- Returns:
- The name.
-
getEnabled
public boolean getEnabled()Accessor method to get current value of field enabled, default value istrue
.- Specified by:
getEnabled
in interfaceVRMLSensorNodeType
- Returns:
- The value of the enabled field
-
getIsActive
public boolean getIsActive()Get the current value of the isActive field- Specified by:
getIsActive
in interfaceVRMLSensorNodeType
- Returns:
- True if currently active, false otherwise
-
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
-
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 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 boolean. This is be used to set SFBool field types isActive, enabled and loop.- 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, String value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a String. This is be used to set SFString field types name.- 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.
-
setEnabled
public void setEnabled(boolean state) Set a new state for the enabled field.- Specified by:
setEnabled
in interfaceVRMLSensorNodeType
- Parameters:
state
- True if this sensor is to be enabled
-
setName
Set a new state for the name field.- Parameters:
name
- The new name
-