Jump to content
  • Advertisement

Archived

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

MindCode

OpenGL OpenGL Matrix Rotations

This topic is 5802 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

I''ve been having a problem with OpenGL matrices. I thought it had something to do with the way I was setting up my matrix until I started doing rotations the "standard" way. glTranslatef( xpos, ypos, zpos ); glRotatef( xangle, 1.f, 0.f, 0.f ); glRotatef( yangle, 0.f, 1.f, 0.f ); glRotatef( zangle, 0.f, 0.f, 1.f ); That''s exactly how it looks (and I''ve tried puting the translation last). The problem is when I change zangle to something other than zero. The x and y rotations work perfectly, but the z rotation only works when looking straight down the z axis. Otherwise it becomes an x rotation the more it turns to the x axis. Is there some special case with OpenGL for the z axis? Is this that the it is supposed to work in OpenGL? Or is there something wrong with my OpenGL implementation.

Share this post


Link to post
Share on other sites
Advertisement
it''s not an openGL problem it sounds like good ol gimble lock and you should 1) look it up and 2) modify your code to prevent it. basically when you concatenate 3 rotations along perpendicular axes, you have the possibility of nulling one of the axis rotations. google will probably provide quick answers, also the Articles & Resources section must have somethining. as an alternitive you could look into doing rotations with quaternions but that a whole giant basket of new hassle

-me

Share this post


Link to post
Share on other sites
I wasn't really sure how gibal lock affected rotations. Until now I thought it only happened under a certain circumstance of rotation. I've also tried using quaternions but for the way I had to implement them I was getting even weirder errors.

I've even tried euler matrices but I was getting the exact same bug.

[edited by - MindCode on December 3, 2002 3:57:00 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
There''s nothing wrong with your OpenGL implementation, OpenGL does not have a special case for the z-axis, and the problem is not gimbal lock. You simply don''t understand composition of transformations, and a trial-and-error approach won''t cut it -- you will be hopelessly confused until you master the basic concepts of the transformation pipeline. The rotations are not independent: each glRotate call changes the current transformation matrix. And rotations do not commute, i.e., the order you apply rotations is important. I suggest spending a little reading up on transformations rather than banging your head against a wall. Trust me on this.

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!