Xj3D VRML/X3D Code API

org.web3d.vrml.renderer.common.nodes
Class BaseDragSensorNode

java.lang.Object
  extended byorg.web3d.vrml.renderer.common.nodes.AbstractNode
      extended byorg.web3d.vrml.renderer.common.nodes.BaseSensorNode
          extended byorg.web3d.vrml.renderer.common.nodes.BaseDragSensorNode
All Implemented Interfaces:
FrameStateListener, VRMLChildNodeType, VRMLDragSensorNodeType, VRMLNode, VRMLNodeType, VRMLPointingDeviceSensorNodeType, VRMLSensorNodeType

public abstract class BaseDragSensorNode
extends BaseSensorNode
implements VRMLDragSensorNodeType

An abstract representation of any form of sensor for subclassing by specific implementations.

Version:
$Revision: 1.10 $
Author:
Justin Couch, Alan Hudson

Field Summary
protected static int FIELD_AUTOOFFSET
          The field index for enabled
protected static int FIELD_DESCRIPTION
          The field index for description
protected static int FIELD_IS_OVER
          The field index for isOver
protected static int FIELD_TRACKPOINT_CHANGED
          The field index for trackPoint_changed
protected  float[] initialPosition
          The initial position of the input touch for generating the tx
protected static org.j3d.geom.IntersectionUtils intersectionUtils
          Common intersection utils class for the ray to geometry testing during the drag process.
protected static int LAST_DRAG_SENSOR_INDEX
          The last field index used by this class
protected  boolean vfAutoOffset
          The value of the autoOffset field
protected  java.lang.String vfDescription
          The value of the description field
protected  boolean vfIsOver
          The value of the isOver field
protected  float[] vfTrackPointChanged
          The value of the trackPoint_changed field
protected static float[] wkPoint
          Array to return intersection point info with
 
Fields inherited from class org.web3d.vrml.renderer.common.nodes.BaseSensorNode
FIELD_ENABLED, FIELD_IS_ACTIVE, LAST_SENSOR_INDEX, vfEnabled, vfIsActive
 
Fields inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
BAD_NODE_MSG, errorReporter, FIELD_METADATA, fieldData, hasChanged, INIT_ONLY_WRITE_MSG, inSetup, isDEF, isStatic, LAST_NODE_INDEX, METADATA_NODE_MSG, METADATA_PROTO_MSG, nodeName, pMetadata, refCount, stateManager, vfMetadata, vrmlMajorVersion, vrmlMinorVersion
 
Constructor Summary
protected BaseDragSensorNode(java.lang.String name)
          Initialise the sensor node and it's fields that are held locally.
 
Method Summary
protected  void copy(VRMLDragSensorNodeType node)
          Set the fields of the sensor node that has the fields set based on the fields of the passed in node.
 boolean getAutoOffset()
          Accessor method to get current value of field autoOffset.
 java.lang.String getDescription()
          Get the description to associate with the link.
 VRMLFieldData getFieldValue(int index)
          Get the value of a field.
 boolean getIsOver()
          Get the current value of the isOver field.
 int getPrimaryType()
          Get the primary type of this node.
 float[] getTrackPointChanged()
          Accessor method to get current value of the trackPoint field.
 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.
 void notifySensorDragEnd(float[] position, float[] direction)
          Notification that this sensor has finished a drag action.
 void notifySensorDragStart(float[] hitPoint, float[] location)
          Notification that this sensor has just been clicked on to start a drag action.
protected abstract  void processDrag(float[] location, float[] direction)
          Generate the tracking output based on the input hit position.
 boolean requiresPointOnly()
          Flag to notify the user whether the node implementation only needs the hit point information, or it needs everything else as well.
 void sendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex)
          Send a routed value from this node to the given destination node.
 void setAutoOffset(boolean state)
          Set a new value for the autoOffset field.
 void setDescription(java.lang.String desc)
          Set the description string for this link.
 void setIsOver(boolean newIsOver)
          Set the flag describing whether the pointing device is over this sensor.
 void setValue(int index, boolean value)
          Set the value of the field at the given index as a boolean.
 void setValue(int index, java.lang.String value)
          Set 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, setEnabled
 
Methods inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
addNodeListener, allEventsComplete, checkNodeType, checkSecondaryType, checkSecondaryType, fireFieldChanged, getMetadataObject, getNodeFieldIndices, getRefCount, 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, updateRefCount
 
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.VRMLSensorNodeType
getEnabled, getIsActive, setEnabled
 
Methods inherited from interface org.web3d.vrml.nodes.VRMLNodeType
addNodeListener, getMetadataObject, getRefCount, hasFieldChanged, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setFrameStateManager, setMetadataObject, setupFinished, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
 
