dungeon_crawler
view prototype/src/camera.h @ 50:c40efa9cf844
torches sound
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 18 Sep 2012 04:45:46 +0300 |
parents | 8fb37db44fd8 |
children |
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);
60 const Vector3 &get_position() const;
61 };
63 class FlyCamera : public Camera {
64 private:
65 Vector3 pos;
66 Quaternion rot;
68 void calc_matrix(Matrix4x4 *mat) const;
69 //void calc_inv_matrix(Matrix4x4 *mat) const;
71 public:
72 FlyCamera();
74 const Vector3 &get_position() const;
75 const Quaternion &get_rotation() const;
77 void input_move(float x, float y, float z);
78 void input_rotate(float x, float y, float z);
79 };
82 #endif // CAMERA_H_