Jump to content
  • Advertisement


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


rotation around 3 axes

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

What i am trying to do is this. I have a flying saucer that i have aligned to the angle of the terrain directly below it. This i have done using rotations around the x and z axes. This works fine. D3DXMatrixTranslation(&matWorld, vLoc.x, vLoc.y, vLoc.z); D3DXMatrixRotationY( &matRotateY, -vR.x ); D3DXMatrixRotationX( &matRotateX, -vR.y ); D3DXMatrixRotationZ( &matRotateZ, -vR.z ); D3DXMatrixMultiply( &matTemp, &matRotateZ, &matRotateY ); D3DXMatrixMultiply( &matTemp, &matRotateX, &matTemp ); D3DXMatrixMultiply( &matWorld, &matTemp, &matWorld ); matLocal = matWorld; The trouble is, when I spin around the y axis also (to spin the saucer), it looks like a coin spinning on a table. How do I get out of this???? Any pointers?? TIA

Share this post

Link to post
Share on other sites
Well I''m an OpenGL user, so I don''t really know what those D3DX functions do, but it seems to mee that you are experiencing gimbal lock. Two solutions spring to mind:

1) Don''t build the matrix based on the current angles and position. Keep a copy of the saucer''s rotation matrix with the saucer itself. Then each frame, base a matrix on the CHANGE of the angles in respect to last frame, instead of the absolute angles. Then multiply the current matrix by the new one and save it to your saucer. Then add the position to this matrix and sent it to D3D.

2) Use quaternions and build the matrix from that. This is the preferable method, but it takes a lot more explaining. I suggest you check the articles section and search for quaternions.

Hope that helped.

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!