Camera pos/dir + rot == right RTS view

Started by
9 comments, last by haegarr 18 years, 1 month ago
gluLookAt already does a heading (y axis rotation) as well as a pitching (x axis rotation). Hence you could try to place the point to look-at appropriately and drop performing your own x axis rotation. It may become difficult to implement the wanted inclination angle.

On the other hand, gluLookAt performs internally a sequence of
glMultMatrixf(M);
glTransled(-eye.x,-eye.y,-eye.z);
[please notice the negative signs and the order of transformations what both result from using the inverse, I mentioned that in my previous reply] where M is computed as rotation matrix. Normally one performs Euler rotations in the order heading first, than pitching, and at last rolling (you don't use rolling). Since the VIEW matrix is the inverse of the camera matrix, gluLookAt does something like
glMultMatrixf(pitching);
glMultMatrixf(heading);
glTransled(-eye.x,-eye.y,-eye.z);
[it doesn't do so really but one can image so].

So, if you want to do a pitching yourself you could see that you have to do it before gluLookAt if you wan't to see an appropriate effect anyhow. To make it work well it seems me senseful to guarantee that the pitching gluLookAt does it an identity operation (i.e. let the look-at point be on the same height as the camera is).

IMHO the overall structure has to be something like this (but don't hate me if I'm wrong ;)
glMatrixMode(GL_MODELVIEW);
glLoadIndentity();
glRotate(-75,1,0,0);
...
gluLookAt(...);
... transforming and rendering of models

Hope this makes sense...

This topic is closed to new replies.

Advertisement