Advertisement Jump to content
Sign in to follow this  

rotate a camera

This topic is 4928 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
Depends on yer camera setup.

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

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 :).



Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!