Sign in to follow this  
Kaelic

gluLookAt and 360 X axis rotation

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 :(

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this