Skip to main content
gamedev.net
🔒 Locked

gimble lock

Started by Philippo 3 replies 450+ views
Original Post
Philippo
Philippo
hi all! I have a problem with my rotations which I think is called "gimble lock". I found some articles about it, but no real way to solve it! I want to rotate my camera in my own space-shooter (roll, pitch and yaw). First I tried it like this: roll(angle): angleZ += angle; pitch(angle): angleY += angle; yaw(angle): angleX += angle; This is of course impossible cause this simply ignores the previous rotations. My solution to this works, but it''s very slow and I think there should be another way. I don''t use 3 variables for the rotations about each axis any more, but I create a temporary rotation matrix at the time the camera gets rotated (not at the time the scene is drawn), and then I multiply this temp matrix with the previous matrix. I''m working with opengl, so instead of using glRotatef(...) before drawing the scene, I''m loading my previously calculated own matrix with glLoadMatrix. This way, the rotation is right, but I don''t think this is a good way. It would be much better, if there were a way to calculate the right 3 angles for roll/pitch/yaw and to use glRotate(...) before drawing the scene. It should also be much faster, I think. Does anyone have another solution for this? thank you Philippo
s_buschmann@gmx.de
http://privat.schlund.de/Gerio
sbusch@pixellight.orghttp://www.pixellight.org
BigCarlito
BigCarlito
Hey! I got an idea! Use quaternions! Seriously, they are perfect for just that kind of task. I still don''t fully understand WHY they work, but they do! Search on Gamasutra for them and that could get you started.


Zeus Interactive
Raptor
Raptor
The look,up,right approach is the best!
we have implemented that and we have no problems what so ever.
Check out GameMaker for a tutorial named Moving the Camera without screwing it up for a clear picture.

best of luck!


Raptor
Philippo
Philippo
Thank you all for your help!

I will use those up/right/forward vectors, this is much simpler than multiplying matrices on each rotation.

BTW: "Mr GameMaker" is a really nice page!
I found another thing here I was looking for since weeks now. thanks, raptor!

bye


Philippo
s_buschmann@gmx.de
http://privat.schlund.de/Gerio
sbusch@pixellight.orghttp://www.pixellight.org

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.