gluLookAt and 360 X axis rotation
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.
Assuming your postioned at the origin, rotate the eye point and up vector around the x axis.
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.
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..
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement