Jump to content
  • Advertisement


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


camera rotation matrix calculation

This topic is 6379 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`m trying to calculate the matrix for camera rotation rotation around the 0-X axes: { 1, 0, 0 0, cosX, -sinX, 0, sinX, cosX} rotation around the 0-Y axes: {cosY, 0, sinY, 0, 1, 0, -sinY 0, cosY} rotation around the 0-Z axes: {cosZ, -sinZ, 0 sinZ, cosZ, 0 0, 0, 0} after multiplication of the matricies we`ll yield the matrix, which rotates the camera around the global X,Y,Z axes: matrix[0]=cosY*cosZ; matrix[4]=-cosY*sinZ; matrix[8]=sinY; matrix[12]=0; matrix[1]=sinX*sinY*cosZ+cosX*sinZ; matrix[5]=-sinX*sinY*sinZ+cosX*cosZ; matrix[9]=-sinX*cosY; matrix[13]=0; matrix[2]=-cosX*sinY*cosZ+sinX*sinZ; matrix[6]=cosX*sinY*sinZ+sinX*cosZ; matrix[10]=cosX*cosY; matrix[14]=0; matrix[3]=0; matrix[7]=0;matrix[11]=0; matrix[15]=1; To manipulate the camera - we have 2 angles: x, y cordinates of the mouse - turn around the Y and X axes. This two angles - LOCAL to camera.(if global Y-not zero than global X not zero and global Z not zero). Local camera 0Z axes always lies in global X0Z coordinates How to project this 2 local mouse angles on to 3 global angles?

Share this post

Link to post
Share on other sites
You cannot manipulate an object, such as a camera, that has 3 degrees of freedom with a device that allows for only 2 degrees of freedomm, such as a mouse.

You have two solutions:
1) Use the keyboard in conjunction with the mouse. Two keyboard keys will afford you a 3rd degree of freedom. Games like quake and halflife use this method (sort of. . . not really, since in quake you can''t rotate along one axis but you get the idea.) Mouse controls x,y, keyboard controls z (or some other combination.)

2) Use the mouse button to toggle your mouse''s y axis with the z axis. This solution is non-ideal as you are basically switching your mouse from a 2 DOF device to a different 2 DOF device -- you will not be able to control all 3 dimensions at the same time, but you will be able to control them in a serial manner.


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!