#### Archived

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

# skewed y-axis toward camera

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

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

thanks for the info.

##### Share on other sites
also, I see:

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...

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5

• 11
• 12
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
633348
• Total Posts
3011463

×