rayzor

view src/vmath.cc @ 0:2a5340a6eee4

rayzor first commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 05 Apr 2014 08:46:27 +0300
parents
children a826bf0fb169
line source
1 #include "vmathmat.h"
2 #include "vmath.h"
4 void Matrix4x4::lookat(const Vector3 &pos, const Vector3 &targ, const Vector3 &up)
5 {
6 Vector3 vk = normalize(targ - pos);
7 Vector3 vj = normalize(up);
8 Vector3 vi = normalize(cross(vk, vj));
9 vj = cross(vi, vk);
11 Matrix4x4 m(
12 vi.x, vi.y, vi.z, 0,
13 vj.x, vj.y, vj.z, 0,
14 -vk.x, -vk.y, -vk.z, 0,
15 0, 0, 0, 1);
16 translate(-pos.x, -pos.y, -pos.z);
17 *this = *this * m;
18 }