-
Notifications
You must be signed in to change notification settings - Fork 0
/
cameras.h
72 lines (62 loc) · 2.02 KB
/
cameras.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef CAMERAS_H
#define CAMERAS_H
/**
* This file contains the ICamera interface, and a camera that implements it.
*
* Do you want to have MULTIPLE cameras in your model? Just add multiple
* SimpleCameraModels to your model, then override the getCamera() method to
* return a SimpleCameraModel.
*
* If you're feeling really ambitious, implement a new kind of camera that
* implements interface ICamera.
*/
#include "model.h"
/**
* Classes implementing this interface can be controlled like cameras,
* meaning that you can manipulate them by dragging your mouse in the
* model view window.
*/
class ICamera : public SignalDispatcher {
public:
/**
* Set this camera using the given vectors.
*/
virtual void fromVectors(Vec3f& position, Vec3f& lookAt, Vec3f& up,
float _fov, float _aspectRatio) = 0;
/**
* Convert this camera to vectors.
*/
virtual void toVectors(Vec3f& position, Vec3f& lookAt, Vec3f& up,
float& fov) = 0;
/**
* Have the camera plot its position at the given time.
*/
virtual void plotKeyframe(float t) = 0;
/**
* Remove the current keyframe
*/
virtual void clearKeyframe(float t) = 0;
/** Make sure the subclass's destructor is called */
virtual ~ICamera();
};
/**
* A basic camera, with a constrained up-vector. TODO: unconstrain this vector!
*/
class SimpleCameraModel : public Model, public ICamera {
protected:
RangeProperty azimuth, elevation, dolly, twist,
lookAtX, lookAtY, lookAtZ, fov;
float aspectRatio;
public:
SimpleCameraModel(const char* name,
Vec3f& lookAt = Vec3f(0, 0, 0), float azimuth = 0,
float elevation = 30, float dolly = 20, float twist = 0,
float fov = 40);
void fromVectors(Vec3f& position, Vec3f& lookAt, Vec3f& up, float _fov, float _aspectRatio);
void toVectors(Vec3f& position, Vec3f& lookAt, Vec3f& up, float& _fov);
static void onChange(SignalDispatcher* d, void* v, void* a);
void plotKeyframe(float t);
void clearKeyframe(float t);
void draw();
};
#endif // CAMERAS_H