Sign in to follow this  

rotate a camera

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

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

This topic is 4527 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.

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