Results 1 to 4 of 4

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

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2002
    Location
    Germany
    Posts
    24

    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. #2
    Junior Member Newbie
    Join Date
    Dec 2001
    Location
    Copenhagen, Denmark
    Posts
    27

    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. #3
    Junior Member Newbie
    Join Date
    Jan 2002
    Location
    Germany
    Posts
    24

    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. #4
    Junior Member Newbie
    Join Date
    Dec 2001
    Location
    Copenhagen, Denmark
    Posts
    27

    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

Similar Threads

  1. Replies: 2
    Last Post: 03-31-2016, 07:18 AM
  2. Basic z coordinate usage displays blank view
    By devonM in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 12-05-2012, 08:41 PM
  3. A view that displays my entire model?
    By anime.igala.net in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 07-20-2008, 11:13 AM
  4. Replies: 1
    Last Post: 06-02-2006, 11:52 AM
  5. Position camera to view an entire 3d object
    By barce in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-07-2001, 01:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean