Class BasePickingNode
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.BaseSensorNode
org.web3d.vrml.renderer.common.nodes.picking.BasePickingNode
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLChildNodeType
,VRMLNodeType
,VRMLPickingSensorNodeType
,VRMLSensorNodeType
,VRMLWorldRootChildNodeType
- Direct Known Subclasses:
BaseLinePickSensor
,BasePointPickSensor
,BasePrimitivePickSensor
,BaseVolumePickSensor
Implementation of the abstract X3DPickingNode type.
- Version:
- $Revision: 1.15 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
The field index for hitTexCoord_Changedprotected static final int
Index of the objectType fieldprotected static final int
The field index for hitPoint_Changedprotected static final int
The field index for pickedGeometryprotected static final int
The field index for pickingGeometryprotected static final int
The field index for isOverprotected static final String
Message for when the node in setValue() is not a Geometryprotected static final String
Message for when the proto is not a Geometryprotected int
Constant representing the intersection typeMap containing the string to constant mapping for intersection typeprotected static final int
Last index used by this base nodeprotected int
Number of valid items in the pickedGeometry arrayprotected int
Number of valid items in the vfPickTarget arrayprotected VRMLProtoInstance
The proto version of the picking geometryprotected int
Constant representing the sort typeMap containing the string to constant mapping for sortingprotected org.j3d.util.HashSet
<String> The set of valid geometry node name types that the picking instance is allowed to use for the pick geometry.protected String
The value of the intersectionType fieldprotected String[]
MFString objectTypeprotected VRMLNodeType[]
The value of the pickTarget fieldprotected VRMLGeometryNodeType
The value of the pickingGeometry fieldprotected VRMLNodeType[]
The value of the pickTarget fieldprotected String
The value of the sortOrder fieldFields 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
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.VRMLPickingSensorNodeType
BOX_PICK, CONE_PICK, CYLINDER_PICK, INTERSECT_BOUNDS, INTERSECT_GEOMETRY, LINE_PICK, POINT_PICK, SORT_ALL, SORT_ALL_SORTED, SORT_ANY, SORT_CLOSEST, SPHERE_PICK, UNDEFINED_PICK, VOLUME_PICK
-
Constructor Summary
ConstructorsConstructorDescriptionBasePickingNode
(String name, String errorMsg) Construct a new generalised picking node object. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkPickTargetType
(VRMLNodeType target) Check to make sure the picking target node being added is of the correct type.protected void
Set the fields of the sensor node that has the fields set based on the fields of the passed in node.getFieldValue
(int index) Get the value of a field.int
Get the intersection type requested for this nodevoid
getObjectType
(String[] val) Fetch the number of object type values in use currently.Fetch the node that is being used to pick the geometryGet the list of nodes that are used for the target geometry.int
Get the primary type of this node.int
Get the intersection type requested for this nodevoid
notifyPickChange
(int numPicks, VRMLNode[] nodes, float[] points, float[] normals, float[] texCoords) Notify the drag sensor that a sensor is currently dragging this device and that it's position and orientation are as given.void
Notification that this sensor has finished a picking action.void
notifyPickStart
(int numPicks, VRMLNode[] nodes, float[] points, float[] normals, float[] texCoords) Notification that this sensor has just been clicked on to start the pick action.int
Get the current number of valid object type strings.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) Accessor method to set a new value for the enabled field.void
setObjectType
(String[] types, int numValid) Set the list of picking targets that this object corresponds to.void
setPickingGeometry
(VRMLNodeType child) Set node content as replacement for the pickingGeometry field.void
Notification that the construction phase of this node has finished.void
Set the value of the field at the given index as a single string.void
Set the value of the field at the given index as an array of floats.void
setValue
(int index, VRMLNodeType child) Set the value of the field at the given index as an array of nodes.void
setValue
(int index, VRMLNodeType[] children, int numValid) Set the value of the field at the given index as an array of nodes.protected void
updateChildren
(VRMLNodeType[] targets, int numValid) Update the child list with the new nodes.Methods inherited from class org.web3d.vrml.renderer.common.nodes.BaseSensorNode
copy, getEnabled, getIsActive, setValue
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, setUserData, 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.lang.VRMLNode
getFieldDeclaration, getFieldIndex, getNodeFieldIndices, getNumFields, 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, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
Methods inherited from interface org.web3d.vrml.nodes.VRMLPickingSensorNodeType
getPickingType
Methods inherited from interface org.web3d.vrml.nodes.VRMLSensorNodeType
getEnabled, getIsActive
-
Field Details
-
FIELD_PICKING_GEOMETRY
protected static final int FIELD_PICKING_GEOMETRYThe field index for pickingGeometry- See Also:
-
FIELD_PICK_TARGET
protected static final int FIELD_PICK_TARGETThe field index for hitPoint_Changed- See Also:
-
FIELD_INTERSECTION_TYPE
protected static final int FIELD_INTERSECTION_TYPEThe field index for hitTexCoord_Changed- See Also:
-
FIELD_PICKED_GEOMETRY
protected static final int FIELD_PICKED_GEOMETRYThe field index for pickedGeometry- See Also:
-
FIELD_SORT_ORDER
protected static final int FIELD_SORT_ORDERThe field index for isOver- See Also:
-
FIELD_OBJECT_TYPE
protected static final int FIELD_OBJECT_TYPEIndex of the objectType field- See Also:
-
LAST_PICK_INDEX
protected static final int LAST_PICK_INDEXLast index used by this base node- See Also:
-
GEOMETRY_PROTO_MSG
Message for when the proto is not a Geometry- See Also:
-
GEOMETRY_NODE_MSG
Message for when the node in setValue() is not a Geometry- See Also:
-
sortTypeMap
-
intersectTypeMap
-
vfObjectType
MFString objectType -
vfPickingGeometry
The value of the pickingGeometry field -
pPickingGeometry
The proto version of the picking geometry -
vfPickTarget
The value of the pickTarget field -
vfPickedGeometry
The value of the pickTarget field -
vfIntersectionType
The value of the intersectionType field -
vfSortOrder
The value of the sortOrder field -
intersectionType
protected int intersectionTypeConstant representing the intersection type -
sortType
protected int sortTypeConstant representing the sort type -
numPickTarget
protected int numPickTargetNumber of valid items in the vfPickTarget array -
numPickedGeometry
protected int numPickedGeometryNumber of valid items in the pickedGeometry array -
validGeometryNodeNames
The set of valid geometry node name types that the picking instance is allowed to use for the pick geometry. THis is sort of a bit of a kludge to deal with the multiple renderer thing. However, when we do get a proto instance, we first walk down the stack looking for the implementation node to make sure it satisfies one of these names too.
-
-
Constructor Details
-
BasePickingNode
-
-
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
-
setObjectType
Set the list of picking targets that this object corresponds to. These can be an array of strings.- Specified by:
setObjectType
in interfaceVRMLPickingSensorNodeType
- Parameters:
types
- The list of object type strings to usenumValid
- The number of valid values to read from the array
-
numObjectType
public int numObjectType()Get the current number of valid object type strings.- Specified by:
numObjectType
in interfaceVRMLPickingSensorNodeType
- Returns:
- a number >= 0
-
getObjectType
Fetch the number of object type values in use currently.- Specified by:
getObjectType
in interfaceVRMLPickingSensorNodeType
- Parameters:
val
- An array to copy the values to
-
getSortOrder
public int getSortOrder()Get the intersection type requested for this node- Specified by:
getSortOrder
in interfaceVRMLPickingSensorNodeType
- Returns:
- one of the SORT_* constants
-
getIntersectionType
public int getIntersectionType()Get the intersection type requested for this node- Specified by:
getIntersectionType
in interfaceVRMLPickingSensorNodeType
- Returns:
- one of the INTERSECT_* constants
-
setPickingGeometry
Set node content as replacement for the pickingGeometry field. This checks only for basic geometry handling. If a concrete node needs a specific set of nodes, it should override this method to check.- Specified by:
setPickingGeometry
in interfaceVRMLPickingSensorNodeType
- Parameters:
child
- The new picking geometry. null will act like delete- Throws:
InvalidFieldValueException
- The node does not match the required type.
-
getPickingGeometry
Fetch the node that is being used to pick the geometry- Specified by:
getPickingGeometry
in interfaceVRMLPickingSensorNodeType
- Returns:
- The valid geometry node or null if not set
-
getPickingTargets
Get the list of nodes that are used for the target geometry. This can be a internal listing of children. Any node valid entries in the can be set to null.- Specified by:
getPickingTargets
in interfaceVRMLPickingSensorNodeType
- Returns:
- an array of picking targets
-
notifyPickStart
public void notifyPickStart(int numPicks, VRMLNode[] nodes, float[] points, float[] normals, float[] texCoords) Notification that this sensor has just been clicked on to start the pick action. Derived classes should call this one to handle the basic node output and state. Points, normals, texCoords not handled.- Specified by:
notifyPickStart
in interfaceVRMLPickingSensorNodeType
- Parameters:
numPicks
- The number of items picked in the arraynodes
- The geometry that was pickedpoints
- Optional array of points that are the intersection pointsnormals
- Optional array of normals that are the intersection pointstexCoords
- Optional array of texture coordinates that are the intersection points
-
notifyPickChange
public void notifyPickChange(int numPicks, VRMLNode[] nodes, float[] points, float[] normals, float[] texCoords) Notify the drag sensor that a sensor is currently dragging this device and that it's position and orientation are as given.- Specified by:
notifyPickChange
in interfaceVRMLPickingSensorNodeType
- Parameters:
numPicks
- The number of items picked in the arraynodes
- The geometry that was pickedpoints
- Optional array of points that are the intersection pointsnormals
- Optional array of normals that are the intersection pointstexCoords
- Optional array of texture coordinates that are the intersection points
-
notifyPickEnd
public void notifyPickEnd()Notification that this sensor has finished a picking action.- Specified by:
notifyPickEnd
in interfaceVRMLPickingSensorNodeType
-
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
-
setupFinished
public void setupFinished()Notification that the construction phase of this node has finished. If the node would like to do any internal processing, such as setting up geometry, then go for it now.- Specified by:
setupFinished
in interfaceVRMLNodeType
- Overrides:
setupFinished
in classAbstractNode
-
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 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:
sendRoute
in interfaceVRMLNodeType
- Overrides:
sendRoute
in 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
Set the value of the field at the given index as a single string. This would be used to set SFString field types.- 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 know
-
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 floats. This would be used to set MFString field 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
-
setValue
public void setValue(int index, VRMLNodeType child) throws InvalidFieldValueException, InvalidFieldException Set the value of the field at the given index as an array of nodes. This would be used to set MFNode field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setchild
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knowInvalidFieldValueException
- The value provided does not fit this type of node
-
setValue
Set the value of the field at the given index as an array of nodes. This would be used to set MFNode field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setchildren
- 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 know
-
setEnabled
public void setEnabled(boolean state) Accessor method to set a new value for the enabled field.- Specified by:
setEnabled
in interfaceVRMLSensorNodeType
- Overrides:
setEnabled
in classBaseSensorNode
- Parameters:
state
- Whether this sensor is enabled
-
checkPickTargetType
Check to make sure the picking target node being added is of the correct type. If not, issue an error.- Parameters:
target
- The node to check that it follows the requirements- Throws:
InvalidFieldValueException
- The node is not a grouping or shape node
-
updateChildren
Update the child list with the new nodes. This is called after all the basic filtering has been complete and may be overridden by derived classes if needed. The default implementation is empty.- Parameters:
targets
- The list of current childrennumValid
- The number of valid children to check
-