Camera Rotation Whitout Matrix

Started by
2 comments, last by uncutno 22 years, 10 months ago
Ok, here is my problem! Ive got a ViweDirection Vector! Ive got a UpDirection Vector, Ive even got a RightDirection Vector! These three makes a perfect matrix for rotation! My question is, how do i make OpenGL use these vectors, so that the "camera" points that way? I found a hard way, with filling up a float m[15], and then use something like glMultMatrix(m), but there must be a easy way? -Anders-Oredsson-Norway-
-Anders-Oredsson-Norway-
Advertisement
I would *STRONGLY* recommend that you don''t use your own matrices for rotations and such (even the Red Book says its not recommended). The gl commands for translation/rotation/scaling/etc are *FAR* faster than yours can ever be (unless of course you figure out a way to do in hardware). And if you want to look at a specific point, use gluLookAt(...).

------------------------------
Trent (ShiningKnight)
E-mail me
OpenGL Game Programming Tutorials
Well if you have a geforce 3 then its easy to do it in hardware. Just use vertex programs.

But yes, since you have those three vectors, gluLookAt is just what you need. That function wants those exact vectors you already have!

-SirKnight
use gluLookAt. From the MSDN documentation:

gluLookAt
The gluLookAt function defines a viewing transformation.

void gluLookAt(
GLdouble eyex,
GLdouble eyey,
GLdouble eyez,
GLdouble centerx,
GLdouble centery,
GLdouble centerz,
GLdouble upx,
GLdouble upy,
GLdouble upz
);
Parameters
eyex, eyey, eyez
The position of the eye point.
centerx, centery, centerz
The position of the reference point.
upx, upy, upz
The direction of the up vector.
Remarks
The gluLookAt function creates a viewing matrix derived from an eye point, a reference point indicating the center of the scene, and an up vector. The matrix maps the reference point to the negative z-axis and the eye point to the origin, so that when you use a typical projection matrix, the center of the scene maps to the center of the viewport. Similarly, the direction described by the up vector projected onto the viewing plane is mapped to the positive y-axis so that it points upward in the viewport. The up vector must not be parallel to the line of sight from the eye to the reference point.

The matrix generated by gluLookAt postmultiplies the current matrix.

This topic is closed to new replies.

Advertisement