View Full Version : What's the correct way to do camera?
12-09-2001, 07:48 AM
What's the correct way to do camera?
Somewhere I saw programs that are puting camera matrix into modelview tree,
someone into projection tree after projection matrix,
sometimes before projection matrix.
But what's the correct way? I thought it is loading camera into projection matrix and then multiplying by projection matrix. Am I right?
You should transform the viewpoint using the modelview matrix, and the projection matrix is only supposed to do projection.
Depending on how you define "correct", this can of course be different. If you really want to put translations in the projection matrix, nothing will stop you from doing it.
gluLookAt is your freind when it comes to cameras. Here is the format:
gluLookAt(xpos, ypos, zpos, xlookat, ylookat, zlookat, xup, yup, zup);
xpos, ypos, zpos - the x,y,z coordinates of the camera's position
xlookat, ylookat, zlookat - the x,y,z coordinates of the point ur camera is looking at
xup, yup, zup - the x, y, z coordinates of the up vector for your camera. (Changing these rolls your camera; 0, 1, 0 is common)
make sure you are working on the modelview matrix. I had that problem for a while, so before using the lookat function do this:
hope that helps.
12-11-2001, 06:22 AM
Put viewing or 'camera' transformations on the modelview matrix. Anything else is very wrong. Messing with the projection matrix like this can screw up fog, lighting & all sorts of other things depending on the implementation.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.