forked from abertay-cmp404/virtual_vita
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameObjectMy.cpp
More file actions
96 lines (74 loc) · 1.75 KB
/
GameObjectMy.cpp
File metadata and controls
96 lines (74 loc) · 1.75 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
#include "GameObjectMy.h"
#include <maths/math_utils.h>
GameObjectMy::GameObjectMy()
{
Init();
}
GameObjectMy::~GameObjectMy()
{
}
void GameObjectMy::Init()
{
velocity_ = gef::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
position_ = gef::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
rotationX_ = 0.0f;
rotationY_ = 0.0f;
rotationZ_ = 0.0f;
localTransform_.SetIdentity();
scale_ = { 1.0f, 1.0f, 1.0f };
}
bool GameObjectMy::Update(float frame_time)
{
position_ += velocity_ * frame_time;
BuildTransformationMatrix();
return true;
}
gef::Matrix44 GameObjectMy::BuildRotationX(float RadAngle_)
{
gef::Matrix44 rotation;
rotation.SetIdentity();
rotation.RotationX(gef::DegToRad(RadAngle_));
return rotation;
}
gef::Matrix44 GameObjectMy::BuildRotationY(float RadAngle_)
{
gef::Matrix44 rotation;
rotation.SetIdentity();
rotation.RotationY(gef::DegToRad(RadAngle_));
return rotation;
}
gef::Matrix44 GameObjectMy::BuildRotationZ(float RadAngle_)
{
gef::Matrix44 rotation;
rotation.SetIdentity();
rotation.RotationZ(gef::DegToRad(RadAngle_));
return rotation;
}
gef::Matrix44 GameObjectMy::BuildScale(gef::Vector4 scale)
{
gef::Matrix44 Scale;
Scale.SetIdentity();
Scale.Scale(scale);
return Scale;
}
gef::Matrix44 GameObjectMy::BuildTranslate(gef::Vector4 tranlate)
{
gef::Matrix44 Trans;
Trans.SetIdentity();
Trans.SetTranslation(tranlate);
return Trans;
}
void GameObjectMy::BuildTransformationMatrix()
{
gef::Matrix44 rotation_X,
rotation_Y,
rotation_Z,
Scaleing,
translate;
Scaleing = BuildScale(scale_);
rotation_X = BuildRotationX(rotationX_);
rotation_Y = BuildRotationY(rotationY_);
rotation_Z = BuildRotationZ(rotationZ_);
translate = BuildTranslate(position_);
localTransform_= Scaleing * rotation_X * rotation_Y * rotation_Z * translate;
}