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 intThe field index for hitTexCoord_Changedprotected static final intIndex of the objectType fieldprotected static final intThe field index for hitPoint_Changedprotected static final intThe field index for pickedGeometryprotected static final intThe field index for pickingGeometryprotected static final intThe field index for isOverprotected static final StringMessage for when the node in setValue() is not a Geometryprotected static final StringMessage for when the proto is not a Geometryprotected intConstant representing the intersection typeMap containing the string to constant mapping for intersection typeprotected static final intLast index used by this base nodeprotected intNumber of valid items in the pickedGeometry arrayprotected intNumber of valid items in the vfPickTarget arrayprotected VRMLProtoInstanceThe proto version of the picking geometryprotected intConstant 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 StringThe value of the intersectionType fieldprotected String[]MFString objectTypeprotected VRMLNodeType[]The value of the pickTarget fieldprotected VRMLGeometryNodeTypeThe value of the pickingGeometry fieldprotected VRMLNodeType[]The value of the pickTarget fieldprotected StringThe value of the sortOrder fieldFields 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, vrmlMinorVersionFields 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 voidcheckPickTargetType(VRMLNodeType target) Check to make sure the picking target node being added is of the correct type.protected voidSet 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.intGet the intersection type requested for this nodevoidgetObjectType(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.intGet the primary type of this node.intGet the intersection type requested for this nodevoidnotifyPickChange(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.voidNotification that this sensor has finished a picking action.voidnotifyPickStart(int numPicks, VRMLNode[] nodes, float[] points, float[] normals, float[] texCoords) Notification that this sensor has just been clicked on to start the pick action.intGet the current number of valid object type strings.voidsendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.voidsetEnabled(boolean state) Accessor method to set a new value for the enabled field.voidsetObjectType(String[] types, int numValid) Set the list of picking targets that this object corresponds to.voidsetPickingGeometry(VRMLNodeType child) Set node content as replacement for the pickingGeometry field.voidNotification that the construction phase of this node has finished.voidSet the value of the field at the given index as a single string.voidSet the value of the field at the given index as an array of floats.voidsetValue(int index, VRMLNodeType child) Set the value of the field at the given index as an array of nodes.voidsetValue(int index, VRMLNodeType[] children, int numValid) Set the value of the field at the given index as an array of nodes.protected voidupdateChildren(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, setValueMethods 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, 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, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCountMethods inherited from interface org.web3d.vrml.nodes.VRMLPickingSensorNodeType
getPickingTypeMethods 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:
setObjectTypein 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:
numObjectTypein interfaceVRMLPickingSensorNodeType- Returns:
- a number >= 0
-
getObjectType
Fetch the number of object type values in use currently.- Specified by:
getObjectTypein interfaceVRMLPickingSensorNodeType- Parameters:
val- An array to copy the values to
-
getSortOrder
public int getSortOrder()Get the intersection type requested for this node- Specified by:
getSortOrderin interfaceVRMLPickingSensorNodeType- Returns:
- one of the SORT_* constants
-
getIntersectionType
public int getIntersectionType()Get the intersection type requested for this node- Specified by:
getIntersectionTypein 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:
setPickingGeometryin 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:
getPickingGeometryin 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:
getPickingTargetsin 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:
notifyPickStartin 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:
notifyPickChangein 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:
notifyPickEndin interfaceVRMLPickingSensorNodeType
-
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
-
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:
setupFinishedin interfaceVRMLNodeType- Overrides:
setupFinishedin 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:
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
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:
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
-
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:
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
-
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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setEnabledin interfaceVRMLSensorNodeType- Overrides:
setEnabledin 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
-