Hi Daniel,

I don't know if you're still looking for how to do this, but i thought I'd contribute 
this bit.

If you're just trying to find the co-ordinate of the intersection point, you can use 
the PickIntersection class:

PickResult result = pickCanvas.pickClosest();
PickIntersection intersection =
  result.getClosestIntersection(pickCanvas.getStartPosition());
Point3d intersectionPoint = intersection.getPointCoordinatesVW();

Alternatively, you could use PickIntersection.getCoordinates() for a local coordinate.

Note: You need to set the GEOMETRY capability bit of your geometry using the 
PickTool.setCapabilities() method.

As a question for everyone, it seems that there may be a bug with 
PickCanvas.pickClosest(). The code snippet above does not always return the closest 
intersection in some of my complex scenes. If, however, I use the following code:

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;
            }
        }
    }
}

it works. I assumed the two would return the equivilent result, but it appears that 
PickCanvas.pickClosest() does not return the Node containing the closest intersection 
to the start point.

josh

On Sat, 13 Jan 2001 15:24:14 +0800, Daniel Balaguer Yagan <[EMAIL PROTECTED]> wrote:

>hi there,
>        just one question on the class PickPoint. I want to pick a point
>using PickCanvas. I have already set the shape location (by using
>pickCanvas.setShapeLocation(mouseEvent).  and the mode
>(PickCanvas.GEOMETRY).
>         I want to get, a PickPoint, is this the way to do it?
>
>        PickResult result = pickCanvas.pickClosest();
>        if (result!=null) PickShape shape =  result.getPickShape();
>        if (shape!=null && (shape instanceof PickPoint))
>                PickPoint pickPoint = (PickPoint) shape;
>
>        After getting the point, I want to get the location. I know that
>class PickPoint has only 2 main methods (set() and get() ). But the get()
>method does not return the location (it is a void method) and accepts a
>Point3d object as parameter.
>        How do you get the location of this pickpoint?
>
>thanks,
>daniel
>
>
>
> ==========================================================================
>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".

Reply via email to