I always have an FPS style free cam which I use for my model viewer etc. and the way I always calculate the view matrix in this cam is along these lines:
m_pitch += pitchThisFrame; m_yaw += yawThisFrame; Matrix pitchMat = Matrix::CreateXRotation(m_pitch); Matrix yawMat = Matrix::CreateYRotation(m_yaw); Matrix rotation = yawMat * pitchMat; const Vector& left = rotation.GetColumn0(); const Vector& up = rotation.GetColumn1(); const Vector& forward = rotation.GetColumn2(); m_position += left * xTransThisFrame; m_position += forward * zTransThisFrame; m_view = Matrix::CreateLookAt(m_position, m_position + forward, up);
As you can see, I basically have my free cam class store a vector for the position and then pitch and yaw values for the rotation of the camera. Then I use my CreateLookAt() function to generate the view matrix from these values each frame.
This has always worked for me but I have been wondering if this is the "correct" way to do it. Perhaps it would be better to just modify the view matrix directly each frame? Though, I suppose I would have to orthonormalise regularly if I went down that route...