> Date:         Mon, 22 Jul 2002 17:12:21 +0530
> From: Srikanth Vavilapalli <[EMAIL PROTECTED]>
>
> I'm a beginner in Java3D and I'd like to know how to Convert a 3D point from
> Virtual World to Scree Points/Coordinates(2D). Presently I am having code
> for converting screen coordinates(2D) to 3D point (as below) where x,y are
> screen coordinates.
> [...]
> When I am doing same thing in reverse for 3D to 2D point conversion as
> below, The values are not coming properly (My Canvas3D height and width are
> 589 and 512. So values should lie in between this. But the output points are
> having some minus values).

Your code looks OK and I haven't been able to see a problem in the tests I
performed.  Could be a couple things going on.

One thing to note is that getImagePlateToVworld() and getVworldToImagePlate()
are not synchronized with the view.  This is bug 4363761, which we can't fix in
the current architecture of Java 3D.  If you have a dynamically changing view
while running your point conversion code, then those methods will always
reflect the position and orientation of the view from the last frame.  There is
a Java 3D request for enhancement (RFE 4707462) that should provide a
workaround for the 1.4 release.

It's also possible that when you're converting from 3D to 2D you may be trying
to transform 3D points outside of the current view frustum (that is, they would
normally be clipped away).  This would give you back 2D points that are outside
of your canvas.

You should also make sure that you're not converting from 2D to 3D, altering
the view, and then converting the resulting 3D point back to 2D -- you'll get a
different canvas position, possibly outside the canvas.

If none of those apply, send us a test case demonstrating the problem and we'll
investigate it.

-- Mark Hood

>          public Point3d get2DTo3DPoint(int x , int y)
>          {
>             Point3d point3d =new Point3d();
>             this.canvas3D.getPixelLocationInImagePlate(x, y, point3d);
>             Transform3D temp = new Transform3D();
>             this.canvas3D.getImagePlateToVworld(temp);
>             temp.transform(point3d);
>             return point3d;
>          }
>
>          public Point2d get3DTo2DPoint(Point3d point3d)
>          {
>
>             Transform3D temp = new Transform3D();
>             this.canvas3D.getVworldToImagePlate(temp);
>             temp.transform(point3d);
>             Point2d point2d =new Point2d();
>             this.canvas3D.getPixelLocationFromImagePlate(point3d,point2d);
>             return point2d;
>          }

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