rev |
line source |
nuclear@1
|
1 #ifndef CAMERA_H_
|
nuclear@1
|
2 #define CAMERA_H_
|
nuclear@1
|
3
|
nuclear@1
|
4 #include "vmath/vmath.h"
|
nuclear@1
|
5
|
nuclear@1
|
6 class Camera {
|
nuclear@1
|
7 protected:
|
nuclear@1
|
8 mutable struct {
|
nuclear@1
|
9 bool valid;
|
nuclear@1
|
10 Matrix4x4 mat;
|
nuclear@1
|
11 } mcache, mcache_inv;
|
nuclear@1
|
12
|
nuclear@1
|
13 virtual void calc_matrix(Matrix4x4 *mat) const = 0;
|
nuclear@1
|
14 virtual void calc_inv_matrix(Matrix4x4 *mat) const;
|
nuclear@1
|
15
|
nuclear@1
|
16 void inval_cache() { mcache.valid = mcache_inv.valid = false; }
|
nuclear@1
|
17 void set_glmat(const Matrix4x4 &m) const;
|
nuclear@1
|
18
|
nuclear@1
|
19 public:
|
nuclear@1
|
20 Camera();
|
nuclear@1
|
21 virtual ~Camera();
|
nuclear@1
|
22
|
nuclear@1
|
23 const Matrix4x4 &matrix() const;
|
nuclear@1
|
24 const Matrix4x4 &inv_matrix() const;
|
nuclear@1
|
25
|
nuclear@1
|
26 void use() const;
|
nuclear@1
|
27 void use_inverse() const;
|
nuclear@1
|
28
|
nuclear@1
|
29 // these do nothing, override to provide input handling
|
nuclear@1
|
30 virtual void input_move(float x, float y, float z);
|
nuclear@1
|
31 virtual void input_rotate(float x, float y, float z);
|
nuclear@1
|
32 virtual void input_zoom(float factor);
|
nuclear@1
|
33 };
|
nuclear@1
|
34
|
nuclear@1
|
35 class OrbitCamera : public Camera {
|
nuclear@7
|
36 protected:
|
nuclear@1
|
37 float theta, phi, rad;
|
nuclear@1
|
38
|
nuclear@1
|
39 void calc_matrix(Matrix4x4 *mat) const;
|
nuclear@1
|
40 void calc_inv_matrix(Matrix4x4 *mat) const;
|
nuclear@1
|
41
|
nuclear@1
|
42 public:
|
nuclear@1
|
43 OrbitCamera();
|
nuclear@1
|
44 virtual ~OrbitCamera();
|
nuclear@1
|
45
|
nuclear@1
|
46 void input_rotate(float x, float y, float z);
|
nuclear@1
|
47 void input_zoom(float factor);
|
nuclear@1
|
48 };
|
nuclear@1
|
49
|
nuclear@7
|
50 class FpsCamera : public OrbitCamera {
|
nuclear@7
|
51 protected:
|
nuclear@7
|
52 Vector3 pos;
|
nuclear@7
|
53
|
nuclear@7
|
54 void calc_matrix(Matrix4x4 *mat) const;
|
nuclear@7
|
55 void calc_inv_matrix(Matrix4x4 *mat) const;
|
nuclear@7
|
56
|
nuclear@7
|
57 public:
|
nuclear@7
|
58 void input_move(float x, float y, float z);
|
nuclear@48
|
59
|
nuclear@48
|
60 const Vector3 &get_position() const;
|
nuclear@7
|
61 };
|
nuclear@7
|
62
|
nuclear@1
|
63 class FlyCamera : public Camera {
|
nuclear@1
|
64 private:
|
nuclear@1
|
65 Vector3 pos;
|
nuclear@1
|
66 Quaternion rot;
|
nuclear@1
|
67
|
nuclear@1
|
68 void calc_matrix(Matrix4x4 *mat) const;
|
nuclear@1
|
69 //void calc_inv_matrix(Matrix4x4 *mat) const;
|
nuclear@1
|
70
|
nuclear@1
|
71 public:
|
nuclear@1
|
72 FlyCamera();
|
nuclear@1
|
73
|
nuclear@1
|
74 const Vector3 &get_position() const;
|
nuclear@1
|
75 const Quaternion &get_rotation() const;
|
nuclear@1
|
76
|
nuclear@1
|
77 void input_move(float x, float y, float z);
|
nuclear@1
|
78 void input_rotate(float x, float y, float z);
|
nuclear@1
|
79 };
|
nuclear@1
|
80
|
nuclear@1
|
81
|
nuclear@1
|
82 #endif // CAMERA_H_
|