erebus
view 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 |
line source
1 #ifndef CAMERA_H_
2 #define CAMERA_H_
4 #include <gmath/gmath.h>
6 class Camera {
7 protected:
8 Vec3 pos;
9 float vfov; // vertical field of view in radians
11 mutable Mat4x4 cached_matrix;
12 mutable bool cached_matrix_valid;
14 virtual void calc_matrix(Mat4x4 *mat) const = 0;
16 Vec2 calc_sample_pos(int x, int y, int xsz, int ysz, int sample) const;
18 public:
19 Camera();
20 Camera(const Vec3 &pos);
21 virtual ~Camera();
23 virtual void set_fov(float vfov);
24 virtual float get_fov() const;
26 virtual void set_position(const Vec3 &pos);
27 virtual const Vec3 &get_position() const;
28 virtual const Mat4x4 &get_matrix() const;
30 virtual Ray get_primary_ray(int x, int y, int xsz, int ysz, int sample = 0) const;
31 };
33 class TargetCamera : public Camera {
34 protected:
35 Vec3 target;
37 void calc_matrix(Mat4x4 *mat) const;
39 public:
40 TargetCamera();
41 TargetCamera(const Vec3 &pos, const Vec3 &targ);
43 virtual void set_target(const Vec3 &targ);
44 virtual const Vec3 &get_target() const;
45 };
47 class FlyCamera : public Camera {
48 protected:
49 Quat rot;
51 void calc_matrix(Mat4x4 *mat) const;
53 public:
54 void input_move(float x, float y, float z);
55 void input_rotate(float x, float y, float z);
56 };
58 #endif // CAMERA_H_