erebus
annotate liberebus/src/camera.h @ 48:9971a08f4104
merged
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 24 Feb 2016 00:29:31 +0200 |
parents | bab25c0ce337 |
children |
rev | line source |
---|---|
nuclear@0 | 1 #ifndef CAMERA_H_ |
nuclear@0 | 2 #define CAMERA_H_ |
nuclear@0 | 3 |
nuclear@45 | 4 #include <gmath/gmath.h> |
nuclear@0 | 5 |
nuclear@0 | 6 class Camera { |
nuclear@0 | 7 protected: |
nuclear@46 | 8 Vec3 pos; |
nuclear@0 | 9 float vfov; // vertical field of view in radians |
nuclear@0 | 10 |
nuclear@46 | 11 mutable Mat4x4 cached_matrix; |
nuclear@0 | 12 mutable bool cached_matrix_valid; |
nuclear@0 | 13 |
nuclear@46 | 14 virtual void calc_matrix(Mat4x4 *mat) const = 0; |
nuclear@0 | 15 |
nuclear@46 | 16 Vec2 calc_sample_pos(int x, int y, int xsz, int ysz, int sample) const; |
nuclear@0 | 17 |
nuclear@0 | 18 public: |
nuclear@0 | 19 Camera(); |
nuclear@46 | 20 Camera(const Vec3 &pos); |
nuclear@0 | 21 virtual ~Camera(); |
nuclear@0 | 22 |
nuclear@0 | 23 virtual void set_fov(float vfov); |
nuclear@0 | 24 virtual float get_fov() const; |
nuclear@0 | 25 |
nuclear@46 | 26 virtual void set_position(const Vec3 &pos); |
nuclear@46 | 27 virtual const Vec3 &get_position() const; |
nuclear@46 | 28 virtual const Mat4x4 &get_matrix() const; |
nuclear@0 | 29 |
nuclear@0 | 30 virtual Ray get_primary_ray(int x, int y, int xsz, int ysz, int sample = 0) const; |
nuclear@0 | 31 }; |
nuclear@0 | 32 |
nuclear@0 | 33 class TargetCamera : public Camera { |
nuclear@0 | 34 protected: |
nuclear@46 | 35 Vec3 target; |
nuclear@0 | 36 |
nuclear@46 | 37 void calc_matrix(Mat4x4 *mat) const; |
nuclear@0 | 38 |
nuclear@0 | 39 public: |
nuclear@0 | 40 TargetCamera(); |
nuclear@46 | 41 TargetCamera(const Vec3 &pos, const Vec3 &targ); |
nuclear@0 | 42 |
nuclear@46 | 43 virtual void set_target(const Vec3 &targ); |
nuclear@46 | 44 virtual const Vec3 &get_target() const; |
nuclear@0 | 45 }; |
nuclear@0 | 46 |
nuclear@0 | 47 class FlyCamera : public Camera { |
nuclear@0 | 48 protected: |
nuclear@46 | 49 Quat rot; |
nuclear@0 | 50 |
nuclear@46 | 51 void calc_matrix(Mat4x4 *mat) const; |
nuclear@0 | 52 |
nuclear@0 | 53 public: |
nuclear@0 | 54 void input_move(float x, float y, float z); |
nuclear@0 | 55 void input_rotate(float x, float y, float z); |
nuclear@0 | 56 }; |
nuclear@0 | 57 |
nuclear@0 | 58 #endif // CAMERA_H_ |