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

skippyj777

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:

glPushMatrix;

// Process angles and such

glRotatef(some angle, some vector);

glRotatef(some angle, some vector);

glTranslate(pos.x, pos.y, pos.z);

glPopMatrix;

All advice will be appreciated.

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).]

skippyj777

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?

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

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.