# gluLookAt and 360 X axis rotation

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

## Recommended Posts

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.

##### Share on other sites
Assuming your postioned at the origin, rotate the eye point and up vector around the x axis.

##### Share on other sites
And how exactly do I successfully calculate my up vector each time I move my eye?

##### Share on other sites
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.

##### Share on other sites
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..

##### Share on other sites
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.

##### Share on other sites
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 :(

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013300
×