Package com.sun.j3d.utils.pickfast
Class PickTool
- java.lang.Object
-
- com.sun.j3d.utils.pickfast.PickTool
-
- Direct Known Subclasses:
PickCanvas
public class PickTool extends java.lang.Object
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.
-
-
Field Summary
Fields Modifier and Type Field Description static int
TYPE_BRANCH_GROUP
Flag to pass togetNode(int)
to return aBranchGroup
node from theSceneGraphPath
.static int
TYPE_GROUP
Flag to pass togetNode(int)
to return aGroup
node from theSceneGraphPath
.static int
TYPE_LINK
Flag to pass togetNode(int)
to return aLink
node from theSceneGraphPath
.static int
TYPE_MORPH
Flag to pass togetNode(int)
to return aMorph
node from theSceneGraphPath
.static int
TYPE_PRIMITIVE
Flag to pass togetNode(int)
to return aPrimitive
node from theSceneGraphPath
.static int
TYPE_SHAPE3D
Flag to pass togetNode(int)
to return aShape3D
node from theSceneGraphPath
.static int
TYPE_SWITCH
Flag to pass togetNode(int)
to return aSwitch
node from theSceneGraphPath
.static int
TYPE_TRANSFORM_GROUP
Flag to pass togetNode(int)
to return aTransformGroup
node from theSceneGraphPath
.protected boolean
userDefineShape
-
Constructor Summary
Constructors Constructor Description PickTool(BranchGroup b)
Constructor with BranchGroup to be picked.PickTool(Locale l)
Constructor with the Locale to be picked.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BranchGroup
getBranchGroup()
Returns the BranchGroup to be picked if the tool was initialized with a BranchGroup, null otherwise.int
getFlags()
Gets the PickInfo content flags.Locale
getLocale()
Returns the Locale to be picked if the tool was initialized with a Locale, null otherwise.int
getMode()
Gets the picking detail mode.Node
getNode(PickInfo pickInfo, int type)
Get the first node of a certain type up the SceneGraphPathPickShape
getPickShape()
Returns the PickShape for this object.javax.vecmath.Point3d
getStartPosition()
Returns the start postion used for distance measurement.PickInfo[]
pickAll()
Selects all the nodes that intersect the PickShape.PickInfo[]
pickAllSorted()
Select all the nodes that intersect the PickShape, returned sorted.PickInfo
pickAny()
Select one of the nodes that intersect the PickShapePickInfo
pickClosest()
Select 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
setShape(PickShape ps, javax.vecmath.Point3d startPt)
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 Detail
-
TYPE_SHAPE3D
public static final int TYPE_SHAPE3D
Flag to pass togetNode(int)
to return aShape3D
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
TYPE_MORPH
public static final int TYPE_MORPH
Flag to pass togetNode(int)
to return aMorph
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
TYPE_PRIMITIVE
public static final int TYPE_PRIMITIVE
Flag to pass togetNode(int)
to return aPrimitive
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
TYPE_LINK
public static final int TYPE_LINK
Flag to pass togetNode(int)
to return aLink
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
TYPE_GROUP
public static final int TYPE_GROUP
Flag to pass togetNode(int)
to return aGroup
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
TYPE_TRANSFORM_GROUP
public static final int TYPE_TRANSFORM_GROUP
Flag to pass togetNode(int)
to return aTransformGroup
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
TYPE_BRANCH_GROUP
public static final int TYPE_BRANCH_GROUP
Flag to pass togetNode(int)
to return aBranchGroup
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
TYPE_SWITCH
public static final int TYPE_SWITCH
Flag to pass togetNode(int)
to return aSwitch
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
userDefineShape
protected boolean userDefineShape
-
-
Constructor Detail
-
PickTool
public PickTool(BranchGroup b)
Constructor with BranchGroup to be picked.
-
PickTool
public PickTool(Locale l)
Constructor with the Locale to be picked.
-
-
Method Detail
-
getBranchGroup
public BranchGroup getBranchGroup()
Returns the BranchGroup to be picked if the tool was initialized with a BranchGroup, null otherwise.
-
getLocale
public Locale getLocale()
Returns the Locale to be picked if the tool was initialized with a Locale, null otherwise.
-
setShape
public void setShape(PickShape ps, javax.vecmath.Point3d startPt)
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
public void setShapeBounds(Bounds bounds, javax.vecmath.Point3d startPt)
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:
java.lang.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:
java.lang.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
public PickShape getPickShape()
Returns the PickShape for this object.
-
getStartPosition
public javax.vecmath.Point3d getStartPosition()
Returns the start postion used for distance measurement.
-
pickAll
public PickInfo[] 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
public PickInfo 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
public PickInfo[] 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
public PickInfo 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
public Node getNode(PickInfo pickInfo, int type)
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:
java.lang.NullPointerException
- if pickInfo does not contain a Scenegraphpath or a picked node
-
-