Jump to content
  • Advertisement


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


What's wrong with my camera-code?

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

Hi everyone! I''m currently workinf on a free camera code. But it doesn''t work correctly! My camera should move in the direction it is currently viewing. But that''s NOT the problem! The problem is that when I''m turning around the camera sometimes turns along the wrong axis! I want to be able to yaw, pitch and roll around the camera''s axis! But what''s wrong with my code? D3DXMATRIX Translation; D3DXMatrixTranslation(&Translation,0.0f,0.0f,0.0f); D3DXMATRIX Rotation; D3DXMatrixRotationYawPitchRoll(&Rotation,(CameraPan*Math::rad), CameraTilt*Math::rad),(CameraRoll*Math::rad)); D3DXMATRIX View; D3DXMatrixMultiply(&View,&Translation,&Rotation); Direct3D::D3DDevice->SetTransform(D3DTS_VIEW,&View); Thanks for any help! (Please don''t say that I should search on google! I searched now one week, but couldn''t find any helpful things!)

Share this post

Link to post
Share on other sites
Hi again!

I wasn''t stopping searching for answers and I found now the right code:

D3DXMATRIX m_matOrientation;
D3DXMATRIX m_matView;


D3DXQuaternionRotationYawPitchRoll(&qR, (CameraPan*Math::rad),(CameraTilt*Math::rad),(CameraRoll*Math::rad));

D3DXMatrixAffineTransformation(&m_matOrientation, 1.25f, NULL, &qR, &D3DXVECTOR3(CameraX,CameraY,CameraZ));

D3DXMatrixInverse( &m_matView, NULL, &m_matOrientation );


Now it works fine!

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!