Hi,
   The problem is that the redering process necessarily looses information
in the conversion from 3D to 2D and there is no way to go back and
explicitly reconstruct it.  If you think about a perspective view and the
view frustrum, the pixel data at any x - y coordinate on the image plate
originates from objects which lie along a line of sight from the view point
to infinity which goes through the point specified on the image plate.  For
example, if you have two objects, one at z distance 5 and another at
distance 10 and both with the same relative x-y coordinates, when projected
the closer object will be twice as far from the center of the view as the
more distant object (If you don't belive me, look straight ahead at the wall
and stick a finger out.  If you move the finger closer, while maintaining
movement perpendicular to the wall, the finger starts to move to the edge of
your periphial vision.)
  To find your x,y,z position you have to know something about the scene.
The imagePlateToVirtualWorld() will give you a percentage of left/right and
up/down that the screen point is relative to the field of view in the
virtual world.  If, for example, your view frustrum was plus/minus 45
degrees from the center of view, and the returned position is 0.5, then an
object 100 units from the view point will be 50 units off center from the
line of sight.  You can now compute a vector by starting at the point of
view and pointing in the direction of the off center point.  Run a collision
intercept (eg., pickRay) and the first object it intersects is what you're
looking at (presuming it wasn't transparent).  Now you have the distance
along the line of sight to the actual object and you can go back and
calculate the real x,y,z coordinates.
  Example:  view angle 45 deg
                  view point = 100, 0, 0
                  look at point    = 0,0,0
                  mouse click returns -0.5,0
                        Mouse tells us object is 50% distance to left of
screen and on vertical centerline
                        Since looking toward orign from down the x axis (and
45deg view angle), we know    that at x = 0 the screen  will display the
virtual world at plus minus y = 100 and z = 100.  Pick vector endpoint as z
= 50, y = 0.
                         Run pick ray
                         Assume returned object is cube of 50 units on a
side with one corner at 0,0,0 and the diagonal at 50,50,50.  Run the
calculation of where the pick ray intercepted the cube and you will get the
virtual world x, y, z coordinates as 50, 0, 25 (presuming I didn't make some
simple mistake in this ad hoc example).
    I know that this is a somewhat long winded explanation but I hope it
gets the point across.  There is room for improvement when you acutally
encode it.
                Gary



Gregory Bradford wrote:

> Dear Java3d users
>
> I have a Canvas3d object which has a pixel x and pixel y position (say a
> mouse click) for which I'm interested
> in finding my data value.
>
> To explain, I've put into my 3d model only PointArray objects whose
> coordinate values are between -2000.0 and
> 2000.0 on any of the three axis.  The actual data isn't important, what
> is important is that I have data whose x coordinates can range from
> -2000.0 to 2000.0.  As well as the Y and the Z data.
>
> Assume that at least some of my data, but not all, shows up in the view
> (good field of view, translation, rotation, scale, etc.).
>
> Now all I want to do is supply a (valid for my canvas) pixel X and Y and
> get back a Point3d which indicates what value the pixel X and Y are in
> my data's coordinate system.  Thus I need to get back something like
> 233.0, -1387.0, 345.0.
>
> Can somebody get me over this hump in the road.  I need a "complete
> solution" that works from beginning to end.
>
> I've tried the following:
>
>   TransformGroup     vp_trans = null;
>  ....
>   Point3d position = new Point3d ( );
>   canvas.getPixelLocationInImagePlate(pixel_x, pixel_y, position);
>   Transform3D ctf = new Transform3D();
>   vp_trans.getTransform ( ctf );
>   canvas.getImagePlateToVworld( ctf );
>   ctf.transform(position_b);
>
> but the values of position.x and position.y always are between -1.0 and
> 1.0, with 0.0 always being at the center of the canvas.  Do I need to
> multiply these returned values by something?
>
> Thanks in advance,
>
> Gregory Bradford

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