Hello Stefano,
to find the distance between two points use
double dist = pointA.distance(pointB);
where "pointA" and "pointB" are Point3f's or Point3d's.
Simply set A to the viewer position and B to whatever point in your universe
you want to calculate the distance to.
>> Can I modify it on the fly?
If you want to change the distance of the viewer from some point (zooming in
and out around a specific point), you can use a simple extrapolation code
like this:
public Point3d getModifiedViewer(Point3d oldViewer, Point3d lookAt, double
newDistance) {
// calculate viewing direction
Vector3d eyeRay = new Vector3d(lookAt);
eyeRay.sub(oldViewer);
eyeRay.normalize();
// eyeRay now is viewing direction with length 1 (normalized)
eyeRay.scale(-newDistance);
// eyeRay now is inverse viewing direction with length "newDistance"
Point3d newViewer=new Point3d(lookAt);
newViewer.add(eyeRay);
// newViewer now is the wanted extrapolated position
return newViewer;
}
I didn't compile and test this code but it should work like this or similar.
It is not optimized for the sake of clarity.
You should be careful not to mix world coordinates and local coordinates in
these calculations, see Vladimir's mail.
Hope it helps.
-- Julian
PS: You may find the following link rather interesting:
(I only have the address in Japan, but it should also be on mirrors all
around the world)
http://isw3.aist-nara.ac.jp/IS/Chihara-lab/yosio-n/comp.graphics.algorithms/
faq.html
and if you can read C perhaps you might want to take a look into the
Graphics Gems code, which you find for example at
ftp://ftp.sunsite.org.uk/Mirrors/wuarchive.wustl.edu/graphics/graphics/books
/graphics-gems/
-----Original Message-----
From: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED]]On Behalf Of Stefano Scarpanti
Sent: Tuesday, February 08, 2000 12:32 PM
To: [EMAIL PROTECTED]
Subject: [JAVA3D] distance of the viewer
Hi all,
I suppose there is a simple field to retrieve distance of the viewer from
the universe.
Which is?
Can I modify it on the fly?
Thanks
===========================================================================
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".
===========================================================================
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".