Hi everyone,
I think I posted this bug some time ago, but thought I'd give it a whirl with the
newest release. I find that using PickCanvas.pickClosest does not always return the
result nearest the user. Usually if the point is wrong, it's on the surface furthest
from the viewplatform along the ray of intersection. I have code that does what I
expect it to for comparison below:
PickIntersection pi;
Point3d closestPoint1, closestPoint2;
// pick all objects under the x, y position
pickCanvas.setShapeLocation(x, y);
// Get all results and the "closest" result
PickResult results[] = pickCanvas.pickAll();
PickResult closest = pickCanvas.pickClosest();
Point3d start = pickCanvas.getStartPosition();
/*
* This is my simple algorithm that always finds the right closestPoint
*/
if (results !=null) {
Point3d nearest, cur;
double minDist = Double.MAX_VALUE;
// Search for the nearest intersection of all objects
for (int r = 0; r < results.length; r++) {
if (results[r].numIntersections() > 0) {
pi = results[r].getClosestIntersection(start);
if (pi != null) {
cur = pi.getPointCoordinatesVW();
double d = cur.distance(start);
if (d < minDist) {
minDist = d;
closestPoint1 = cur;
}
}
}
} // end nearest intersection search
/*
* This is the shortest code, but closestPoint2 is not the same as closestPoint1
*/
if (closest != null) {
pi = closest.getClosestIntersection(start);
if (pi != null)
Point3d closestPoint2 = pi.getPointCoordinatesVW();
}
==========================================================================To
unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".