Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Camera Rotation Whitout Matrix

This topic is 6175 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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-

Share this post

Link to post
Share on other sites
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

Share this post

Link to post
Share on other sites
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!


Share this post

Link to post
Share on other sites
use gluLookAt. From the MSDN documentation:

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

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!