]> git.localhorst.tv Git - gworm.git/blob - src/graphics/Camera.h
basic gravity calculations
[gworm.git] / src / graphics / Camera.h
1 #ifndef GWORM_CAMERA_H_
2 #define GWORM_CAMERA_H_
3
4 #include "Vector.h"
5
6
7 namespace gworm {
8
9 class Camera {
10
11 public:
12         Camera(Vector<int> size, const Vector<float> &);
13
14 public:
15         void SetTarget(const Vector<float> &t) { target = &t; }
16
17         Vector<int> ScreenSize() const { return size; }
18
19         void Resize(int w, int h) { Resize(Vector<int>(w, h)); }
20         void Resize(Vector<int>);
21         void Update(float deltaT) { } // unused
22
23         /// transform v from world coords to screen coords
24         Vector<int> ToScreen(Vector<float> v) const {
25                 return Vector<int>(v - *target) + offset;
26         }
27
28         /// transform v from screen coords to world coords
29         Vector<float> FromScreen(Vector<int> v) const {
30                 return Vector<float>(v - offset) + *target;
31         }
32
33 private:
34         const Vector<float> *target;
35         Vector<int> size;
36         Vector<int> offset;
37
38 };
39
40 }
41
42 #endif