Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

emacs

skewed y-axis toward camera

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello, i was wondering if someone can point out the flaw in the following logic: i wrote a custom viewing transformation with the body consisting of these OpenGL calls glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotated(roll, 0.0, 0.0, 1.0); glRotated(heading, 1.0, 0.0, 0.0); glRotated(pitch, 0.0, 1.0, 0.0); glTranslated(-eyex, -eyey, -eyez); currently, my scene consists of a grid at y=0 and the three principal axes x, y and z each having a length of 10. when pitch=0, the y-axis points straight up as expected. however, if i increase pitch to some positive value and track the camera slightly to the left or right, i noticed the y-axis is actually skewed towards the initial location of the camera. i have positioned the camera at various locales and everytime the y-axis is skewed toward the initial location of the camera. in fact, all objects in this context have their y-coordinates skewed in the same manner. does anyone have an idea what could cause this? [Edited by - emacs on November 23, 2008 1:13:15 PM]

Share this post


Link to post
Share on other sites
Advertisement
of course the y axis isnt pointing straight up after applying pitch. stick a pencil in your head (well, dont, just imagine it) and then look up.. notice where the "up" of your head is pointing now?). if you still want to rotate around your rooms "up" you will need the matrix built by your three local axes (right/up/forward), transpose it and rotate around THAT y to "compensate" for all the changes you made when doing prior rotations (or just do it before any other rotations while your objects "up" and the worlds "up" still match).

all i can say/guess without knowing what exactly you store in your angles. except maybe: forget storing angles for anything beyond doom-style cameras/objects that dont happen to always rotate around world "up" and object "right".

Share this post


Link to post
Share on other sites
also, I see:

glRotated(heading, 1.0, 0.0, 0.0);
glRotated(pitch, 0.0, 1.0, 0.0);

but I think that heading & pitch vars should be swapped.

I.e. heading should be a rotation around the y axis...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!