-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcube_data.h
More file actions
68 lines (58 loc) · 2.85 KB
/
Copy pathcube_data.h
File metadata and controls
68 lines (58 loc) · 2.85 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
#pragma once
#include <vector>
#include <glm/glm.hpp>
struct Vertex {
glm::vec3 position; // Позиция вершины (x, y, z)
glm::vec3 normal; // Нормаль к поверхности (nx, ny, nz)
glm::vec2 texCoord; // Текстурные координаты (u, v)
};
class Cube {
public:
static std::vector<Vertex> getVertices() {
return {
// Передняя грань
{{-0.5f, -0.5f, 0.5f}, { 0.0f, 0.0f, 1.0f}, {0.0f, 0.0f}},
{{ 0.5f, -0.5f, 0.5f}, { 0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
{{ 0.5f, 0.5f, 0.5f}, { 0.0f, 0.0f, 1.0f}, {1.0f, 1.0f}},
{{-0.5f, 0.5f, 0.5f}, { 0.0f, 0.0f, 1.0f}, {0.0f, 1.0f}},
// Задняя грань
{{-0.5f, -0.5f, -0.5f}, { 0.0f, 0.0f, -1.0f}, {0.0f, 0.0f}},
{{-0.5f, 0.5f, -0.5f}, { 0.0f, 0.0f, -1.0f}, {1.0f, 1.0f}},
{{ 0.5f, 0.5f, -0.5f}, { 0.0f, 0.0f, -1.0f}, {0.0f, 1.0f}},
{{ 0.5f, -0.5f, -0.5f}, { 0.0f, 0.0f, -1.0f}, {1.0f, 0.0f}},
// Левая грань
{{-0.5f, -0.5f, -0.5f}, {-1.0f, 0.0f, 0.0f}, {0.0f, 0.0f}},
{{-0.5f, -0.5f, 0.5f}, {-1.0f, 0.0f, 0.0f}, {1.0f, 0.0f}},
{{-0.5f, 0.5f, 0.5f}, {-1.0f, 0.0f, 0.0f}, {1.0f, 1.0f}},
{{-0.5f, 0.5f, -0.5f}, {-1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}},
// Правая грань
{{ 0.5f, -0.5f, -0.5f}, { 1.0f, 0.0f, 0.0f}, {0.0f, 0.0f}},
{{ 0.5f, 0.5f, -0.5f}, { 1.0f, 0.0f, 0.0f}, {1.0f, 1.0f}},
{{ 0.5f, 0.5f, 0.5f}, { 1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}},
{{ 0.5f, -0.5f, 0.5f}, { 1.0f, 0.0f, 0.0f}, {1.0f, 0.0f}},
// Нижняя грань
{{-0.5f, -0.5f, -0.5f}, { 0.0f, -1.0f, 0.0f}, {0.0f, 0.0f}},
{{ 0.5f, -0.5f, -0.5f}, { 0.0f, -1.0f, 0.0f}, {1.0f, 0.0f}},
{{ 0.5f, -0.5f, 0.5f}, { 0.0f, -1.0f, 0.0f}, {1.0f, 1.0f}},
{{-0.5f, -0.5f, 0.5f}, { 0.0f, -1.0f, 0.0f}, {0.0f, 1.0f}},
// Верхняя грань
{{-0.5f, 0.5f, -0.5f}, { 0.0f, 1.0f, 0.0f}, {0.0f, 0.0f}},
{{-0.5f, 0.5f, 0.5f}, { 0.0f, 1.0f, 0.0f}, {1.0f, 0.0f}},
{{ 0.5f, 0.5f, 0.5f}, { 0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},
{{ 0.5f, 0.5f, -0.5f}, { 0.0f, 1.0f, 0.0f}, {0.0f, 1.0f}}
};
}
static std::vector<unsigned int> getIndices() {
std::vector<unsigned int> indices;
// Каждая грань состоит из 2 треугольников
for (unsigned int i = 0; i < 24; i += 4) {
indices.push_back(i + 0);
indices.push_back(i + 1);
indices.push_back(i + 2);
indices.push_back(i + 0);
indices.push_back(i + 2);
indices.push_back(i + 3);
}
return indices;
}
};