View Full Version : Everyones favorite, a camera question

04-12-2001, 02:30 PM
Im looking for a way to "center" a camera on a object.(yes i know open gl doesnt have cameras. i use my own) Basically like the old nes rpg's do, the world moves around the character, while the character stays stationary in the center of the screen. This is what i need, a way to make the camera follow the characters movement. Any help is appretiated. thanks.

04-12-2001, 02:55 PM
This is pretty simple. gluLookAt will create and multiply a camera matrix of sorts. It takes 9 inputs (3 vectors):

1) The world-space location you want to put the camera.
2) A world-space point where you want the camera to look.
3) A vector that you wish to consider the 'up' direction.

Note: make sure that the up vector and the look-at point are not along the same line.

All you need to do is make sure this is the bottom matrix of your stack by making your rendering loop look like this:

<rendering loop>

04-17-2001, 08:44 PM
gluLookAt is the fastest and simplest way to create aan "eye".
you also can build your own camera by craeting a struct that contains the u,v,n vector and the position of the "eye" inside it.
then you have to construct the camera based on the 4x4 transformation matrix, and also create your own Transform function and Rotation for the "eye".
well,this is a long way, but more accurate I think..
anyway, to simulate the eye for the first time, it is sufficient to use :

eye - "eye" or camera position
coi - center of interest
coi with up_vector - determines camera orientation

that's all, see you