dungeon_crawler
view prototype/src/camera.h @ 27:cbf86e5198a9
fized the vbo state creep
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 25 Aug 2012 14:37:51 +0300 |
parents | 96de911d05d4 |
children | aa9e28670ae2 |
line source
1 #ifndef CAMERA_H_
2 #define CAMERA_H_
4 #include "vmath/vmath.h"
6 class Camera {
7 protected:
8 mutable struct {
9 bool valid;
10 Matrix4x4 mat;
11 } mcache, mcache_inv;
13 virtual void calc_matrix(Matrix4x4 *mat) const = 0;
14 virtual void calc_inv_matrix(Matrix4x4 *mat) const;
16 void inval_cache() { mcache.valid = mcache_inv.valid = false; }
17 void set_glmat(const Matrix4x4 &m) const;
19 public:
20 Camera();
21 virtual ~Camera();
23 const Matrix4x4 &matrix() const;
24 const Matrix4x4 &inv_matrix() const;
26 void use() const;
27 void use_inverse() const;
29 // these do nothing, override to provide input handling
30 virtual void input_move(float x, float y, float z);
31 virtual void input_rotate(float x, float y, float z);
32 virtual void input_zoom(float factor);
33 };
35 class OrbitCamera : public Camera {
36 protected:
37 float theta, phi, rad;
39 void calc_matrix(Matrix4x4 *mat) const;
40 void calc_inv_matrix(Matrix4x4 *mat) const;
42 public:
43 OrbitCamera();
44 virtual ~OrbitCamera();
46 void input_rotate(float x, float y, float z);
47 void input_zoom(float factor);
48 };
50 class FpsCamera : public OrbitCamera {
51 protected:
52 Vector3 pos;
54 void calc_matrix(Matrix4x4 *mat) const;
55 void calc_inv_matrix(Matrix4x4 *mat) const;
57 public:
58 void input_move(float x, float y, float z);
59 };
61 class FlyCamera : public Camera {
62 private:
63 Vector3 pos;
64 Quaternion rot;
66 void calc_matrix(Matrix4x4 *mat) const;
67 //void calc_inv_matrix(Matrix4x4 *mat) const;
69 public:
70 FlyCamera();
72 const Vector3 &get_position() const;
73 const Quaternion &get_rotation() const;
75 void input_move(float x, float y, float z);
76 void input_rotate(float x, float y, float z);
77 };
80 #endif // CAMERA_H_