> From: Adam Belmont <[EMAIL PROTECTED]>
> 
> I am trying to pick points (which may be as small as a pixel) and lines
> in a Canvas3D.
> I 'm using PickObject.java from the utilities package. Problem is that
> it is very difficult to pick the exact spot on the screen with the
> mouse. So I'd like to be able to give a bit of variable tolerance the
> picking mechanism.
> I see that PickObject generates a PickRay and then attempts to intersect
> it with objects found underneath the picking location.  I think a
> solution for this problem would be to vary the diameter of the PickRay,
> in effect creating a PickCylinder instead.

I'll be replying to this in several parts. I've got new picking utilities and a 
example which shows how they are used, but the mailing list software won't allow 
me to post a message larger than 40K.

This message will tell you about the pieces to come.  The following messages 
will have:
        
        PickingExt.jar     -- source for a replacement for the picking utilities
        PickingExtDoc.jar  -- documentation for the new utilities
        PickingExtTest.jar -- files to add to the PickTest example directory
                              to show how the new picking works.
                             
Here are the details:

Picking lines and points requires a PickShape which can intersect with the 
primtives.  J3D 1.1 supports picking using a Bounds object for the pick shape 
and a BoundingPolytope can be used to make a volume represents the area around 
the mouse position.  The problems is that the picking utilities in J3D 1.1 only 
understand how to generate PickRay's, not PickBounds.

The pickingExt package extends the com.sun.j3d.utils.behaviors.picking package 
to support line/point picking using a pick "aperture".  The aperture is a closed 
loop of points around 0,0 in window coordinates (see PickObject.java).  When 
using an aperture, the utility will generate a bounding polytope which extends 
from the eye through the edges of the pick aperature.  

The default aperture is a 4 pixel square around the mouse point. The result is 
similar to using a pick cylinder as other emails have suggested.

A couple notes:

1) We are distributing the updated version of the picking utilities as source 
since we can't update the "official" utilties until J3D 1.2.  If you like, you 
can change the package for the utilities to 
com.sun.j3d.utils.behaviors.pickingExt, but you are responsible for building and 
maintaining the extended utilities.  I'll be posting updated versions of these 
utilities to the interest alias if bug fixes or extensions are needed.

2) Both the SHAPE_RAY and SHAPE_APERTURE modes work correctly under parallel and 
perspective views.

3) J3D 1.1.1 has a couple bugs which show up when using these utilties.  First, 
only the endpoints of lines can be picked for SHAPE_APERTURE picking.  Second, 
the "bounds" picking test will fail for SHAPE_APERTURE picking, so use 
SHAPE_RAY_APERTURE for best results.  Both these bugs will be fixed in the 
upcoming 1.1.2 release.

4) For doing pick aperture picking, the best performance comes from using 
SHAPE_RAY_APERTURE mode.  This uses a pick ray for the "bounds" phase of picking 
and then a pick aperture for the "geometry" phase of picking.

Hope this helps.  Let me know if you have problems,

Doug Gehringer
Sun Microsystems

=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to