goat3dgfx
view src/camera.h @ 11:d061fe1a31ec
compile vr source files or not
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 24 Nov 2013 14:00:14 +0200 |
parents | |
children | 7d6b667821cf |
line source
1 #ifndef CAMERA_H_
2 #define CAMERA_H_
4 #include <vmath/vmath.h>
6 class Camera {
7 protected:
8 float roll;
10 mutable struct {
11 bool valid;
12 Matrix4x4 mat;
13 } mcache, mcache_inv;
15 virtual void calc_matrix(Matrix4x4 *mat) const = 0;
16 virtual void calc_inv_matrix(Matrix4x4 *mat) const;
18 void inval_cache() { mcache.valid = mcache_inv.valid = false; }
19 void set_glmat(const Matrix4x4 &m) const;
21 public:
22 Camera();
23 virtual ~Camera();
25 const Matrix4x4 &matrix() const;
26 const Matrix4x4 &inv_matrix() const;
28 void use() const;
29 void use_inverse() const;
31 // these do nothing, override to provide input handling
32 virtual void input_move(float x, float y, float z);
33 virtual void input_rotate(float x, float y, float z);
34 virtual void input_zoom(float factor);
35 };
37 class OrbitCamera : public Camera {
38 protected:
39 float theta, phi, rad;
41 void calc_matrix(Matrix4x4 *mat) const;
42 void calc_inv_matrix(Matrix4x4 *mat) const;
44 public:
45 OrbitCamera();
46 virtual ~OrbitCamera();
48 void input_rotate(float x, float y, float z);
49 void input_zoom(float factor);
50 };
52 class FpsCamera : public OrbitCamera {
53 protected:
54 Vector3 pos;
56 void calc_matrix(Matrix4x4 *mat) const;
57 void calc_inv_matrix(Matrix4x4 *mat) const;
59 public:
60 void input_move(float x, float y, float z);
62 const Vector3 &get_position() const;
63 };
65 class FlyCamera : public Camera {
66 private:
67 Vector3 pos;
68 Quaternion rot;
70 void calc_matrix(Matrix4x4 *mat) const;
71 //void calc_inv_matrix(Matrix4x4 *mat) const;
73 public:
74 FlyCamera();
76 const Vector3 &get_position() const;
77 const Quaternion &get_rotation() const;
79 void input_move(float x, float y, float z);
80 void input_rotate(float x, float y, float z);
81 };
84 class VRFpsCamera : public FpsCamera {
85 private:
86 float neck_eye_dist;
87 float prev_angles[3];
89 void calc_matrix(Matrix4x4 *mat) const;
90 void calc_inv_matrix(Matrix4x4 *mat) const;
92 public:
93 VRFpsCamera();
95 void track_vr();
96 };
98 #endif // CAMERA_H_