Jump to content
  • Advertisement
Sign in to follow this  
Say

rotate a camera

This topic is 4871 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've my cam focused on a mesh on the front. I would rotate the cam so i can what the mesh on the right. What is the matrix i have to multiplicate?

Share this post


Link to post
Share on other sites
Advertisement
Depends on yer camera setup.

This is not the fastest, just works. In reality you should be able to just do a:


D3DXQUATERNION QUAT;
D3DXMATRIX matAT;
D3DXMATRIX matRot;
D3DXMATRIX matView;
D3DXQuaternionRotationYawPitchRoll(&QUAT, vecRot.x, vecRot.y,vecRot.z);
D3DXMatrixAffineTransformation(&matAT, 1.00f, NULL, &QUAT, &vecPosition);
D3DXMatrixInverse(&matView, NULL, &matAT);
matCameraView = matView * matRot;
pd3dDevice->SetTransform(D3DTS_VIEW, &matCameraView);





That uses quaternions, also not in degrees, they are in Radians. So should be immune to gimbal lock, although the Z always gets messed for me, I can show ya a way around it still if need be. vecPostion is hte position of the camera, vecRot is the new rotation(not added rotation).

Also you should pickup a good book on beginning directx programming, this sorta thing is one of the first things taught usually (NO OFFENSE PLEASE). Of course some books do suck :).

GL,

Brad

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!