Class PickResult
- java.lang.Object
-
- com.sun.j3d.utils.picking.PickResult
-
public class PickResult extends java.lang.Object
Stores information about a pick hit. Detailed information about the pick and each intersection of the PickShape with the picked Node can be inquired. The PickResult is constructed with basic information and more detailed information is generated as needed. The additional information is only available if capability bits on the scene graph Nodes are set properly;PickTool.setCapabilties(Node, int)
can be used to ensure correct capabilites are set. Inquiring data which is not available due to capabilties not being set will generate aCapabilityNotSet
exception.A PickResult can be used to calculate intersections on Node which is not part of a live scene graph using the constructor which takes a local to VWorld transformation for the Node.
Pick hits on TriangleStrip primitives will store the triangle points in the PickIntersection with the verticies in counter-clockwise order. For triangles which start with an odd numbered vertex this will be the the opposite of the order of the points in the TriangleStrip. This way the triangle in the PickIntersection will display the same was as the triangle in the strip.
If the Shape3D being picked has multiple geometry arrays, the arrays are stored in the PickResult and referred to by a geometry index.
If the Shape3D refers to a CompressedGeometry, the geometry is decompressed into an array of Shape3D nodes which can be inquired. The geometry NodeComponents for the Shape3D nodes are stored and used as if the Shape3D had multiple geometries. If there are multiple CompressedGeometries on the Shape3D, the decompressed Shape3Ds and GeometryArrays will be stored sequentially.
The intersection point for Morph nodes cannot be calculated using the displayed geometry due to limitations in the current Java3D core API (the current geometry of the the Morph cannot be inquired). Instead the geometry at index 0 in the Morph is used. This limitation may be eliminated in a future release of Java3D.
-
-
Field Summary
Fields Modifier and Type Field Description static int
BRANCH_GROUP
Flag to pass togetNode(int)
to return aBranchGroup
node from theSceneGraphPath
.static int
GROUP
Flag to pass togetNode(int)
to return aGroup
node from theSceneGraphPath
.static int
LINK
Flag to pass togetNode(int)
to return aLink
node from theSceneGraphPath
.static int
MORPH
Flag to pass togetNode(int)
to return aMorph
node from theSceneGraphPath
.static int
PRIMITIVE
Flag to pass togetNode(int)
to return aPrimitive
node from theSceneGraphPath
.static int
SHAPE3D
Flag to pass togetNode(int)
to return aShape3D
node from theSceneGraphPath
.static int
SWITCH
Flag to pass togetNode(int)
to return aSwitch
node from theSceneGraphPath
.static int
TRANSFORM_GROUP
Flag to pass togetNode(int)
to return aTransformGroup
node from theSceneGraphPath
.
-
Constructor Summary
Constructors Constructor Description PickResult(Node pn, Transform3D l2vw, PickShape ps)
Construct a PickResult using the Node and localToVWorld transformPickResult(SceneGraphPath sgp, PickShape ps)
Construct a PickResult using a SceneGraphPath
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PickIntersection
getClosestIntersection(javax.vecmath.Point3d pt)
Gets the PickIntersection in this PickResult that is closest to a pointShape3D[]
getCompressedGeometryShape3Ds()
Get the array of Shape3Ds that came from decompressing a CompressedGeometry on the picked node.boolean
getFirstPickEnable()
Return the "first intersection only" value.GeometryArray
getGeometryArray()
Get the GeometryArray at index 0 for the picked nodeGeometryArray[]
getGeometryArrays()
Get the array of GeometryArrays for the picked nodePickIntersection
getIntersection(int index)
Returns a specific PickIntersection objectTransform3D
getLocalToVworld()
Get the localToVworld transform for the NodeNode
getNode(int flags)
Get the first node of a certain type up the SceneGraphPathNode
getObject()
Get the picked nodePickShape
getPickShape()
Get the PickShape used for intersectionsSceneGraphPath
getSceneGraphPath()
Get the SceneGraphPath.int
numCompressedGeometryShape3Ds()
Get the number of Shape3Ds that came from decompressing a CompressedGeometry on the picked node.int
numGeometryArrays()
Get the number of GeometryArrays for the picked nodeint
numIntersections()
Returns the number of PickIntersections in the PickResult.void
setFirstIntersectOnly(boolean flag)
Set the PickResult to find only the first intersection of the PickShape with the Node.java.lang.String
toString()
Returns String representation
-
-
-
Field Detail
-
SHAPE3D
public static final int SHAPE3D
Flag to pass togetNode(int)
to return aShape3D
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
MORPH
public static final int MORPH
Flag to pass togetNode(int)
to return aMorph
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
PRIMITIVE
public static final int PRIMITIVE
Flag to pass togetNode(int)
to return aPrimitive
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
LINK
public static final int LINK
Flag to pass togetNode(int)
to return aLink
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
GROUP
public static final int GROUP
Flag to pass togetNode(int)
to return aGroup
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
TRANSFORM_GROUP
public static final int TRANSFORM_GROUP
Flag to pass togetNode(int)
to return aTransformGroup
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
BRANCH_GROUP
public static final int BRANCH_GROUP
Flag to pass togetNode(int)
to return aBranchGroup
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
SWITCH
public static final int SWITCH
Flag to pass togetNode(int)
to return aSwitch
node from theSceneGraphPath
.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PickResult
public PickResult(SceneGraphPath sgp, PickShape ps)
Construct a PickResult using a SceneGraphPath- Parameters:
sgp
- SceneGraphPath associated with this PickResultps
- The pickShape to intersect against
-
PickResult
public PickResult(Node pn, Transform3D l2vw, PickShape ps)
Construct a PickResult using the Node and localToVWorld transform- Parameters:
pn
- The picked node.l2vw
- The local to VWorld transformation for the nodeps
- The PickShape to intersect against- Throws:
java.lang.IllegalArgumentException
- If the node is not a Morph or Shape3D.
-
-
Method Detail
-
getSceneGraphPath
public SceneGraphPath getSceneGraphPath()
Get the SceneGraphPath. This will be null if the non SceneGraphPath constructor was used.
-
getLocalToVworld
public Transform3D getLocalToVworld()
Get the localToVworld transform for the Node
-
getGeometryArray
public GeometryArray getGeometryArray()
Get the GeometryArray at index 0 for the picked node
-
getGeometryArrays
public GeometryArray[] getGeometryArrays()
Get the array of GeometryArrays for the picked node
-
numGeometryArrays
public int numGeometryArrays()
Get the number of GeometryArrays for the picked node
-
numCompressedGeometryShape3Ds
public int numCompressedGeometryShape3Ds()
Get the number of Shape3Ds that came from decompressing a CompressedGeometry on the picked node.
-
getCompressedGeometryShape3Ds
public Shape3D[] getCompressedGeometryShape3Ds()
Get the array of Shape3Ds that came from decompressing a CompressedGeometry on the picked node.
-
getPickShape
public PickShape getPickShape()
Get the PickShape used for intersections
-
setFirstIntersectOnly
public void setFirstIntersectOnly(boolean flag)
Set the PickResult to find only the first intersection of the PickShape with the Node. The default isfalse
(all intersections are found)
-
getFirstPickEnable
public boolean getFirstPickEnable()
Return the "first intersection only" value.
-
numIntersections
public int numIntersections()
Returns the number of PickIntersections in the PickResult.- Returns:
- the number of intersections
-
getIntersection
public PickIntersection getIntersection(int index)
Returns a specific PickIntersection object- Parameters:
index
- the index number- Returns:
- the PickIntersection referenced by the index number
-
getClosestIntersection
public PickIntersection getClosestIntersection(javax.vecmath.Point3d pt)
Gets the PickIntersection in this PickResult that is closest to a point- Parameters:
pt
- the point to use for distance calculations- Returns:
- the closest PickIntersection object
-
toString
public java.lang.String toString()
Returns String representation- Overrides:
toString
in classjava.lang.Object
- Returns:
- string representation of this object
-
getObject
public Node getObject()
Get the picked node
-
getNode
public Node getNode(int flags)
Get the first node of a certain type up the SceneGraphPath- Parameters:
flags
- the type of node we are interested in- Returns:
- a Node object
-
-