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

Here is a solution using some of the cool new stuff in J3D 1.2:  Create a non
visible polygon which passes through the center of your data space and then use
the picking utilities to find a point on the polygon which is at the x,y screen
location.

Create your polygon and make it non-visible using

    RenderingAttributes.setVisible(false);

If possible, make the rest of your data non-pickable.

Generate your MC point using the pick utilities.  At init:

          PickCanvas pickCanvas = new PickCanvas(canvas, scene);
          pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);

Then for your mouse event:

          pickCanvas.setShapeLocation(mouseEvent);
          PickResult[] results = pickCanvas.pickAll();

The MC point will then be

        Point3d mcPoint = results[0].getIntersection(0).getPointCoordinates();

This assumes that the polygon is the only pickable part of your scene.  If not,
then you may get back more than one PickResult. You'll need to figure out which
PickResult has your polygon:

        if (results.length > 0) {
          for (int i = 0; i < results.length; i++) {
            if (results[i].getObject() == <your polygon>) {
                mcPoint = results[i].getIntersection(0).getPointCoordinates();
            }
          }
        }

If your data space can be rotated to any orientation, then this method may fail
because you rotate the pick polygon so that it is edge-on.  You can fix this by
making three polygons through your data space which are aligned with the X, Y
and Z axes, so that you will always get an intersection.  You can then use any
of the intersections of the PickRay with your polygons for your MC point.

Hope this helps,

Doug Gehringer
Sun Microsystems

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