3d-rotation with 2d-input device (mouse)

Started by
1 comment, last by NoNseNse 23 years, 9 months ago
OK, yesterday I started morphing my 1st person-engine(quake-style) ito a flight simulator. But soon I fugured problems with the rotations: normally if you''re standing at the origin and move up and down your mouse you rotate around the x-axis in your engine. left and right mouse-movement should result in rotation around the y axis. but if you rotate 90° on the x-axis, and then move your mouse sideways, it shouldn''t rotate around the x-axis (which would look like rolling) but around the z-axis. This problem does not occur only at these particular angles, but with nearly every angle there''s a problem. I fugured that I''d have to use the sines and cosines for compensation, but after some time without any result, I decided to ask if anyone here can help me, perhaps give me some code just for the rotation. THX in advance!
Advertisement
You have to rotate the viewer around its local axis, not the world axis. You need to calculate vectors that go along the cameras local axis and rotate the camera around those vectors.
I belive your problem is called gimble lock, www.mr-gamemaker.com has a tutorial on how to fix that problem
Im Always Bored--Bordem ICQ: 76947930

This topic is closed to new replies.

Advertisement