rayzor
diff src/camera.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/camera.cc Sat Apr 05 08:46:27 2014 +0300 1.3 @@ -0,0 +1,50 @@ 1.4 +#include "camera.h" 1.5 + 1.6 +Camera::Camera() 1.7 + : pos(0, 0, 10) 1.8 +{ 1.9 + fov = M_PI; 1.10 +} 1.11 + 1.12 +void Camera::set_position(const Vector3 &pos) 1.13 +{ 1.14 + this->pos = pos; 1.15 +} 1.16 + 1.17 +const Vector3 &Camera::get_position() const 1.18 +{ 1.19 + return pos; 1.20 +} 1.21 + 1.22 +void Camera::set_target(const Vector3 &target) 1.23 +{ 1.24 + this->target = target; 1.25 +} 1.26 + 1.27 +const Vector3 &Camera::get_target() const 1.28 +{ 1.29 + return target; 1.30 +} 1.31 + 1.32 +void Camera::set_fov(float fov) 1.33 +{ 1.34 + this->fov = fov; 1.35 +} 1.36 + 1.37 +float Camera::get_fov() const 1.38 +{ 1.39 + return fov; 1.40 +} 1.41 + 1.42 +Matrix4x4 Camera::get_matrix() const 1.43 +{ 1.44 + Matrix4x4 res; 1.45 + res.lookat(pos, target, Vector3(0, 1, 0)); 1.46 + return res; 1.47 +} 1.48 + 1.49 +Matrix4x4 Camera::get_inv_matrix() const 1.50 +{ 1.51 + Matrix4x4 res; 1.52 + return res; // TODO 1.53 +}