Sign in to follow this  

rotate a camera

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this