annotate liberebus/src/camera.h @ 44:a2afaf8af09b
helpful comment
author |
John Tsiombikas <nuclear@member.fsf.org> |
date |
Fri, 18 Sep 2015 06:47:41 +0300 |
parents |
9621beb22694 |
children |
bab25c0ce337 |
rev |
line source |
nuclear@0
|
1 #ifndef CAMERA_H_
|
nuclear@0
|
2 #define CAMERA_H_
|
nuclear@0
|
3
|
nuclear@0
|
4 #include "vmath/vmath.h"
|
nuclear@0
|
5
|
nuclear@0
|
6 class Camera {
|
nuclear@0
|
7 protected:
|
nuclear@0
|
8 Vector3 pos;
|
nuclear@0
|
9 float vfov; // vertical field of view in radians
|
nuclear@0
|
10
|
nuclear@0
|
11 mutable Matrix4x4 cached_matrix;
|
nuclear@0
|
12 mutable bool cached_matrix_valid;
|
nuclear@0
|
13
|
nuclear@0
|
14 virtual void calc_matrix(Matrix4x4 *mat) const = 0;
|
nuclear@0
|
15
|
nuclear@0
|
16 Vector2 calc_sample_pos(int x, int y, int xsz, int ysz, int sample) const;
|
nuclear@0
|
17
|
nuclear@0
|
18 public:
|
nuclear@0
|
19 Camera();
|
nuclear@0
|
20 Camera(const Vector3 &pos);
|
nuclear@0
|
21 virtual ~Camera();
|
nuclear@0
|
22
|
nuclear@0
|
23 virtual void set_fov(float vfov);
|
nuclear@0
|
24 virtual float get_fov() const;
|
nuclear@0
|
25
|
nuclear@0
|
26 virtual void set_position(const Vector3 &pos);
|
nuclear@0
|
27 virtual const Vector3 &get_position() const;
|
nuclear@0
|
28 virtual const Matrix4x4 &get_matrix() const;
|
nuclear@0
|
29
|
nuclear@0
|
30 virtual Ray get_primary_ray(int x, int y, int xsz, int ysz, int sample = 0) const;
|
nuclear@0
|
31 };
|
nuclear@0
|
32
|
nuclear@0
|
33 class TargetCamera : public Camera {
|
nuclear@0
|
34 protected:
|
nuclear@0
|
35 Vector3 target;
|
nuclear@0
|
36
|
nuclear@0
|
37 void calc_matrix(Matrix4x4 *mat) const;
|
nuclear@0
|
38
|
nuclear@0
|
39 public:
|
nuclear@0
|
40 TargetCamera();
|
nuclear@0
|
41 TargetCamera(const Vector3 &pos, const Vector3 &targ);
|
nuclear@0
|
42
|
nuclear@0
|
43 virtual void set_target(const Vector3 &targ);
|
nuclear@0
|
44 virtual const Vector3 &get_target() const;
|
nuclear@0
|
45 };
|
nuclear@0
|
46
|
nuclear@0
|
47 class FlyCamera : public Camera {
|
nuclear@0
|
48 protected:
|
nuclear@0
|
49 Quaternion rot;
|
nuclear@0
|
50
|
nuclear@0
|
51 void calc_matrix(Matrix4x4 *mat) const;
|
nuclear@0
|
52
|
nuclear@0
|
53 public:
|
nuclear@0
|
54 void input_move(float x, float y, float z);
|
nuclear@0
|
55 void input_rotate(float x, float y, float z);
|
nuclear@0
|
56 };
|
nuclear@0
|
57
|
nuclear@0
|
58 #endif // CAMERA_H_
|