-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcube.h
30 lines (27 loc) · 793 Bytes
/
cube.h
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
#include <glm/vec3.hpp>
#include <vector>
class Cube {
public:
glm::vec3 pos;
float dim;
Cube(float x, float y, float z, float _dimention) {
pos = glm::vec3(x, y, z);
dim = _dimention;
};
std::vector<Cube> generate_carpet() {
std::vector<Cube> carpet;
for (int i = -1; i<2; i++) {
for (int j = -1; j<2; j++) {
for (int k = -1; k<2; k++) {
int sum = abs(i) + abs(j) + abs(k);
float newDim = dim / 3;
if (sum > 1) {
Cube cube(pos.x + i * newDim, pos.y + j * newDim, pos.z + k * newDim, newDim);
carpet.push_back(cube);
}
}
}
}
return carpet;
}
};