Jump to content
  • Advertisement
Sign in to follow this  

OpenGL gllookat and center mesh from bounding sphere

This topic is 2569 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a big opengl model (formed by many meshes)and his bounding sphere.
How i can set the camera with gllookat so as center the camera on the model ?
Pratically ,I would see the entire model .
and in webgl is the same ?
because i need both(opengl and webgl)

Share this post

Link to post
Share on other sites
You view is defined by two transformations:

  • Camera orientation (view matrix) - this is the one you are setting with lookAt. Basically this is the real world placement of camera - position and direction.
  • Projection matrix - this defines the "optical parameters" of the camera - field of vision and near and far clipping planes.To make the whole of your object visible, you have first to decide camera position. If you do not care, choose something like 4 x radius from the center of your object in some direction.

    Then you can set the camera orientation with gluLookAt, giving the camera position, bounding sphere center and up direction as parameters.

    Projection has to be set separately with glFrustum / gluPerspective (perspective) or glOrtho (isometric). Calculating proper parameters for glFrustum needs some trigonometry.

    You can take look at http://www.opengl.org/resources/faq/technical/viewing.htm for more examples and explanations.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!