Rory Douglas wrote:
>
> Hi there
>
> >From this discussion I was just wondering, what does the method
> getImagePlateToVworld() in Canvas3D actually do?
> I realise it can't give you one of the co-ordinates,but which one?  Does the
> transform returned correspond to the inverse of the matrix that takes
> Normalised Projection co-ords into screen space?

Hi Rory, here is an example (from 3D User Interfaces whith Java3D)
how to use getImagePlateToVworld():

Canvas3dD canvas;
int mouseX, mouseY;

Point3d rayOrg = new Point3d();
Vector3d rayDir = new Vector3d();

// Get eye position in view space
Point3d eyePos = new Point3d();
canvas.getCenterEyeInImageOlate(eyePos);

// Translate mouse canvas position to view space
Point3d mousePos = new Point3d();
canvas.getPixelLocationInImagePlate(mouseX, mouseY, mousePos);

//Get the view-to-world transform
Transform3D xform = new Transform3D();
canvas.getImagePlateToVworld(xform);

//transform eye and mouse from view to world space
xform.transform(eyePos);
xform.transform(mousePos);

//save the world pick ray origin
rayOrg.set(eyePos);

//build the world pick ray direction

rayDir.sub(mousePos, rayOrg);
rayDir.normalize()

//build pick ray

PickRay ray = new PickRay(rayOrg,rayDir);

//throw the pick ray into the scene at all leaf shape
// nodes under pick root (e.g. Branchgroup)

Scengraph paths[] = root.pickAllSorted(ray)

Now you use this to determine the hit point with objects in the scene,
which in fact will give you a point with 3 coordinates (x,y,z).

For 2 of these points it's easy to compute their distance.

Hope it helps

Joerg
--

  http://w5.cs.uni-sb.de/~baus

  Email : [EMAIL PROTECTED]
  Phone : +49-681-302-2016
  Fax   : +49-681-302-4136

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