-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndicator.cpp
85 lines (69 loc) · 1.77 KB
/
Indicator.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
#include "Indicator.h"
#include "main.h"
Indicator::Indicator(VegetableType veggie) {
type = veggie;
if (veggie_map[type].requires_water) {
model = INDICATOR_WATER;
}
else if (veggie_map[type].requires_fertilizer) {
model = INDICATOR_FERTILIZER;
}
else {
model = INDICATOR_WATER;
printf("why did you make an indicator class?\n");
}
translate = new glm::vec2(0.f, 0.f);
translate3D = new glm::vec3(0.f, 0.f, 0.f);
rotation = glm::mat4(1);
}
Indicator::~Indicator()
{
delete translate;
delete translate3D;
}
void Indicator::FixedUpdate() {
//TODO: get camera pos to set rotation
if (currHeight >= maxHeight)
goingUp = false;
else if (currHeight <= minHeight)
goingUp = true;
if (goingUp)
currHeight += heightIncrement;
else
currHeight -= heightIncrement;
}
glm::mat4 Indicator::GetParentTransform()
{
return GetTranslation() * rotation;
}
ModelEnum Indicator::GetModelEnum() { return model; }
AniMode Indicator::GetAniMode() { return modelAnim; }
glm::vec3 Indicator::GetPosition() const
{
return glm::vec3((*translate)[0], currHeight, -(*translate)[1]);
}
glm::mat4 Indicator::GetTranslation() {
return glm::translate(glm::vec3((*translate3D)[0], currHeight, -(*translate3D)[2]));
}
glm::mat4 Indicator::GetRotation() const
{
return rotation;
}
void Indicator::SetPosition(glm::vec3 position)
{
*translate = glm::vec2(position[0], -position[2]);
*translate3D = glm::vec3(position[0], currHeight, -position[2]);
}
void Indicator::SetRotation(glm::mat4 rotation)
{
this->rotation = rotation;
}
glm::mat4 Indicator::GetTransformation() {
return glm::translate(glm::vec3((*translate3D)[0], currHeight, -(*translate3D)[2])) * rotation;
}
void Indicator::SetWater() {
model = INDICATOR_WATER;
}
void Indicator::SetFertilize() {
model = INDICATOR_FERTILIZER;
}