-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmovable.cpp
More file actions
134 lines (111 loc) · 1.85 KB
/
movable.cpp
File metadata and controls
134 lines (111 loc) · 1.85 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include "stdafx.h"
#include "movable.h"
Movable::Movable() : m_pendingMatrixUpdate(false), m_scale(1.f) {}
Movable::Movable(float x, float y, float z) : m_pendingMatrixUpdate(true)
{
m_pos.x = x;
m_pos.y = y;
m_pos.z = z;
m_scale = 1.f;
}
void Movable::setPos(float x, float y, float z)
{
m_pos.x = x;
m_pos.y = y;
m_pos.z = z;
m_pendingMatrixUpdate = true;
}
void Movable::setPos(const math::vec3 & pos)
{
m_pos = pos;
m_pendingMatrixUpdate = true;
}
void Movable::setRot(const math::Quaternion & quat)
{
m_rot = quat;
m_pendingMatrixUpdate = true;
}
void Movable::setScale(float scale)
{
m_scale = scale;
m_pendingMatrixUpdate = true;
}
void Movable::move(float x, float y, float z)
{
m_pos.x += x;
m_pos.y += y;
m_pos.z += z;
m_pendingMatrixUpdate = true;
}
void Movable::move(const math::vec3 & delta)
{
m_pos += delta;
m_pendingMatrixUpdate = true;
}
void Movable::rotate(float x, float y, float z, float w)
{
// ///
setRot(math::Quaternion(x, y, z, w)); //To be extended
m_pendingMatrixUpdate = true;
}
void Movable::rotate(const math::Quaternion & quat)
{
m_rot = quat*m_rot;
m_pendingMatrixUpdate = true;
}
void Movable::scale(float scale)
{
m_scale *= scale;
m_pendingMatrixUpdate = true;
}
math::vec3 Movable::getPos()
{
return m_pos;
}
math::Quaternion Movable::getRot()
{
return m_rot;
}
float Movable::getScale()
{
return m_scale;
}
float Movable::getPosX()
{
return m_pos.x;
}
float Movable::getPosY()
{
return m_pos.y;
}
float Movable::getPosZ()
{
return m_pos.z;
}
float Movable::getRotX()
{
return m_rot.x;
}
float Movable::getRotY()
{
return m_rot.y;
}
float Movable::getRotZ()
{
return m_rot.z;
}
float Movable::getRotW()
{
return m_rot.w;
}
void Movable::resetPos()
{
m_pos.reset();
m_rot.reset();
m_scale = 0;
m_pendingMatrixUpdate = true;
}
bool Movable::pendingUpdate()
{
return m_pendingMatrixUpdate;
}