erebus

annotate liberebus/src/camera.h @ 0:4abdce1361b9

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 27 Apr 2014 16:02:47 +0300
parents
children 9621beb22694
rev   line source
nuclear@0 1 #ifndef CAMERA_H_
nuclear@0 2 #define CAMERA_H_
nuclear@0 3
nuclear@0 4 #include "vmath/vmath.h"
nuclear@0 5
nuclear@0 6 class Camera {
nuclear@0 7 protected:
nuclear@0 8 Vector3 pos;
nuclear@0 9 float vfov; // vertical field of view in radians
nuclear@0 10
nuclear@0 11 mutable Matrix4x4 cached_matrix;
nuclear@0 12 mutable bool cached_matrix_valid;
nuclear@0 13
nuclear@0 14 mutable Vector3 *rdir_cache;
nuclear@0 15 mutable int rdir_cache_width, rdir_cache_height;
nuclear@0 16
nuclear@0 17 virtual void calc_matrix(Matrix4x4 *mat) const = 0;
nuclear@0 18
nuclear@0 19 Vector2 calc_sample_pos(int x, int y, int xsz, int ysz, int sample) const;
nuclear@0 20
nuclear@0 21 public:
nuclear@0 22 Camera();
nuclear@0 23 Camera(const Vector3 &pos);
nuclear@0 24 virtual ~Camera();
nuclear@0 25
nuclear@0 26 virtual void set_fov(float vfov);
nuclear@0 27 virtual float get_fov() const;
nuclear@0 28
nuclear@0 29 virtual void set_position(const Vector3 &pos);
nuclear@0 30 virtual const Vector3 &get_position() const;
nuclear@0 31 virtual const Matrix4x4 &get_matrix() const;
nuclear@0 32
nuclear@0 33 virtual Ray get_primary_ray(int x, int y, int xsz, int ysz, int sample = 0) const;
nuclear@0 34 };
nuclear@0 35
nuclear@0 36 class TargetCamera : public Camera {
nuclear@0 37 protected:
nuclear@0 38 Vector3 target;
nuclear@0 39
nuclear@0 40 void calc_matrix(Matrix4x4 *mat) const;
nuclear@0 41
nuclear@0 42 public:
nuclear@0 43 TargetCamera();
nuclear@0 44 TargetCamera(const Vector3 &pos, const Vector3 &targ);
nuclear@0 45
nuclear@0 46 virtual void set_target(const Vector3 &targ);
nuclear@0 47 virtual const Vector3 &get_target() const;
nuclear@0 48 };
nuclear@0 49
nuclear@0 50 class FlyCamera : public Camera {
nuclear@0 51 protected:
nuclear@0 52 Quaternion rot;
nuclear@0 53
nuclear@0 54 void calc_matrix(Matrix4x4 *mat) const;
nuclear@0 55
nuclear@0 56 public:
nuclear@0 57 void input_move(float x, float y, float z);
nuclear@0 58 void input_rotate(float x, float y, float z);
nuclear@0 59 };
nuclear@0 60
nuclear@0 61 #endif // CAMERA_H_