> From: Roger Cottam <[EMAIL PROTECTED]>
>
> Does anyone have code they'd be willing to share to form a picking ray from
> the mouse position directly into the scene?  PickObject.generatePickRay
> states that the ray generated is from the viewer position in the direction
> of the x,y window coordinates.  

PickObject.generatePickRay() creates a pick ray in VWorld coordinates in the way 
I think you want.  Perhaps there is a bug.

Here is what PickObject.generatePickRay() does.  

First, it transforms the window x,y coordinates to image plate coordinates 
using:

    Canvas3D.getPixelLocationInImagePlate()
    
This gives a 3D point on the image plate (for a normal monitor setup, image 
plate coords are defined the origin at the lower left corner of the face of the 
monitor, so this point will be at z=0 in image plate coords).  

Next it inquires the eye position in image plate coords using:

    Canvas3D.getCenterEyeInImagePlate()
    
The eye is at a point in front of your monitor, centered on your window, and at 
a distance which depends on your field of view.
    
Then it inquires the image plate to VWorld transform using:

    Canvas3D.getImagePlateToVWorld();
    
This is the transform which moves from the physical world (image plate coords, 
units in meters), to the virtual world (VWorld coordinates, units in "virtual" 
meters).
    
It then transforms the window point and eye point into VWorld coordinates.  It 
then creates a PickRay from the eye point through the window point in VWorld 
coordinates.


> Picking a quad which is perpendicular to
> the view generates a bowing effect as the x,y gets farther from the center
> of the window - the distance to the plane naturally increases. 

I'm not sure what you mean by "bowing effect".  The quad/ray intersection should 
remain the same regardless of the distance from the center of the window, since 
the intersection is happening in VWorld coordinates.


> I want a
> consistent distance for the x,y coord to the plane in front of the view,
> which should be given correctly if the picking ray is from the 2D point
> projected on to the front of the frustum and the vector is in the direction
> of the view.  

Java3D uses the image plate instead of the front clip plane for this projection, 
since the image plate is defined to be the front face of the monitor.  

The front clipping plane is "virtual"-- it can be in front of or in back of the 
monitor face.

> I can easily get the direction vector of the view, but
> projecting the 2D mouse point to a 3D point on the front clipping plane is
> the problem I currently face and haven't been able to solve yet...

PickObject.generatePickRay should be doing what you are asking for. Perhaps 
there is a bug.  Can you send us a test case which shows what you mean?


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