rayzor
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/vmath.cc Sat Apr 05 08:46:27 2014 +0300 1.3 @@ -0,0 +1,18 @@ 1.4 +#include "vmathmat.h" 1.5 +#include "vmath.h" 1.6 + 1.7 +void Matrix4x4::lookat(const Vector3 &pos, const Vector3 &targ, const Vector3 &up) 1.8 +{ 1.9 + Vector3 vk = normalize(targ - pos); 1.10 + Vector3 vj = normalize(up); 1.11 + Vector3 vi = normalize(cross(vk, vj)); 1.12 + vj = cross(vi, vk); 1.13 + 1.14 + Matrix4x4 m( 1.15 + vi.x, vi.y, vi.z, 0, 1.16 + vj.x, vj.y, vj.z, 0, 1.17 + -vk.x, -vk.y, -vk.z, 0, 1.18 + 0, 0, 0, 1); 1.19 + translate(-pos.x, -pos.y, -pos.z); 1.20 + *this = *this * m; 1.21 +}