forked from phisko/kengine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TransformComponent.hpp
67 lines (55 loc) · 2.21 KB
/
TransformComponent.hpp
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
#pragma once
#include "SerializableComponent.hpp"
#include "Point.hpp"
#include "concat.hpp"
namespace kengine
{
template<typename Precision, std::size_t Dimensions>
class TransformComponent : public putils::Reflectible<TransformComponent<Precision, Dimensions>>,
public kengine::SerializableComponent<TransformComponent<Precision, Dimensions>>
{
public:
TransformComponent(const putils::Point<Precision, Dimensions> &pos = { 0, 0 },
const putils::Point<Precision, Dimensions> &size = { 1, 1 })
: boundingBox(pos, size)
{}
TransformComponent(const putils::Rect<Precision, Dimensions> &rect)
: boundingBox(rect)
{}
const std::string type = pmeta_nameof(TransformComponent);
putils::Rect<Precision, Dimensions> boundingBox;
Precision pitch = 0; // Radians
Precision yaw = 0; // Radians
/*
* Reflectible
*/
public:
static const auto get_class_name() { return pmeta_nameof(TransformComponent); }
static const auto &get_attributes()
{
static const auto table = pmeta::make_table(
pmeta_reflectible_attribute(&TransformComponent::type),
pmeta_reflectible_attribute(&TransformComponent::boundingBox),
pmeta_reflectible_attribute(&TransformComponent::pitch),
pmeta_reflectible_attribute(&TransformComponent::yaw)
);
return table;
}
static const auto &get_methods()
{
static const auto table = pmeta::make_table();
return table;
}
static const auto &get_parents()
{
static const auto table = pmeta::make_table();
return table;
}
};
using TransformComponent2i = TransformComponent<int, 2>;
using TransformComponent3i = TransformComponent<int, 3>;
using TransformComponent2d = TransformComponent<double, 2>;
using TransformComponent3d = TransformComponent<double, 3>;
using TransformComponent2f = TransformComponent<float, 2>;
using TransformComponent3f = TransformComponent<float, 3>;
};