View Full Version : How do I set a model's pos, look up look at?

08-23-2000, 08:41 AM
If I have a position, normalized look up vector, and normalized look at vector, how do I set the modelview matrix to use those values? I assume the code would look something like this:

// Process angles and such
glRotatef(some angle, some vector);
glRotatef(some angle, some vector);
glTranslate(pos.x, pos.y, pos.z);

All advice will be appreciated.

08-23-2000, 09:46 AM
You just do the cross product of your up vector and you look at vector, this will give you the left vector.

You just take those 3 vectors and create a matrix in that order I think

left, up, foward

and you do glMultMatrix and you are done!

This will create a new basis for the vectors

[This message has been edited by Gorg (edited 08-23-2000).]

08-23-2000, 09:50 AM
What about the position? Should I add the position to the last row of the matrix, or subtract it from the last row in the matrix?

08-23-2000, 12:20 PM
I believe you can put it in the matrix, but I am not sure where, so just use glTranslate. The matrix you just created is the rotation matrix