🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

special vector rotation

Started by
0 comments, last by IStrikerI 22 years, 9 months ago
i need to rotate a vector according to the mouse movement: i use this vector as a direction vector for the movement and later for things like shooting (rockets etc.). if i move the mouse to the left or right, the vector rotates around the y-axis and if i move the mouse up or down the vector rotates around the x-axis. for this i have two variables xrotation and yrotation. i add the x and y movements from the mouse to that variables. every frame i reset the vector to: x = 0 y = 0 z =-1 and then i rotate it by xrotation around the x-axis and yrotation around the y-axis. this works already, but if i rotate the vector +90 degrees around the y-axis so that it is x = 1 y = 0 z = 0 and then move the mouse up and down, it has no effect on the y coordinate of the vector. i know why, because i now have to rotate the vector around the z-axis to point up and down. but i want to rotate the vector around the x-axis every time to point up and down without looking on the y-rotation. also if i rotate the vector 180 degrees around the y-axis and then point up and down the vector moves the inversed way (if i move the mouse up the y coordinate decreases and if i move the mouse down it increases). i heard about gimbal lock and that i can solve it with quaternions. is my problem gimbal lock or can anybody help me ?
Advertisement
That is not gimble lock, but rather just a confusing control scheme. It is the equivalent of controlling an aircraft with an external view that always points north and controls relative to the view rather than the aircraft. So when the aircraft is headed east/west the up/down movement of the mouse roll the aircraft because you are rotating around the views x-axis which is the aircrafts forward axis. Without any idea of what you are controlling or the viewpoint I can''t suggest a better control scheme. I would suggest adding up and right vectors then using axis angle rotations.
Keys to success: Ability, ambition and opportunity.

This topic is closed to new replies.

Advertisement