D3DXVECTOR3 Rot = GetCameraRotation();
D3DXVECTOR4 LocalViewOrigin = GetCameraEyePosition();
D3DXMATRIX InverseRotationMatrix(
D3DXMATRIX(
cos(Rot.x), -sin(Rot.x), 0.0f, 0.0f,
sin(Rot.x), cos(Rot.x), 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f) *
D3DXMATRIX(
cos(Rot.y), 0.0f, -sin(Rot.y), 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
sin(Rot.y), 0.0f, cos(Rot.y), 0.0f,
0.0f, 0.0f, 0.0f, 1.0f) *
D3DXMATRIX(
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, cos(Rot.z), -sin(Rot.z), 0.0f,
0.0f, sin(Rot.z), cos(Rot.z), 0.0f,
0.0f, 0.0f, 0.0f, 1.0f)
);
D3DXMATRIX ViewRotationMatrix = InverseRotationMatrix * D3DXMATRIX(
0, 0, 1, 0,
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 0, 1);
D3DXMATRIX translation(
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
-LocalViewOrigin.x, -LocalViewOrigin.y, -LocalViewOrigin.z, 1.0f);
D3DXMATRIX ViewMatrix = translation * ViewRotationMatrix;