I.e. how to calculate the middle of the object, at which the camera will
point? Some kind of center of weight calculation?
My 1st idea to calc. view volume was to sort all x coords, choose biggest
and smallest, which
will be the left and right clipping planes, do the sorting for y-coords
(to have top and bottom clipping planes) and for z coords (to have
near/far clipping planes).
But there are probably better ways to do it?
What OpenGL functions to use (gluLookAt? gluPerspective? glFrustrumm?
glOrtho? ) to set eye pos. and viewing volume?
Przemek
--------------------------
pjac...@elka.pw.edu.pl
--------------------------
I believe the easiest way is to use the objects bounding sphere. As you
have the bounding sphere, you also have the target point the camera should
look at. Next you should calc the distance how far the camera should that
the whole object (bouding sphere) would be visible. Fir this you will need
the FOV of your camera and the radius of the bounding sphere. The distance
is calculated as follows:
dist = radius / tan( FOV / 2 )
Then you need to know the direction of the camera. You can start just by
translating it backwards of the object by some amount.
You could use glPerspective to set the projection, and glLookat to set
look at transformation.
--memon
cos(pi),sin(pi) lddoW 6Jo'3p15u1@uow3w
uow3W uow3w~/6Jo'3p15u1'mmm
But how I can get bounding sphere having my object?
Przemek
See:
http://www.magic-software.com/
There browse: Source Code > 3D Source Code: Containment. There you should
see sources on how to calculate minimum volume bounding sphere.