daily pastebin goal

View MAtrix

a guest Nov 24th, 2016 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Returns a view matrix, ie inverse world
  2. mat4 LookAt(const vec3& position, const vec3& target, const vec3& up) {
  3.     vec3 forward = Normalized(target - position);
  4.     vec3 right = Normalized(Cross(up, forward));
  5.     vec3 newUp = Cross(forward, right);
  7.     return
  8.         mat4( // Rotation is transposed
  9.         right.x, newUp.x, forward.x, 0.0f,
  10.         right.y, newUp.y, forward.y, 0.0f,
  11.         right.z, newUp.z, forward.z, 0.0f,
  12.         -Dot(right, position), -Dot(newUp, position), -Dot(forward, position), 1.0f
  13.     );
  14. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand