Camera placement

I have a mesh as a set of surfaces,described by vertexes
I need to place the camera so,that while doing perspective projection Ill get the best "picture". How can I do it? (I cant rotate /traslate etc. camera - just place it once)

Thank you in advance for the answers

Well in OpenGL there is no ‘camera’. The ‘camera’ is always at 0,0,0 facing 0,0,0.
You have to translate your scene into the camera’s view.
You may also want to look at ‘gluLookAt’.

If your mesh is from DCC software such as 3dsmax or Maya and you want to render your scene from one camera, you can just write down its world position and fov such that parameter and use gluLookAt and gluPerspective to do what you want.

Set the lookat value to be the mean of all the vertex positions.
Find the smallest eigenvector of the covariance matrix :smiley: and set the camera along the mean - this eigenvector such that the field of view covers the scene.
There are some minor details to work out, of course :wink:

I should mention that the details concerning the covariance matrix are nicely presented in:
Real-Time Collision Detection (The Morgan Kaufmann Series in Interactive 3-D Technology) (Hardcover)
This would be a way to make sure you set the camera to view the broadest dimension of your scene…