> Date:         Tue, 23 Jul 2002 15:42:28 +0530
> From: "Nitin.Jain" <[EMAIL PROTECTED]>
>
> I have a point array in my view. I want to have a pick utility which picks
> one of these points, even if it is not clicked very near to the point. I'm
> creating a Cylindrical PickRay for that with the required radius.
>
> The Pick works fine in the initial view but when I rotate the view it does
> not pick the point properly. I'm doing a
> getPixelLocationInImagePlate( x,  y, p3d) to get the point corresponding to
> the mouise click, then I'm transforming the point with the transform of
> getImagePlateToVworld(Tranform3d) and setting this point as the origin of
> the ray and the direction is taken as the opposite of the 'z' parameter of
> this point(I think this is the place where I'm screwing this up)

You need to use the vector from the eyepoint to the transformed mouse point as
the direction.

If you're using the default view attach policy of NOMINAL_HEAD and the default
eyepoint policy of RELATIVE_TO_FIELD_OF_VIEW, then the origin of the view
platform is the eyepoint.  You can then get the eyepoint from the translation
components of the view platform's local to vworld transform, using
vp.getLocalToVWorld(Transform3D t) and then t.get(Vector3d v).

If you're not using those default policies, then you need to get the eyepoint
from Canvas3D.getCenterEyeInImagePlate() and then transform it with the matrix
you get from getImagePlateToVworld().  You may also need to do this if you're
using SimpleUniverse or ConfiguredUniverse to build the view side of the scene
graph, since the view platform will be live at that point and the capability to
get its local to vworld won't be set (or you could detach the ViewingPlatform
branch group first).

This is essentially what PickCanvas.setShapeLocation() does for you, except
that it creates a PickConeRay for perspective projections.  Are you sure you'd
rather have a CylinderRay?  That would effectively make the pick tolerance
smaller the further away your pickable objects are.

-- Mark Hood

===========================================================================
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