rotate a camera
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?
Depends on yer camera setup.
This is not the fastest, just works. In reality you should be able to just do a:
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement