-
Notifications
You must be signed in to change notification settings - Fork 1
/
shape.cpp
118 lines (88 loc) · 2.33 KB
/
shape.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
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
#include "shape.h"
#include "header.h"
Shape::Shape(float x, float y, float z) {
this->x = x;
this->y = y;
this->z = z;
this->mvp_changed = false;
setRotateValues(0.00f, 0.00f, 0.00f);
setSpeed();
setRotateSpeed();
}
Shape::~Shape() {
}
// der Destruktor
void Shape::setRotateValues(float rotX, float rotY, float rotZ) {
this->rotateX = rotX;
this->rotateY = rotY;
this->rotateZ = rotZ;
// DBG("rotateX = %f, rotateY = %f, rotateZ = %f", rotateX, rotateY, rotateZ);
ViewRotateX = glm::rotate(ViewTranslate, glm::radians(rotateX), glm::vec3(1.0f, 0.0f, 0.0f));
ViewRotateY = glm::rotate(ViewRotateX, glm::radians(rotateY), glm::vec3(0.0f, 1.0f, 0.0f));
ViewRotateZ = glm::rotate(ViewRotateY, glm::radians(rotateZ), glm::vec3(0.0f, 0.0f, 1.0f));
adjustMatrices();
}
void Shape::setMatrix(btScalar *mat) {
std::memcpy(m, mat, matrix_dimension*sizeof(btScalar));
}
float Shape::getRotateValueX() {
return this->rotateX;
}
float Shape::getRotateValueY() {
return this->rotateY;
}
float Shape::getRotateValueZ() {
return this->rotateZ;
}
float Shape::getX() {
return this->x;
}
float Shape::getY() {
return this->y;
}
float Shape::getZ() {
return this->z;
}
void Shape::setPos(float x, float y, float z) {
this->x = x;
this->y = y;
this->z = z;
ViewTranslate = glm::translate(glm::mat4(1.0f), glm::vec3(x, y, z));
setRotateValues(getRotateValueX(), getRotateValueY(), getRotateValueZ());
adjustMatrices();
}
float Shape::getSpeedX() {
return this->speedX;
}
float Shape::getSpeedY() {
return this->speedY;
}
float Shape::getSpeedZ() {
return this->speedZ;
}
void Shape::setSpeed(float x, float y, float z) {
this->speedX = x;
this->speedY = y;
this->speedZ = z;
}
float Shape::getRotateSpeedValueX() {
return this->rotateSpeedX;
}
float Shape::getRotateSpeedValueY() {
return this->rotateSpeedY;
}
float Shape::getRotateSpeedValueZ() {
return this->rotateSpeedZ;
}
void Shape::setRotateSpeed(float x, float y, float z) {
this->rotateSpeedX = x;
this->rotateSpeedY = y;
this->rotateSpeedZ = z;
}
void Shape::adjustMatrices() {
// View = glm::rotate(ViewRotateZ, 20.0f, glm::vec3(0.0f, 1.0f, 0.0f));
View = ViewRotateZ;
Model = glm::mat4(1.0f);
MVP = View * Model;
this->mvp_changed = true;
}