]> git.localhorst.tv Git - space.git/blob - src/graphics/Camera.h
dynamic zoom
[space.git] / src / graphics / Camera.h
1 #ifndef SPACE_CAMERA_H_
2 #define SPACE_CAMERA_H_
3
4 #include "../math/Vector.h"
5
6
7 namespace space {
8
9 class Camera {
10
11 public:
12         Camera(int w, int h, const Vector<float> &);
13
14 public:
15         void SetTarget(const Vector<float> &t) { target = &t; }
16         void SetZoom(float z) { zoom = z; }
17
18         void Resize(int w, int h);
19         void Update(float deltaT);
20
21         void StartZoom();
22         void StopZoom();
23         void StartShrink();
24         void StopShrink();
25
26         Vector<int> ToScreen(Vector<float> v) const {
27                 return Vector<int>(OffsetOf(v));
28         }
29         Vector<float> OffsetOf(Vector<float> v) const {
30                 return ToScale(v - *target) + offset;
31         }
32         Vector<float> ToScale(Vector<float> v) const {
33                 return v * zoom;
34         }
35
36 private:
37         const Vector<float> *target;
38         Vector<float> offset;
39
40         float zoom;
41         int zoomAcc;
42
43 };
44
45 }
46
47 #endif