-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtransform.hpp
More file actions
61 lines (49 loc) · 1.12 KB
/
transform.hpp
File metadata and controls
61 lines (49 loc) · 1.12 KB
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
//
// transform.hpp
// Simpleton Engine
//
// Created by Indi Kernick on 15/11/17.
// Copyright © 2017 Indi Kernick. All rights reserved.
//
#ifndef engine_camera_2d_transform_hpp
#define engine_camera_2d_transform_hpp
#include "aabb.hpp"
#include <glm/vec2.hpp>
#include <glm/mat3x3.hpp>
namespace Cam2D {
struct Props;
enum class Origin {
TOP_LEFT,
TOP_MID,
TOP_RIGHT,
MID_RIGHT,
BOTTOM_RIGHT,
BOTTOM_MID,
BOTTOM_LEFT,
MID_LEFT,
CENTER
};
class Transform {
public:
Transform() = default;
void setOrigin(Origin);
void setInvertX(bool);
void setInvertY(bool);
void setSize(glm::vec2);
glm::mat3 toPixels() const;
glm::mat3 toMeters() const;
void calculate(Props, Params);
private:
glm::mat3 toPixelsMat;
glm::mat3 toMetersMat;
glm::vec2 boxSize = {0.0f, 0.0f};
Origin origin = Origin::CENTER;
bool invertX = false;
bool invertY = false;
glm::vec2 calcOriginPos() const;
glm::vec2 calcInvertedScale() const;
glm::vec2 calcShiftedPos(Params) const;
};
}
#include "transform.inl"
#endif