gluLookAt and 360 X axis rotation

Started by
5 comments, last by Kaelic 19 years, 4 months ago
Is it possible to do this using gluLookAt so you have a smooth rotation on X axis 360 degrees? No screen flipping at 90 up and down. Well? Come on, there has to be a way.
Advertisement
Assuming your postioned at the origin, rotate the eye point and up vector around the x axis.
And how exactly do I successfully calculate my up vector each time I move my eye?
You could use a cross product, I suppose, but at this point we're quickly moving into the realm where LookAt is superfluous.

Let eyevec = campos - lookatpos;

Let plusx = (1, 0, 0);

upvec = eyevec x plusx;

Where x is a cross product operator.
Scratch that, doing what you suggested works. But messes up yaw calculation. Makes rotating on Y axis backwards, then it switches to forwards and is just generally wonky...

EDIT: Played with it a bit, it seems that when Yawing (rotating on Y axis ie left and right) as it approaches the view vector approaches x axis, Up flips around..
I treat my camera as an eye location, view vector, and up vector. And to apply rotations I just rotate both vectors, and translations I just move the eye location. Then I input them into gluLookAt with the view point = eye location + view vector. I keep view vector and up vector perpendicular just to help me visualize what the cameras doing.

Note: I'm aware that I could easily make the matrix by hand but it's a little easier to read, and performance cost is almost nothing since it's once per frame.
Well duh Cocalus. As I said before, I know how to use gluLookAt, I know what vectors you pass. What I don't know is how you calculate the Up vector so that you can also do 360 degrees pitch. Why is it so hard to get answers for this? Someone just give me a formula :(

This topic is closed to new replies.

Advertisement