-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransform.cpp
39 lines (27 loc) · 850 Bytes
/
transform.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
#include "m_transform.h"
void Transform::setPosition(Vector3f _position){
position = _position;
};
void Transform::setRotation(Vector3f _rotation){
rotation = _rotation;
};
void Transform::setScale(Vector3f _scale){
scale = _scale;
};
void Transform::translateBy(Vector3f _translateBy){
position += _translateBy;
};
void Transform::rotateBy(Vector3f _rotateBy){
rotation += _rotateBy;
};
void Transform::scaleBy(Vector3f _scaleBy){
scale += _scaleBy;
};
void Transform::getMatrix(Matrix4f* ret) {
ScaleMatrix scaleMatrix(scale);
RotationXMatrix rotateXMatrix(rotation.x);
RotationYMatrix rotateYMatrix(rotation.y);
RotationZMatrix rotateZMatrix(rotation.z);
TranslationMatrix translateMatrix(position);
*ret = translateMatrix * rotateXMatrix * rotateYMatrix * rotateZMatrix * scaleMatrix;
}