Hi Karsten and Daniel,
I found the same problem as well. Is this a bug with PickCanvas? I also found that the
code snippet Daniel suggests does not always return the closest intersection (although
theoretically it should). I've found that the following loop always returns the
nearest intersection:
Point3d startPosition = pickCanvas.getStartPosition()
PickResult[] results = pickCanvas.pickAll();
for (int r = 0; r < results.length; r++) {
if (results[r].numIntersections() > 0) {
PickIntersection pi =
results[r].getClosestIntersection(startPosition);
if (pi != null) {
currentPoint = pi.getPointCoordinatesVW();
double d = currentPoint.distance(startPosition);
if (d < minDist) {
minDist = d;
intersectionPoint = currentPoint;
}
}
}
}
josh
>>> [EMAIL PROTECTED] 02/05/01 06:37AM >>>
I'm using multiple geometries in the same Shape3d, and was getting the same
results you mention (farthest object always got picked). Others posted the
solution to this problem on this list. Here's what I use:
pickCanvas.setShapeLocation(currentEvent);
// get the starting position of the pick
Point3d eyePos = pickCanvas.getStartPosition();
// the pickClosest returns a PickResult with the picks sorted by the
distance
// from the ViewPlatform to the intersection point.
PickResult pickResult = pickCanvas.pickClosest();
if (pickResult != null) {
PickIntersection pi =
pickResult.getClosestIntersection(eyePos);
int index = pi.getGeometryArrayIndex();
......
}
Hope this helps
Daniel Dvorak
-----Original Message-----
From: Karsten Fries [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 05, 2001 6:28 AM
To: [EMAIL PROTECTED]
Subject: [JAVA3D] Picking problems
Hi all,
i have a tiny problem with picking. Almost everything is fine. But i get a
strange behavior using
PickCanvas of the utilities calling its pickClosest() method. The
intersections i get are still ok, but
my interest lies in the picked node. And it appears to me that in all cases
never the nearest objects
node is retrived using getObject() or getNode( PickResult.SHAPE3D ) of the
PickResult.
even more confusing: in the majority of the cases i have the impression that
the object with the
greatest distance is picked.
is this something known??? has someone a workaround or is this fixed in the
newest beta??
i'm currently using 1.2.1 beta 1
Thanks for any comments on this,
Karsten
===========================================================================
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".
===========================================================================
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".
===========================================================================
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".