erebus

view liberebus/src/camera.h @ 42:b9294cd6b9dc

console input history with up/down
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 10 Jun 2014 16:15:08 +0300
parents 9621beb22694
children bab25c0ce337
line source
1 #ifndef CAMERA_H_
2 #define CAMERA_H_
4 #include "vmath/vmath.h"
6 class Camera {
7 protected:
8 Vector3 pos;
9 float vfov; // vertical field of view in radians
11 mutable Matrix4x4 cached_matrix;
12 mutable bool cached_matrix_valid;
14 virtual void calc_matrix(Matrix4x4 *mat) const = 0;
16 Vector2 calc_sample_pos(int x, int y, int xsz, int ysz, int sample) const;
18 public:
19 Camera();
20 Camera(const Vector3 &pos);
21 virtual ~Camera();
23 virtual void set_fov(float vfov);
24 virtual float get_fov() const;
26 virtual void set_position(const Vector3 &pos);
27 virtual const Vector3 &get_position() const;
28 virtual const Matrix4x4 &get_matrix() const;
30 virtual Ray get_primary_ray(int x, int y, int xsz, int ysz, int sample = 0) const;
31 };
33 class TargetCamera : public Camera {
34 protected:
35 Vector3 target;
37 void calc_matrix(Matrix4x4 *mat) const;
39 public:
40 TargetCamera();
41 TargetCamera(const Vector3 &pos, const Vector3 &targ);
43 virtual void set_target(const Vector3 &targ);
44 virtual const Vector3 &get_target() const;
45 };
47 class FlyCamera : public Camera {
48 protected:
49 Quaternion rot;
51 void calc_matrix(Matrix4x4 *mat) const;
53 public:
54 void input_move(float x, float y, float z);
55 void input_rotate(float x, float y, float z);
56 };
58 #endif // CAMERA_H_