mPitch += GetControllerPitch();
mYaw += GetControllerYaw();
Matrix rotation = Matrix::CreateXRotation(mPitch);
rotation = Matrix::CreateYRotation(mYaw) * rotation;
Vector& left = rotation.GetColumn(0);
Vector& up = rotation.GetColumn(1);
Vector& forward = rotation.GetColumn(2);
if (GetControllerUp())
mPosition += forward;
if (GetControllerDown())
mPosition -= forward;
if (GetControllerLeft())
mPosition -= left;
if (GetControllerRight())
mPosition += left;
mView = Matrix::CreateLookAt(mPosition, mPosition+forward, up);
I don't like this, though. I don't like storing the total position, pitch and yaw values in the class. I should be able to get all this information directly from the view matrix, shouldn't I? I'm effectively storing the information twice. I was wondering if I can do away with calling CreateLookAt() every frame and just multiply the view matrix by the relative changes each frame. Something like this:
float pitchChange = GetControllerPitch();
float yawChange = GetControllerYaw();
Matrix rotation = Matrix::CreateXRotation(pitchChange);
rotation = Matrix::CreateYRotation(yawChange) * rotation;
mView = rotation * mView;
Vector& left = mView .GetColumn(0);
Vector& up = mView .GetColumn(1);
Vector& forward = mView .GetColumn(2);
Vector& position = mView.GetColumn(3);
if (GetControllerUp())
mPosition += forward;
if (GetControllerDown())
mPosition -= forward;
if (GetControllerLeft())
mPosition -= left;
if (GetControllerRight())
mPosition += left;
Should this be possible or do I need to take other things into consideration?