Methods inherited from interface org.web3d.vrml.lang.VRMLNode
getFieldDeclaration, getFieldIndex, getNodeFieldIndices, getNumFields, getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersion
 
Methods inherited from interface org.web3d.vrml.nodes.FrameStateListener
allEventsComplete
 

Field Detail

FIELD_AUTOOFFSET

protected static final int FIELD_AUTOOFFSET
The field index for enabled

See Also:
Constant Field Values

FIELD_TRACKPOINT_CHANGED

protected static final int FIELD_TRACKPOINT_CHANGED
The field index for trackPoint_changed

See Also:
Constant Field Values

FIELD_DESCRIPTION

protected static final int FIELD_DESCRIPTION
The field index for description

See Also:
Constant Field Values

FIELD_IS_OVER

protected static final int FIELD_IS_OVER
The field index for isOver

See Also:
Constant Field Values

LAST_DRAG_SENSOR_INDEX

protected static final int LAST_DRAG_SENSOR_INDEX
The last field index used by this class

See Also:
Constant Field Values

intersectionUtils

protected static org.j3d.geom.IntersectionUtils intersectionUtils
Common 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[] wkPoint
Array to return intersection point info with


vfAutoOffset

protected boolean vfAutoOffset
The value of the autoOffset field


vfTrackPointChanged

protected float[] vfTrackPointChanged
The value of the trackPoint_changed field


vfDescription

protected java.lang.String vfDescription
The value of the description field


vfIsOver

protected boolean vfIsOver
The value of the isOver field


initialPosition

protected float[] initialPosition
The initial position of the input touch for generating the tx

Constructor Detail

BaseDragSensorNode

protected BaseDragSensorNode(java.lang.String name)
Initialise the sensor node and it's fields that are held locally.

Parameters:
name - The name of the type of node
Method Detail

copy

protected void copy(VRMLDragSensorNodeType node)
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

public java.lang.String 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:
getDescription in interface VRMLDragSensorNodeType
Returns:
The current description or null

setDescription

public void setDescription(java.lang.String desc)
Set the description string for this link. Setting a value of null will clear the current description.

Specified by:
setDescription in interface VRMLDragSensorNodeType
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:
notifySensorDragStart in interface VRMLDragSensorNodeType
Parameters:
hitPoint - Where the input device intersected the object sensor
location - 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:
notifySensorDragChange in interface VRMLDragSensorNodeType
Parameters:
position - Where the sensor origin is in local coordinates
direction - 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:
notifySensorDragEnd in interface VRMLDragSensorNodeType
Parameters:
position - Where the sensor origin is in local coordinates
direction - 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:
requiresPointOnly in interface VRMLPointingDeviceSensorNodeType
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:
setIsOver in interface VRMLPointingDeviceSensorNodeType
Parameters:
newIsOver - The new value for isOver

getIsOver

public boolean getIsOver()
Get the current value of the isOver field.

Specified by:
getIsOver in interface VRMLPointingDeviceSensorNodeType
Returns:
The current value of isOver

setAutoOffset

public void setAutoOffset(boolean state)
Set a new value for the autoOffset field.

Specified by:
setAutoOffset in interface VRMLDragSensorNodeType
Parameters:
state - The new value for AutoOffset

getAutoOffset

public boolean getAutoOffset()
Accessor method to get current value of field autoOffset. Default value is true

Specified by:
getAutoOffset in interface VRMLDragSensorNodeType
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:
getPrimaryType in interface VRMLNode
Returns:
The primary type

getFieldValue

public VRMLFieldData getFieldValue(int index)
                            throws InvalidFieldException
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 interface VRMLNodeType
Overrides:
getFieldValue in class BaseSensorNode
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

public void sendRoute(double time,
                      int srcIndex,
                      VRMLNodeType destNode,
                      int destIndex)
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 interface VRMLNodeType
Overrides:
sendRoute in class BaseSensorNode
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 from
destNode - The node reference that we will be sending the value to
destIndex - 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 interface VRMLNodeType
Overrides:
setValue in class BaseSensorNode
Parameters:
index - The index of destination field to set
value - The new value to use for the node
Throws:
InvalidFieldException - The index is not a valid field
InvalidFieldValueException - The field value is not legal for the field specified.

setValue

public void setValue(int index,
                     java.lang.String value)
              throws InvalidFieldException
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:
setValue in interface VRMLNodeType
Overrides:
setValue in class AbstractNode
Parameters:
index - The index of destination field to set
value - 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 locally
direction - Vector showing the direction the sensor is pointing

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium