Class BaseDragSensorNode
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.BaseSensorNode
org.web3d.vrml.renderer.common.nodes.BaseDragSensorNode
- All Implemented Interfaces:
VRMLNode,FrameStateListener,VRMLChildNodeType,VRMLDragSensorNodeType,VRMLNodeType,VRMLPointingDeviceSensorNodeType,VRMLSensorNodeType,VRMLWorldRootChildNodeType
- Direct Known Subclasses:
BaseCylinderSensor,BasePlaneSensor,BaseSphereSensor
An abstract representation of any form of sensor for
subclassing by specific implementations.
- Version:
- $Revision: 1.11 $
- Author:
- Justin Couch, Alan Hudson
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intThe field index for enabledprotected static final intThe field index for descriptionprotected static final intThe field index for isOverprotected static final intThe field index for trackPoint_changedprotected float[]The initial position of the input touch for generating the txprotected static org.j3d.geom.IntersectionUtilsCommon intersection utils class for the ray to geometry testing during the drag process.protected static final intThe last field index used by this classprotected booleanThe value of the autoOffset fieldprotected StringThe value of the description fieldprotected booleanThe value of the isOver fieldprotected float[]The value of the trackPoint_changed fieldprotected static float[]Array to return intersection point info withFields inherited from class org.web3d.vrml.renderer.common.nodes.BaseSensorNode
FIELD_ENABLED, FIELD_IS_ACTIVE, LAST_SENSOR_INDEX, vfEnabled, vfIsActiveFields 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
ConstructorsModifierConstructorDescriptionprotectedBaseDragSensorNode(String name) Initialise the sensor node and it's fields that are held locally. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcopy(VRMLDragSensorNodeType node) Set the fields of the sensor node that has the fields set based on the fields of the passed in node.booleanAccessor method to get current value of field autoOffset.Get the description to associate with the link.getFieldValue(int index) Get the value of a field.booleanGet the current value of the isOver field.intGet the primary type of this node.float[]Accessor method to get current value of the trackPoint field.voidnotifySensorDragChange(float[] position, float[] direction) Notify the drag sensor that a sensor is currently dragging this device and that it's position and orientation are as given.voidnotifySensorDragEnd(float[] position, float[] direction) Notification that this sensor has finished a drag action.voidnotifySensorDragStart(float[] hitPoint, float[] location) Notification that this sensor has just been clicked on to start a drag action.protected abstract voidprocessDrag(float[] location, float[] direction) Generate the tracking output based on the input hit position.booleanFlag to notify the user whether the node implementation only needs the hit point information, or it needs everything else as well.voidsendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.voidsetAutoOffset(boolean state) Set a new value for the autoOffset field.voidsetDescription(String desc) Set the description string for this link.voidsetIsOver(boolean newIsOver) Set the flag describing whether the pointing device is over this sensor.voidsetValue(int index, boolean value) Set the value of the field at the given index as a boolean.voidSet the value of the field at the given index as an array of floats.Methods inherited from class org.web3d.vrml.renderer.common.nodes.BaseSensorNode
copy, getEnabled, getIsActive, setEnabledMethods 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, 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.lang.VRMLNode
getFieldDeclaration, getFieldIndex, getNodeFieldIndices, getNumFields, getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersionMethods 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, updateRefCountMethods inherited from interface org.web3d.vrml.nodes.VRMLSensorNodeType
getEnabled, getIsActive, setEnabled
-
Field Details
-
FIELD_AUTOOFFSET
protected static final int FIELD_AUTOOFFSETThe field index for enabled- See Also:
-
FIELD_TRACKPOINT_CHANGED
protected static final int FIELD_TRACKPOINT_CHANGEDThe field index for trackPoint_changed- See Also:
-
FIELD_DESCRIPTION
protected static final int FIELD_DESCRIPTIONThe field index for description- See Also:
-
FIELD_IS_OVER
protected static final int FIELD_IS_OVERThe field index for isOver- See Also:
-
LAST_DRAG_SENSOR_INDEX
protected static final int LAST_DRAG_SENSOR_INDEXThe last field index used by this class- See Also:
-
intersectionUtils
protected static org.j3d.geom.IntersectionUtils intersectionUtilsCommon intersection utils class for the ray to geometry testing during the drag process. Single common instance used because we know the event model calling this will be single threaded. -
wkPoint
protected static float[] wkPointArray to return intersection point info with -
vfAutoOffset
protected boolean vfAutoOffsetThe value of the autoOffset field -
vfTrackPointChanged
protected float[] vfTrackPointChangedThe value of the trackPoint_changed field -
vfDescription
The value of the description field -
vfIsOver
protected boolean vfIsOverThe value of the isOver field -
initialPosition
protected float[] initialPositionThe initial position of the input touch for generating the tx
-
-
Constructor Details
-
BaseDragSensorNode
Initialise the sensor node and it's fields that are held locally.- Parameters:
name- The name of the type of node
-
-
Method Details
-
copy
Set the fields of the sensor node that has the fields set based on the fields of the passed in node. This will not copy any children nodes, only the local fields.- Parameters:
node- The sensor node to copy info from
-
getDescription
Get the description to associate with the link. This is a line of text suitable for mouseovers, status information etc. If there is no description set then it returns null.- Specified by:
getDescriptionin interfaceVRMLDragSensorNodeType- Specified by:
getDescriptionin interfaceVRMLPointingDeviceSensorNodeType- Returns:
- The current description or null
-
setDescription
Set the description string for this link. Setting a value of null will clear the current description.- Specified by:
setDescriptionin interfaceVRMLDragSensorNodeType- Specified by:
setDescriptionin interfaceVRMLPointingDeviceSensorNodeType- Parameters:
desc- The new description to set
-
notifySensorDragStart
public void notifySensorDragStart(float[] hitPoint, float[] location) Notification that this sensor has just been clicked on to start a drag action.- Specified by:
notifySensorDragStartin interfaceVRMLDragSensorNodeType- Parameters:
hitPoint- Where the input device intersected the object sensorlocation- Where the sensor origin is in local coordinates
-
notifySensorDragChange
public void notifySensorDragChange(float[] position, float[] direction) Notify the drag sensor that a sensor is currently dragging this device and that it's position and orientation are as given.- Specified by:
notifySensorDragChangein interfaceVRMLDragSensorNodeType- Parameters:
position- Where the sensor origin is in local coordinatesdirection- Vector showing the direction the sensor is pointing
-
notifySensorDragEnd
public void notifySensorDragEnd(float[] position, float[] direction) Notification that this sensor has finished a drag action.- Specified by:
notifySensorDragEndin interfaceVRMLDragSensorNodeType- Parameters:
position- Where the sensor origin is in local coordinatesdirection- Vector showing the direction the sensor is pointing
-
requiresPointOnly
public boolean requiresPointOnly()Flag to notify the user whether the node implementation only needs the hit point information, or it needs everything else as well. This is an optimisation method that allows the internals of the event model to avoid doing unnecessary work. If the return value is true, then the hitNormal and hitTexCoord parameter values will not be supplied (they'll be null references).- Specified by:
requiresPointOnlyin interfaceVRMLPointingDeviceSensorNodeType- Returns:
- true if the node implementation only requires hitPoint information
-
setIsOver
public void setIsOver(boolean newIsOver) Set the flag describing whether the pointing device is over this sensor. The result should be that isOver SFBool output only field is set appropriately at the node level.- Specified by:
setIsOverin interfaceVRMLPointingDeviceSensorNodeType- Parameters:
newIsOver- The new value for isOver
-
getIsOver
public boolean getIsOver()Get the current value of the isOver field.- Specified by:
getIsOverin interfaceVRMLPointingDeviceSensorNodeType- Returns:
- The current value of isOver
-
setAutoOffset
public void setAutoOffset(boolean state) Set a new value for the autoOffset field.- Specified by:
setAutoOffsetin interfaceVRMLDragSensorNodeType- Parameters:
state- The new value for AutoOffset
-
getAutoOffset
public boolean getAutoOffset()Accessor method to get current value of field autoOffset. Default value istrue- Specified by:
getAutoOffsetin interfaceVRMLDragSensorNodeType- Returns:
- The current value of AutoOffset
-
getTrackPointChanged
public float[] getTrackPointChanged()Accessor method to get current value of the trackPoint field. The value returned is a temporary array that may be reused. The called should not maintain a reference to the value or expect that the value will be always constant or valid.- Returns:
- The current value of trackPoint_changed(SFVec3f)
-
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 classBaseSensorNode- 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 classBaseSensorNode- 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein classBaseSensorNode- 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 array of floats. This would be used to set SFString field "title".- 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 know
-
processDrag
protected abstract void processDrag(float[] location, float[] direction) Generate the tracking output based on the input hit position.- Parameters:
location- The position of the mouse locallydirection- Vector showing the direction the sensor is pointing
-