< Zurück | Inhalt | Weiter >

16.3 PickTool

java.lang.Object

|

+−−com.sun.j3d.utils.picking.PickTool


PickTool is the base class for picking operations. The picking methods will return a PickResult 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 PickResult is returned (see table 16.2).


Table 16.2 PickTools


PickTool Mode

Description


BOUNDS

Pick using the bounds of the pickable nodes. The PickResult returned will contain the SceneGraphPath to the picked Node.

GEOMETRY

Pick using the geometry of the pickable nodes. The PickResult returned will contain


the SceneGraphPath to the picked Node. Geometry nodes in the scene must have the ALLOW_INTERSECT capability set for this mode.


GEOMETRY_INTERSECT_INFO

Same as GEOMETRY, but the PickResult will include information on each intersection of the pick shape with the geometry. The intersection information includes the subprimitive picked (i.e., the point, line, triangle, or quad), the closest vertex to the center of the pick shape, and the intersection's coordinate, normal, color, and texture coordinates. To allow this to be generated, Shape3D and Morph nodes must have the ALLOW_GEOMETRY_READ capability set, and GeometryArrays must have the ALLOW_FORMAT_READ, ALLOW_COUNT_READ, and ALLOW_COORDINATE_READ

capabilities set, plus the ALLOW_COORDINATE_INDEX_READ

capability for indexed geometry. To query the intersection color, normal, or texture coordinates, the corresponding READ capability bits must be set on the

GeometryArray.

The utility method PickTool.setCapabilities(Node, int) can be used before the scenegraph 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 about more detailed information if the capability 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 query intersections on some of the PickResults. This will save the effort of doing intersection computation on the other PickResults. However, querying the intersections from a GEOMETRY pick will make the intersection computation happen twice, so 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 Morph cannot be queryed). Instead, they are picked by 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 scenegraph path, even if the mode is

GEOMETRY_INTERSECT_INFO.