annotate 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 |
rev |
line source |
nuclear@0
|
1 #include "vmathmat.h"
|
nuclear@0
|
2 #include "vmath.h"
|
nuclear@0
|
3
|
nuclear@0
|
4 void Matrix4x4::lookat(const Vector3 &pos, const Vector3 &targ, const Vector3 &up)
|
nuclear@0
|
5 {
|
nuclear@0
|
6 Vector3 vk = normalize(targ - pos);
|
nuclear@0
|
7 Vector3 vj = normalize(up);
|
nuclear@0
|
8 Vector3 vi = normalize(cross(vk, vj));
|
nuclear@0
|
9 vj = cross(vi, vk);
|
nuclear@0
|
10
|
nuclear@0
|
11 Matrix4x4 m(
|
nuclear@0
|
12 vi.x, vi.y, vi.z, 0,
|
nuclear@0
|
13 vj.x, vj.y, vj.z, 0,
|
nuclear@0
|
14 -vk.x, -vk.y, -vk.z, 0,
|
nuclear@0
|
15 0, 0, 0, 1);
|
nuclear@0
|
16 translate(-pos.x, -pos.y, -pos.z);
|
nuclear@0
|
17 *this = *this * m;
|
nuclear@0
|
18 }
|