title: Translating a 3D object along a local axis
body: <p>I am working on making a FPS style camera for a class project. I am currently using 2 Vec3s to hold the cameras position and rotation. With my current code I am only able to translate with respect to the global axis, not in the direction of my current facing. How do I use the camera's rotation in order to translate in the direction I would like? EX: Pressing 'W' causes the camera to translate forward along its local Z axis.</p>
  
  <pre><code>camMat = Matrix4Identity();
  
  //Input for camera
  if (GetAsyncKeyState('Q'))
  {
      camRot.y += 60.0f*timer.Delta();
  }
  if (GetAsyncKeyState('E'))
  {
      camRot.y -= 60.0f*timer.Delta();
  }
  if (GetAsyncKeyState('W'))
  {
      camPos.z += 4.0f*timer.Delta();
  }
  if (GetAsyncKeyState('S'))
  {
      camPos.z -= 4.0f*timer.Delta();
  }
  if (GetAsyncKeyState('A'))
  {
      camPos.x -= 4.0f*timer.Delta();
  }
  if (GetAsyncKeyState('D'))
  {
      camPos.x += 4.0f*timer.Delta();
  }
  
  camMat = Matrix4Multiply(camMat, Matrix4RotationX(camRot.x));
  camMat = Matrix4Multiply(camMat, Matrix4RotationY(camRot.y));
  camMat = Matrix4Multiply(camMat, Matrix4RotationZ(camRot.z));
  camMat = Matrix4Multiply(camMat, Matrix4Translate(camPos.x, camPos.y, camPos.z));
  </code></pre>
  
  <p>EDIT: I do see a lot of similar questions on SO but they all seem to use slightly different implementations that aren't making sense to me.</p>