I apologize if the title is somewhat misleading but I was unsure what to title this post. I am trying to develop somewhat of a flight simulator type camera system. Ideally, no matter what the orientation of the camera is relative to the world, if the user presses the "travel right" key, the camera should appear to travel right from their point of view (regardless of what it's orientation in world-space is). I have written some code that attempts perform an inverse transformation of directions relative to the camera back into world-space before rotating the camera. I should add that I am using the DirectXTK library for its math functions. Here is my code:
user_input_function(INPUT input_type)
{
switch(input_type)
{
....
case MOTION_STATE_ROT_RIGHT:
axis = __transform_local(Vector3(0, 0, 1));
new_transform = cur_transform * Matrix::CreateFromAxisAngle(axis, -0.1f);
this->renderer->SetTransform(TRANSFORM_VIEW,
new_transform);
break;
}
}
Vector3 __transform_local(Vector3 &v)
{
Matrix inv_view = this->renderer->GetInvTransform(TRANSFORM_VIEW);
return Vector3::TransformNormal(v, inv_view);
}
When I run my program, the rotations produced are incorrect when attempting to rotate around an axis that is not strictly X, Y or Z (relative to the camera).