Hello,
in the faq section i found an article describing how to calculate a view that displays the whole scene by using an orthographic projection. I must calculate this view for a perspective projection. How can i calculate the correct distance between the camera (eye-point) and the scene-centerpoint (reference-point), so that applying gluLookAt with the desired parameters leads in a view to the complete scene?
I THINK it goes something like this:
fov = cameras field-of-view in radians
r = radius of model
c = r / sin (fov/2)
dist = sqrt (r * r + c* c)
I havent had time to check it (just did some scribbling on the back of an envelope), but try it out
Hello Nicholas,
thank you very much, it works fine
Best regards
Michael Schuster
Originally posted by tabor25:
[b]Hello Nicholas,
thank you very much, it works fine
Best regards
Michael Schuster[/b]
Glad to hear it.
FYI: The method used is to get the cross product of the up & forward vectors. The cross of two vectors is a vector that is perpendicular to the plane defined by the other two vectors. If you’re intrested, I can mail you an LGPL 3D math library in C++ I took it from the CrystalSpace engine. Nothing special, but works nicely. If you want it, mail me at nicholasfrancis@mac.com