# Thread: How can I calculate a view that displays my entire model?

1. ## How can I calculate a view that displays my entire model?

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?

2. ## Re: How can I calculate a view that displays my entire model?

I THINK it goes something like this:

Code :
```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

3. ## Re: How can I calculate a view that displays my entire model?

Hello Nicholas,

thank you very much, it works fine

Best regards

Michael Schuster

4. ## Re: How can I calculate a view that displays my entire model?

Originally posted by tabor25:
Hello Nicholas,

thank you very much, it works fine

Best regards

Michael Schuster
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

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•