erebus

view 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
line source
1 #ifndef CAMERA_H_
2 #define CAMERA_H_
4 #include "vmath/vmath.h"
6 class Camera {
7 protected:
8 Vector3 pos;
9 float vfov; // vertical field of view in radians
11 mutable Matrix4x4 cached_matrix;
12 mutable bool cached_matrix_valid;
14 mutable Vector3 *rdir_cache;
15 mutable int rdir_cache_width, rdir_cache_height;
16 mutable float rdir_cache_fov;
18 virtual void calc_matrix(Matrix4x4 *mat) const = 0;
20 Vector2 calc_sample_pos(int x, int y, int xsz, int ysz, int sample) const;
22 public:
23 Camera();
24 Camera(const Vector3 &pos);
25 virtual ~Camera();
27 virtual void set_fov(float vfov);
28 virtual float get_fov() const;
30 virtual void set_position(const Vector3 &pos);
31 virtual const Vector3 &get_position() const;
32 virtual const Matrix4x4 &get_matrix() const;
34 virtual Ray get_primary_ray(int x, int y, int xsz, int ysz, int sample = 0) const;
35 };
37 class TargetCamera : public Camera {
38 protected:
39 Vector3 target;
41 void calc_matrix(Matrix4x4 *mat) const;
43 public:
44 TargetCamera();
45 TargetCamera(const Vector3 &pos, const Vector3 &targ);
47 virtual void set_target(const Vector3 &targ);
48 virtual const Vector3 &get_target() const;
49 };
51 class FlyCamera : public Camera {
52 protected:
53 Quaternion rot;
55 void calc_matrix(Matrix4x4 *mat) const;
57 public:
58 void input_move(float x, float y, float z);
59 void input_rotate(float x, float y, float z);
60 };
62 #endif // CAMERA_H_