Package com.sun.j3d.utils.pickfast
Class PickTool
java.lang.Object
com.sun.j3d.utils.pickfast.PickTool
- Direct Known Subclasses:
PickCanvas
The base class for optimized picking operations.
The picking methods will return a PickInfo object for each object picked,
which can then be queried to
obtain more detailed information about the specific objects that were
picked.
The pick mode specifies the detail level of picking before the PickInfo is returned:
- PickInfo.PICK_BOUNDS - Pick using the only bounds of the pickable nodes.
- PickInfo.PICK_GEOMETRY will pick using the geometry of the pickable nodes. Geometry nodes in the scene must have the ALLOW_INTERSECT capability set for this mode.
The pick flags specifies the content of the PickInfo(s) returned by the pick methods. This is specified as one or more individual bits that are bitwise "OR"ed together to describe the PickInfo data. The flags include :
PickInfo.SCENEGRAPHPATH
- request for computed SceneGraphPath.PickInfo.NODE
- request for computed intersected Node.PickInfo.LOCAL_TO_VWORLD
- request for computed local to virtual world transform.PickInfo.CLOSEST_INTERSECTION_POINT
- request for closest intersection point.PickInfo.CLOSEST_DISTANCE
- request for the distance of closest intersection.PickInfo.CLOSEST_GEOM_INFO
- request for only the closest intersection geometry information.PickInfo.ALL_GEOM_INFO
- request for all intersection geometry information.When using pickAllSorted or pickClosest methods, the picks will be sorted by the distance from the start point of the pick shape to the intersection point.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Flag to pass togetNode(int)
to return aBranchGroup
node from theSceneGraphPath
.static final int
Flag to pass togetNode(int)
to return aGroup
node from theSceneGraphPath
.static final int
Flag to pass togetNode(int)
to return aLink
node from theSceneGraphPath
.static final int
Flag to pass togetNode(int)
to return aMorph
node from theSceneGraphPath
.static final int
Flag to pass togetNode(int)
to return aPrimitive
node from theSceneGraphPath
.static final int
Flag to pass togetNode(int)
to return aShape3D
node from theSceneGraphPath
.static final int
Flag to pass togetNode(int)
to return aSwitch
node from theSceneGraphPath
.static final int
Flag to pass togetNode(int)
to return aTransformGroup
node from theSceneGraphPath
.protected boolean
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor with BranchGroup to be picked.Constructor with the Locale to be picked. -
Method Summary
Modifier and TypeMethodDescriptionReturns the BranchGroup to be picked if the tool was initialized with a BranchGroup, null otherwise.int
getFlags()
Gets the PickInfo content flags.Returns the Locale to be picked if the tool was initialized with a Locale, null otherwise.int
getMode()
Gets the picking detail mode.Get the first node of a certain type up the SceneGraphPathReturns the PickShape for this object.javax.vecmath.Point3d
Returns the start postion used for distance measurement.PickInfo[]
pickAll()
Selects all the nodes that intersect the PickShape.PickInfo[]
Select all the nodes that intersect the PickShape, returned sorted.pickAny()
Select one of the nodes that intersect the PickShapeSelect the closest node that intersects the PickShape.void
setFlags
(int flags) Sets the PickInfo content flags.void
setMode
(int mode) Sets the picking detail mode.void
Sets the pick shape to a user-provided PickShape objectvoid
setShapeBounds
(Bounds bounds, javax.vecmath.Point3d startPt) Sets the pick shape to use a user-provided Bounds objectvoid
setShapeConeRay
(javax.vecmath.Point3d start, javax.vecmath.Vector3d dir, double angle) Sets the pick shape to an infinite PickCone.void
setShapeConeSegment
(javax.vecmath.Point3d start, javax.vecmath.Point3d end, double angle) Sets the pick shape to a capped PickConevoid
setShapeCylinderRay
(javax.vecmath.Point3d start, javax.vecmath.Vector3d dir, double radius) Sets the pick shape to an infinite PickCylinder.void
setShapeCylinderSegment
(javax.vecmath.Point3d start, javax.vecmath.Point3d end, double radius) Sets the pick shape to a capped PickCylindervoid
setShapeRay
(javax.vecmath.Point3d start, javax.vecmath.Vector3d dir) Sets the pick shape to a PickRay.void
setShapeSegment
(javax.vecmath.Point3d start, javax.vecmath.Point3d end) Sets the pick shape to a PickSegment.
-
Field Details
-
TYPE_SHAPE3D
public static final int TYPE_SHAPE3DFlag to pass togetNode(int)
to return aShape3D
node from theSceneGraphPath
.- See Also:
-
TYPE_MORPH
public static final int TYPE_MORPHFlag to pass togetNode(int)
to return aMorph
node from theSceneGraphPath
.- See Also:
-
TYPE_PRIMITIVE
public static final int TYPE_PRIMITIVEFlag to pass togetNode(int)
to return aPrimitive
node from theSceneGraphPath
.- See Also:
-
TYPE_LINK
public static final int TYPE_LINKFlag to pass togetNode(int)
to return aLink
node from theSceneGraphPath
.- See Also:
-
TYPE_GROUP
public static final int TYPE_GROUPFlag to pass togetNode(int)
to return aGroup
node from theSceneGraphPath
.- See Also:
-
TYPE_TRANSFORM_GROUP
public static final int TYPE_TRANSFORM_GROUPFlag to pass togetNode(int)
to return aTransformGroup
node from theSceneGraphPath
.- See Also:
-
TYPE_BRANCH_GROUP
public static final int TYPE_BRANCH_GROUPFlag to pass togetNode(int)
to return aBranchGroup
node from theSceneGraphPath
.- See Also:
-
TYPE_SWITCH
public static final int TYPE_SWITCHFlag to pass togetNode(int)
to return aSwitch
node from theSceneGraphPath
.- See Also:
-
userDefineShape
protected boolean userDefineShape
-
-
Constructor Details
-
PickTool
Constructor with BranchGroup to be picked. -
PickTool
Constructor with the Locale to be picked.
-
-
Method Details
-
getBranchGroup
Returns the BranchGroup to be picked if the tool was initialized with a BranchGroup, null otherwise. -
getLocale
Returns the Locale to be picked if the tool was initialized with a Locale, null otherwise. -
setShape
Sets the pick shape to a user-provided PickShape object- Parameters:
ps
- The pick shape to pick against.startPt
- The start point to use for distance calculations
-
setShapeBounds
Sets the pick shape to use a user-provided Bounds object- Parameters:
bounds
- The bounds to pick against.startPt
- The start point to use for distance calculations
-
setMode
public void setMode(int mode) Sets the picking detail mode. The default is PickInfo.PICK_BOUNDS.- Parameters:
mode
- One of PickInfo.PICK_BOUNDS or PickInfo.PICK_GEOMETRY.- Throws:
IllegalArgumentException
- if mode is not a legal value
-
getMode
public int getMode()Gets the picking detail mode. -
setFlags
public void setFlags(int flags) Sets the PickInfo content flags. The default is PickInfo.NODE.- Parameters:
flags
- specified as one or more individual bits that are bitwise "OR"ed together :PickInfo.SCENEGRAPHPATH
- request for computed SceneGraphPath.
PickInfo.NODE
- request for computed intersected Node.
PickInfo.LOCAL_TO_VWORLD
- request for computed local to virtual world transform.
PickInfo.CLOSEST_INTERSECTION_POINT
- request for closest intersection point.
PickInfo.CLOSEST_DISTANCE
- request for the distance of closest intersection.
PickInfo.CLOSEST_GEOM_INFO
- request for only the closest intersection geometry information.
PickInfo.ALL_GEOM_INFO
- request for all intersection geometry information.
- Throws:
IllegalArgumentException
- if any other bits besides the above are set.
-
getFlags
public int getFlags()Gets the PickInfo content flags. -
setShapeRay
public void setShapeRay(javax.vecmath.Point3d start, javax.vecmath.Vector3d dir) Sets the pick shape to a PickRay.- Parameters:
start
- The start of the raydir
- The direction of the ray
-
setShapeSegment
public void setShapeSegment(javax.vecmath.Point3d start, javax.vecmath.Point3d end) Sets the pick shape to a PickSegment.- Parameters:
start
- The start of the segmentend
- The end of the segment
-
setShapeCylinderSegment
public void setShapeCylinderSegment(javax.vecmath.Point3d start, javax.vecmath.Point3d end, double radius) Sets the pick shape to a capped PickCylinder- Parameters:
start
- The start of axis of the cylinderend
- The end of the axis of the cylinderradius
- The radius of the cylinder
-
setShapeCylinderRay
public void setShapeCylinderRay(javax.vecmath.Point3d start, javax.vecmath.Vector3d dir, double radius) Sets the pick shape to an infinite PickCylinder.- Parameters:
start
- The start of axis of the cylinderdir
- The direction of the axis of the cylinderradius
- The radius of the cylinder
-
setShapeConeSegment
public void setShapeConeSegment(javax.vecmath.Point3d start, javax.vecmath.Point3d end, double angle) Sets the pick shape to a capped PickCone- Parameters:
start
- The start of axis of the coneend
- The end of the axis of the coneangle
- The angle of the cone
-
setShapeConeRay
public void setShapeConeRay(javax.vecmath.Point3d start, javax.vecmath.Vector3d dir, double angle) Sets the pick shape to an infinite PickCone.- Parameters:
start
- The start of axis of the conedir
- The direction of the axis of the coneangle
- The angle of the cone
-
getPickShape
Returns the PickShape for this object. -
getStartPosition
public javax.vecmath.Point3d getStartPosition()Returns the start postion used for distance measurement. -
pickAll
Selects all the nodes that intersect the PickShape.- Returns:
- An array of
PickInfo
objects which will contain information about the picked instances.null
if nothing was picked.
-
pickAny
Select one of the nodes that intersect the PickShape- Returns:
- A
PickInfo
object which will contain information about the picked instance.null
if nothing was picked.
-
pickAllSorted
Select all the nodes that intersect the PickShape, returned sorted. The "closest" object will be returned first. See note above to see how "closest" is determined.- Returns:
- An array of
PickInfo
objects which will contain information about the picked instances.null
if nothing was picked.
-
pickClosest
Select the closest node that intersects the PickShape. See note above to see how "closest" is determined.- Returns:
- A
PickInfo
object which will contain information about the picked instance.null
if nothing was picked.
-
getNode
Get the first node of a certain type up the SceneGraphPath- Parameters:
type
- the type of node we are interested in- Returns:
- a Node object
- Throws:
NullPointerException
- if pickInfo does not contain a Scenegraphpath or a picked node
-