erebus

annotate liberebus/src/camera.h @ 6:bb006fb96f1b

forgot to add two files
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 24 May 2014 02:22:14 +0300
parents 4abdce1361b9
children e2d9bf168a41
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@5 16 mutable float rdir_cache_fov;
nuclear@0 17
nuclear@0 18 virtual void calc_matrix(Matrix4x4 *mat) const = 0;
nuclear@0 19
nuclear@0 20 Vector2 calc_sample_pos(int x, int y, int xsz, int ysz, int sample) const;
nuclear@0 21
nuclear@0 22 public:
nuclear@0 23 Camera();
nuclear@0 24 Camera(const Vector3 &pos);
nuclear@0 25 virtual ~Camera();
nuclear@0 26
nuclear@0 27 virtual void set_fov(float vfov);
nuclear@0 28 virtual float get_fov() const;
nuclear@0 29
nuclear@0 30 virtual void set_position(const Vector3 &pos);
nuclear@0 31 virtual const Vector3 &get_position() const;
nuclear@0 32 virtual const Matrix4x4 &get_matrix() const;
nuclear@0 33
nuclear@0 34 virtual Ray get_primary_ray(int x, int y, int xsz, int ysz, int sample = 0) const;
nuclear@0 35 };
nuclear@0 36
nuclear@0 37 class TargetCamera : public Camera {
nuclear@0 38 protected:
nuclear@0 39 Vector3 target;
nuclear@0 40
nuclear@0 41 void calc_matrix(Matrix4x4 *mat) const;
nuclear@0 42
nuclear@0 43 public:
nuclear@0 44 TargetCamera();
nuclear@0 45 TargetCamera(const Vector3 &pos, const Vector3 &targ);
nuclear@0 46
nuclear@0 47 virtual void set_target(const Vector3 &targ);
nuclear@0 48 virtual const Vector3 &get_target() const;
nuclear@0 49 };
nuclear@0 50
nuclear@0 51 class FlyCamera : public Camera {
nuclear@0 52 protected:
nuclear@0 53 Quaternion rot;
nuclear@0 54
nuclear@0 55 void calc_matrix(Matrix4x4 *mat) const;
nuclear@0 56
nuclear@0 57 public:
nuclear@0 58 void input_move(float x, float y, float z);
nuclear@0 59 void input_rotate(float x, float y, float z);
nuclear@0 60 };
nuclear@0 61
nuclear@0 62 #endif // CAMERA_H_