Holds information about an intersection of a PickShape with a Node
as part of a PickResult. Information about
the intersected geometry, intersected primitive, intersection point, and
closest vertex can be inquired.
The intersected geometry is indicated by an index into the list of
geometry arrays on the PickResult. It can also be inquired from this
object.
The intersected primitive indicates which primitive out of the GeometryArray
was intersected (where the primitive is a point, line, triangle or quad,
not a
com.sun.j3d.utils.geometry.Primitive) .
For example, the intersection would indicate which triangle out of a
triangle strip was intersected.
The methods which return primitive data will have one value if the primitive
is
a point, two values if the primitive is a line, three values if the primitive
is a triangle and four values if the primitive is quad.
The primitive's VWorld coordinates are saved when then intersection is
calculated. The local coordinates, normal, color and texture coordinates
for the primitive can also be inquired if they are present and readable.
The intersection point is the location on the primitive which intersects the
pick shape closest to the center of the pick shape. The intersection point's
location in VWorld coordinates is saved when the intersection is calculated.
The local coordinates, normal, color and texture coordiantes of at the
intersection can be interpolated if they are present and readable.
The closest vertex is the vertex of the primitive closest to the intersection
point. The vertex index, VWorld coordinates and local coordinates of the
closest vertex can be inquired. The normal, color and texture coordinate
of the closest vertex can be inquired from the geometry array:
Vector3f getNormal(PickIntersection pi, int vertexIndex) {
int index;
Vector3d normal = new Vector3f();
GeometryArray ga = pickIntersection.getGeometryArray();
if (pickIntersection.geometryIsIndexed()) {
index = ga.getNormalIndex(vertexIndex);
} else {
index = vertexIndex;
}
ga.getNormal(index, normal);
return normal;
}
The color, normal
and texture coordinate information for the intersected primitive and the
intersection point
can be inquired
the geometry includes them and the corresponding READ capibility bits are
set.
PickTool.setCapabilties(Node, int)
can be used to set the capability bits
to allow this data to be inquired.
|