rayzor
view src/vmath.cc @ 11:fe94d9e986ae
optimized 16bpp swap_buffers
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 10 Apr 2014 08:42:33 +0300 |
parents | 2a5340a6eee4 |
children | d94a69933a71 |
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 }