-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtransform3d.cpp
More file actions
59 lines (51 loc) · 1000 Bytes
/
transform3d.cpp
File metadata and controls
59 lines (51 loc) · 1000 Bytes
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
#include "transform3d.h"
// Transform by (Add / scale)
void Transform3D::translate(const QVector3D &dt)
{
m_dirty = true;
m_translation += dt;
}
void Transform3D::scale(const QVector3D &ds)
{
m_dirty = true;
m_scale += ds;
}
void Transform3D::rotate(const QQuaternion &dr)
{
m_dirty = true;
m_rotation = dr * m_rotation;
}
void Transform3D::grow(const QVector3D &ds)
{
m_dirty = true;
m_scale += ds;
}
// Transform To (Setters)
void Transform3D::setTranslation(const QVector3D &t)
{
m_dirty = true;
m_translation = t;
}
void Transform3D::setScale(const QVector3D &s)
{
m_dirty = true;
m_scale = s;
}
void Transform3D::setRotation(const QQuaternion &r)
{
m_dirty = true;
m_rotation = r;
}
// Accessors
const QMatrix4x4 &Transform3D::toMatrix()
{
if (m_dirty)
{
m_dirty = false;
m_world.setToIdentity();
m_world.translate(m_translation);
m_world.rotate(m_rotation);
m_world.scale(m_scale);
}
return m_world;
}