when I set my camera perspective what should lead my logic…?? , why glFrustum(-4,4,-2,2,1,50) , and not
is it correct to thing about the place i put the camera ?
(room , space , field)

The values you give will change the way the scene looks, i.e. set the values too big, too small, or give disproportionate values and you will get some odd looking views. Now I’m the first to admit that I’m not certain on the math behind it so I’ve draged out some code from quake that does it correctly, well for a game like quake anyway.

void MYgluPerspective( GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar )
GLdouble xmin, xmax, ymin, ymax;

ymax = zNear * tan( fovy * M_PI / 360.0 );
ymin = -ymax;

xmin = ymin * aspect;
xmax = ymax * aspect;

glFrustum( xmin, xmax, ymin, ymax, zNear, zFar );

Fovy is the field of view, something like 45 is good here but you may want something else depending on what you are doing.

aspect is the screen width / screen height normally I think.

Znear and Zfar are the minimum and maximum distances that you can see, both must be greater than 0. Values will vary depending on what you are doing.


well, think about how yoru camera sits in the real world, and try and work out what you want to be able to do with it. This should give you some idea of what it is you want from your frustum.

Do you, for example, want to place the camera right 1 metre away from a flower standing 1 metre tall (its a sun flower, no less=) and have it fit onto the screen?

draw a digram of a metre tall flower and an optical centre a metre away and draw the lines from the top of the flower through the optical axis. This is the beginnings of your frustum. Where do you want the near clip plane? well, it betetr not be more than a metre away, because you’ll lose your flower. Hmm. Just guess. =) the focal legnth is important, tho, but… just pick some place. now, using similar triangles, you can work out the size of your top/left/right/bottom coordinates, and you’re set.

all because you know what kind of things you want to do with you camera, ie. what you want to “photograph” and at what scale and so on.

hoep this helps,