public class PickTool extends Object
The pick mode specifies the detail level of picking before the PickResult is returned:
The utility method
PickTool.setCapabilities(Node, int)
can be used before the scene graph is
made live to set the
capabilities of Shape3D, Morph or Geometry
nodes to allow picking.
A PickResult from a lower level of detail pick can be used to inquire more detailed information if the capibility bits are set. This can be used to filter the PickResults before the more computationally intensive intersection processing. For example, the application can do a BOUNDS pick and then selectively inquire intersections on some of the PickResults. This will save the effort of doing intersection computation on the other PickResults. However, inquiring the intersections from a GEOMETRY pick will make the intersection computation happen twice, use GEOMETRY_INTERSECT_INFO if you want to inquire the intersection information on all the PickResults.
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.
Morph nodes cannot be picked using the displayed geometry in GEOMETRY_INTERSECT_INFO mode due to limitations in the current Java3D core API (the current geometry of the the Morph cannot be inquired). Instead they are picked using the geometry at index 0 in the Morph, this limitation may be eliminated in a future release of Java3D.
If the pick shape is a PickBounds, the pick result will contain only the scene graph path, even if the mode is GEOMETRY_INTERSECT_INFO.
Modifier and Type | Field and Description |
---|---|
static int |
BOUNDS
Use this mode to pick by bounds and get basic information
on the pick.
|
static int |
GEOMETRY
Use this mode to pick by geometry and get basic
information on the pick.
|
static int |
GEOMETRY_INTERSECT_INFO
Use this mode to pick by geometry and save
information about the intersections (intersected primitive,
intersection point and closest vertex).
|
static int |
INTERSECT_COORD
Flag to pass to
setCapabilities(Node, int) |
static int |
INTERSECT_FULL
Flag to pass to
setCapabilities(Node, int) |
static int |
INTERSECT_TEST
Flag to pass to
setCapabilities(Node, int) |
protected boolean |
userDefineShape |
Constructor and Description |
---|
PickTool(BranchGroup b)
Constructor with BranchGroup to be picked.
|
PickTool(Locale l)
Constructor with the Locale to be picked.
|
Modifier and Type | Method and Description |
---|---|
BranchGroup |
getBranchGroup()
Returns the BranchGroup to be picked if the tool was initialized
with a BranchGroup, null otherwise.
|
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.
|
PickShape |
getPickShape()
Returns the PickShape for this object.
|
Point3d |
getStartPosition()
Returns the start postion used for distance measurement.
|
PickResult[] |
pickAll()
Selects all the nodes that intersect the PickShape.
|
PickResult[] |
pickAllSorted()
Select all the nodes that intersect the
PickShape, returned sorted.
|
PickResult |
pickAny()
Select one of the nodes that intersect the PickShape
|
PickResult |
pickClosest()
Select the closest node that
intersects the PickShape.
|
Locale |
setBranchGroup(Locale l)
Deprecated.
This method does nothing other than return its
input parameter.
|
static void |
setCapabilities(Node node,
int level)
Sets the capabilities on the Node and it's components to allow
picking at the specified detail level.
|
void |
setMode(int mode)
Sets the picking detail mode.
|
void |
setShape(PickShape ps,
Point3d startPt)
Sets the pick shape to a user-provided PickShape object
|
void |
setShapeBounds(Bounds bounds,
Point3d startPt)
Sets the pick shape to use a user-provided Bounds object
|
void |
setShapeConeRay(Point3d start,
Vector3d dir,
double angle)
Sets the pick shape to an infinite PickCone.
|
void |
setShapeConeSegment(Point3d start,
Point3d end,
double angle)
Sets the pick shape to a capped PickCone
|
void |
setShapeCylinderRay(Point3d start,
Vector3d dir,
double radius)
Sets the pick shape to an infinite PickCylinder.
|
void |
setShapeCylinderSegment(Point3d start,
Point3d end,
double radius)
Sets the pick shape to a capped PickCylinder
|
void |
setShapeRay(Point3d start,
Vector3d dir)
Sets the pick shape to a PickRay.
|
void |
setShapeSegment(Point3d start,
Point3d end)
Sets the pick shape to a PickSegment.
|
protected boolean userDefineShape
public static final int BOUNDS
public static final int GEOMETRY
public static final int GEOMETRY_INTERSECT_INFO
public static final int INTERSECT_TEST
setCapabilities(Node, int) to set
the Node's capabilities to allow intersection tests, but not
inquire information about the intersections (use for GEOMETRY mode).
public static final int INTERSECT_COORD
setCapabilities(Node, int) to set
the Node's capabilities to allow inquiry of the intersection
coordinate information.
public static final int INTERSECT_FULL
setCapabilities(Node, int) to set
the Node's capabilities to allow inquiry of all intersection
information.
public PickTool(BranchGroup b)
public PickTool(Locale l)
public BranchGroup getBranchGroup()
public Locale getLocale()
public Locale setBranchGroup(Locale l)
public static void setCapabilities(Node node, int level)
Note that by default all org.scijava.java3d.utils.geometry.Primitive objects with the same parameters share their geometry (e.g., you can have 50 spheres in your scene, but the geometry is stored only once). Therefore the capabilities of the geometry are also shared, and once a shared node is live, the capabilities cannot be changed. To assign capabilities to Primitives with the same parameters, either set the capabilities before the primitive is set live, or specify the Primitive.GEOMETRY_NOT_SHARED constructor parameter when creating the primitive.
node
- The node to modifylevel
- The capability level, must be one of INTERSECT_TEST,
INTERSECT_COORD or INTERSECT_FULLIllegalArgumentException
- if Node is not a Shape3D or Morph or
if the flag value is not valid.RestrictedAccessException
- if the node is part
of a live or compiled scene graph.public void setShape(PickShape ps, Point3d startPt)
ps
- The pick shape to pick against.startPt
- The start point to use for distance calculationspublic void setShapeBounds(Bounds bounds, Point3d startPt)
bounds
- The bounds to pick against.startPt
- The start point to use for distance calculationspublic void setMode(int mode)
mode
- One of BOUNDS, GEOMETRY, GEOMETRY_INTERSECT_INFO, orIllegalArgumentException
- if mode is not a legal valuepublic int getMode()
public void setShapeRay(Point3d start, Vector3d dir)
start
- The start of the raydir
- The direction of the raypublic void setShapeSegment(Point3d start, Point3d end)
start
- The start of the segment
p @param end The end of the segmentpublic void setShapeCylinderSegment(Point3d start, Point3d end, double radius)
start
- The start of axis of the cylinderend
- The end of the axis of the cylinderradius
- The radius of the cylinderpublic void setShapeCylinderRay(Point3d start, Vector3d dir, double radius)
start
- The start of axis of the cylinderdir
- The direction of the axis of the cylinderradius
- The radius of the cylinderpublic void setShapeConeSegment(Point3d start, Point3d end, double angle)
start
- The start of axis of the coneend
- The end of the axis of the coneangle
- The angle of the conepublic void setShapeConeRay(Point3d start, Vector3d dir, double angle)
start
- The start of axis of the conedir
- The direction of the axis of the coneangle
- The angle of the conepublic PickShape getPickShape()
public Point3d getStartPosition()
public PickResult[] pickAll()
PickResult
objects which will contain
information about the picked instances. null
if nothing was
picked.public PickResult pickAny()
PickResult
object which will contain
information about the picked instance. null
if nothing
was picked.public PickResult[] pickAllSorted()
PickResult
objects which will contain
information
about the picked instances. null
if nothing was picked.public PickResult pickClosest()
PickResult
object which will contain
information about the picked instance. null
if nothing
was picked.Copyright © 2016–2022 SciJava. All rights reserved.