Dear Ravi,
The following should get you close:
//VVVVVVVVVVVVVVVVVVVVVVVVVVVVCut
belowVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
/**
* determines a corresponding virtual world point given a canvas
point.
*
* @params int x, int y the x,y points on the canvas as returned by
mouse, etc.
* @return Point3d a virtual world point corresponding to the canvas
point
* provided.
*/
public Point3d getCanvasPtToVworldPt(int x, int y)
{
Point3d VworldPt = new Point3d();
Point3d centerEyePt = new Point3d();
// convert the canvas point to ImagePlate coords
canvas.getPixelLocationInImagePlate(x, y, VworldPt);
// transform the point from an imageplate coordinate to a Vworld
// coordinate
Transform3D imagePlateToVworld = new Transform3D();
canvas.getImagePlateToVworld(imagePlateToVworld);
imagePlateToVworld.transform(VworldPt);
canvas.getCenterEyeInImagePlate(centerEyePt);
imagePlateToVworld.transform(centerEyePt);
//Logging.trace(10, "Center eye pt VW " + centerEyePt);
//now compute the z=0 value in the centereye to VworldPt pt
//centerEyePt_VworldPt = alpha *centerEyePt_planePt with planePt.z=0;
double alpha = 0.0;
if ( VworldPt.z != centerEyePt.z )
{
alpha = centerEyePt.z /(VworldPt.z - centerEyePt.z);
}
/*
// The following may work for Z, I haven't tested it
double beta = 0.0;
if ( VworldPt.y != centerEyePt.y )
{
beta = centerEyePt.y /(VworldPt.y - centerEyePt.y);
}
*/
Point3d planePt = new Point3d ( centerEyePt.x - alpha * ( VworldPt.x -
centerEyePt.x )
, centerEyePt.y - alpha * ( VworldPt.y -
centerEyePt.y )
, 0.0 // centerEyePt.z - beta * (
VworldPt.z - centerEyePt.z )
);
return planePt;
}
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Cut
above^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Hope this helps...
BTW, I believe this code was originally posted by Olivier Fillon to this
discussion list. I claim no credit for it.
I would suggest to the Sun engineers to include this functionality (or
something similar), and the inverse of this functionality, in their
demo/example Java3d code snippets distributed with Java3d.
Regards,
Gregory Bradford
> Ravi Goel wrote:
>
> hi ...is it possible to convert the mouse click position pixel value
> into the physical world size in meters...there was something given in
> the canvas3d class....but i couldn't follow...can anybody plz help
> me...
>
> thanks
> ravi
begin:vcard
n:Bradford;Gregory
tel;fax:408-736-8447
tel;work:408-736-2822
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:[EMAIL PROTECTED]
fn:Gregory Bradford
end:vcard