-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEmpty.cpp
112 lines (90 loc) · 2.84 KB
/
Empty.cpp
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "Empty.h"
Empty::Empty() {
emp = smgr->addEmptySceneNode();
}
Empty::Empty(const Vector3D& pos) : Empty() {
emp->setPosition(irr::core::vector3df(pos.x, pos.y, pos.z));
}
Empty::Empty(const Vector3D& pos, const Vector3D& rot) : Empty(pos) {
emp->setRotation(irr::core::vector3df(rot.x, rot.y, rot.z));
}
Empty::Empty(const Vector3D& pos, const Vector3D& rot, const Vector3D& scale) : Empty(pos, rot) {
emp->setScale(irr::core::vector3df(scale.x, scale.y, scale.z));
}
bool Empty::getVisibility() const {
if (!emp)
return false;
return emp->isVisible();
}
void Empty::setVisibility(bool visible) {
emp->setVisible(visible);
}
Vector3D Empty::getPosition() {
if (!emp)
return Vector3D();
return Vector3D(emp->getPosition().X, emp->getPosition().Y, emp->getPosition().Z);
}
void Empty::setPosition(const Vector3D& pos) {
if (!emp)
return;
emp->setPosition(irr::core::vector3df(pos.x, pos.y, pos.z));
}
Vector3D Empty::getRotation() {
if (!emp)
return Vector3D();
return Vector3D(emp->getRotation().X, emp->getRotation().Y, emp->getRotation().Z);
}
void Empty::setRotation(const Vector3D& rot) {
if (!emp)
return;
emp->setRotation(irr::core::vector3df(rot.x, rot.y, rot.z));
}
Vector3D Empty::getScale() {
if (!emp)
return Vector3D();
return Vector3D(emp->getScale().X, emp->getScale().Y, emp->getScale().Z);
}
void Empty::setScale(const Vector3D& scale) {
if (!emp)
return;
emp->setScale(irr::core::vector3df(scale.x, scale.y, scale.z));
}
bool Empty::getDebug() {
return emp ? d != nullptr : false;
}
void Empty::setDebug(bool visible) {
if (emp) {
if (visible && !d)
d = new DebugSceneNode(emp, smgr, 0, DebugType::EMPTY);
else
d->remove();
}
}
sol::table Empty::getBoundingBox() {
sol::table result = lua->create_table();
result["min"] = Vector3D();
result["max"] = Vector3D();
if (emp) {
core::aabbox3d<f32> bb = emp->getTransformedBoundingBox();
result["min"] = Vector3D(bb.MinEdge.X, bb.MinEdge.Y, bb.MinEdge.Z);
result["max"] = Vector3D(bb.MaxEdge.X, bb.MaxEdge.Y, bb.MaxEdge.Z);
}
return result;
}
void Empty::destroy() {
if (emp)
emp->remove();
}
void bindEmpty() {
sol::usertype<Empty> bind_type = lua->new_usertype<Empty>("Empty",
sol::constructors<Empty(), Empty(const Vector3D & pos), Empty(const Vector3D & pos, const Vector3D & rot), Empty(const Vector3D & pos, const Vector3D & rot, const Vector3D & scale)>(),
sol::base_classes, sol::bases<Compatible3D>(),
"visible", sol::property(&Empty::getVisibility, &Empty::setVisibility),
"position", sol::property(&Empty::getPosition, &Empty::setPosition),
"rotation", sol::property(&Empty::getRotation, &Empty::setRotation),
"scale", sol::property(&Empty::getScale, &Empty::setScale),
"debug", sol::property(&Empty::getDebug, &Empty::setDebug)
);
bind_type["destroy"] = &Empty::destroy;
bind_type["getBoundingBox"] = &Empty::getBoundingBox;
}