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.ObjectThe 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 intTYPE_BRANCH_GROUPFlag to pass togetNode(int)to return aBranchGroupnode from theSceneGraphPath.static intTYPE_GROUPFlag to pass togetNode(int)to return aGroupnode from theSceneGraphPath.static intTYPE_LINKFlag to pass togetNode(int)to return aLinknode from theSceneGraphPath.static intTYPE_MORPHFlag to pass togetNode(int)to return aMorphnode from theSceneGraphPath.static intTYPE_PRIMITIVEFlag to pass togetNode(int)to return aPrimitivenode from theSceneGraphPath.static intTYPE_SHAPE3DFlag to pass togetNode(int)to return aShape3Dnode from theSceneGraphPath.static intTYPE_SWITCHFlag to pass togetNode(int)to return aSwitchnode from theSceneGraphPath.static intTYPE_TRANSFORM_GROUPFlag to pass togetNode(int)to return aTransformGroupnode from theSceneGraphPath.protected booleanuserDefineShape
-
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 BranchGroupgetBranchGroup()Returns the BranchGroup to be picked if the tool was initialized with a BranchGroup, null otherwise.intgetFlags()Gets the PickInfo content flags.LocalegetLocale()Returns the Locale to be picked if the tool was initialized with a Locale, null otherwise.intgetMode()Gets the picking detail mode.NodegetNode(PickInfo pickInfo, int type)Get the first node of a certain type up the SceneGraphPathPickShapegetPickShape()Returns the PickShape for this object.javax.vecmath.Point3dgetStartPosition()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.PickInfopickAny()Select one of the nodes that intersect the PickShapePickInfopickClosest()Select the closest node that intersects the PickShape.voidsetFlags(int flags)Sets the PickInfo content flags.voidsetMode(int mode)Sets the picking detail mode.voidsetShape(PickShape ps, javax.vecmath.Point3d startPt)Sets the pick shape to a user-provided PickShape objectvoidsetShapeBounds(Bounds bounds, javax.vecmath.Point3d startPt)Sets the pick shape to use a user-provided Bounds objectvoidsetShapeConeRay(javax.vecmath.Point3d start, javax.vecmath.Vector3d dir, double angle)Sets the pick shape to an infinite PickCone.voidsetShapeConeSegment(javax.vecmath.Point3d start, javax.vecmath.Point3d end, double angle)Sets the pick shape to a capped PickConevoidsetShapeCylinderRay(javax.vecmath.Point3d start, javax.vecmath.Vector3d dir, double radius)Sets the pick shape to an infinite PickCylinder.voidsetShapeCylinderSegment(javax.vecmath.Point3d start, javax.vecmath.Point3d end, double radius)Sets the pick shape to a capped PickCylindervoidsetShapeRay(javax.vecmath.Point3d start, javax.vecmath.Vector3d dir)Sets the pick shape to a PickRay.voidsetShapeSegment(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 aShape3Dnode from theSceneGraphPath.- See Also:
- Constant Field Values
-
TYPE_MORPH
public static final int TYPE_MORPH
Flag to pass togetNode(int)to return aMorphnode from theSceneGraphPath.- See Also:
- Constant Field Values
-
TYPE_PRIMITIVE
public static final int TYPE_PRIMITIVE
Flag to pass togetNode(int)to return aPrimitivenode from theSceneGraphPath.- See Also:
- Constant Field Values
-
TYPE_LINK
public static final int TYPE_LINK
Flag to pass togetNode(int)to return aLinknode from theSceneGraphPath.- See Also:
- Constant Field Values
-
TYPE_GROUP
public static final int TYPE_GROUP
Flag to pass togetNode(int)to return aGroupnode from theSceneGraphPath.- See Also:
- Constant Field Values
-
TYPE_TRANSFORM_GROUP
public static final int TYPE_TRANSFORM_GROUP
Flag to pass togetNode(int)to return aTransformGroupnode from theSceneGraphPath.- See Also:
- Constant Field Values
-
TYPE_BRANCH_GROUP
public static final int TYPE_BRANCH_GROUP
Flag to pass togetNode(int)to return aBranchGroupnode from theSceneGraphPath.- See Also:
- Constant Field Values
-
TYPE_SWITCH
public static final int TYPE_SWITCH
Flag to pass togetNode(int)to return aSwitchnode 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
PickInfoobjects which will contain information about the picked instances.nullif nothing was picked.
-
pickAny
public PickInfo pickAny()
Select one of the nodes that intersect the PickShape- Returns:
- A
PickInfoobject which will contain information about the picked instance.nullif 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
PickInfoobjects which will contain information about the picked instances.nullif 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
PickInfoobject which will contain information about the picked instance.nullif 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
-
-