Skip to main content

Cube.ixx File

Unit-cube mesh asset with positions, normals, UVs, and indexed triangles. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine
namespacerendering
namespacemesh
namespaceassets

Classes Index

structCube

Static cube mesh definition with per-face vertices. More...

Description

Unit-cube mesh asset with positions, normals, UVs, and indexed triangles.

File Listing

The file content with the documentation metadata removed is:

1
5module;
6
7#include <span>
8#include <array>
9
10export module helios.engine.rendering.mesh.assets:Cube;
11
12import helios.engine.rendering.common.types.Vertex;
13import helios.engine.rendering.mesh.types.PrimitiveType;
14import helios.engine.rendering.mesh.types.MeshData;
15
19
27 struct Cube {
28
32 static constexpr std::array<Vertex, 24> vertices{{
33 // n (z = 1.0)
34 {{-1.0f, -1.0f, 1.0f}, { 0.0f, 0.0f, 1.0f}, {0.0f, 0.0f}}, // Bottom-left
35 {{ 1.0f, -1.0f, 1.0f}, { 0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}}, // Bottom-right
36 {{ 1.0f, 1.0f, 1.0f}, { 0.0f, 0.0f, 1.0f}, {1.0f, 1.0f}}, // Top-right
37 {{-1.0f, 1.0f, 1.0f}, { 0.0f, 0.0f, 1.0f}, {0.0f, 1.0f}}, // Top-left
38
39 // f (z = -1.0)
40 {{-1.0f, -1.0f, -1.0f}, { 0.0f, 0.0f, -1.0f}, {1.0f, 0.0f}}, // Bottom-left
41 {{ 1.0f, -1.0f, -1.0f}, { 0.0f, 0.0f, -1.0f}, {0.0f, 0.0f}}, // Bottom-right
42 {{ 1.0f, 1.0f, -1.0f}, { 0.0f, 0.0f, -1.0f}, {0.0f, 1.0f}}, // Top-right
43 {{-1.0f, 1.0f, -1.0f}, { 0.0f, 0.0f, -1.0f}, {1.0f, 1.0f}}, // Top-left
44
45 // l (x = -1.0)
46 {{-1.0f, -1.0f, -1.0f}, {-1.0f, 0.0f, 0.0f}, {0.0f, 0.0f}}, // Bottom-left
47 {{-1.0f, -1.0f, 1.0f}, {-1.0f, 0.0f, 0.0f}, {1.0f, 0.0f}}, // Bottom-right
48 {{-1.0f, 1.0f, 1.0f}, {-1.0f, 0.0f, 0.0f}, {1.0f, 1.0f}}, // Top-right
49 {{-1.0f, 1.0f, -1.0f}, {-1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}}, // Top-left
50
51 // r (x = 1.0)
52 {{ 1.0f, -1.0f, -1.0f}, { 1.0f, 0.0f, 0.0f}, {1.0f, 0.0f}}, // Bottom-left
53 {{ 1.0f, -1.0f, 1.0f}, { 1.0f, 0.0f, 0.0f}, {0.0f, 0.0f}}, // Bottom-right
54 {{ 1.0f, 1.0f, 1.0f}, { 1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}}, // Top-right
55 {{ 1.0f, 1.0f, -1.0f}, { 1.0f, 0.0f, 0.0f}, {1.0f, 1.0f}}, // Top-left
56
57 // b (y = -1.0)
58 {{-1.0f, -1.0f, -1.0f}, { 0.0f, -1.0f, 0.0f}, {0.0f, 1.0f}}, // Bottom-left
59 {{ 1.0f, -1.0f, -1.0f}, { 0.0f, -1.0f, 0.0f}, {1.0f, 1.0f}}, // Bottom-right
60 {{ 1.0f, -1.0f, 1.0f}, { 0.0f, -1.0f, 0.0f}, {1.0f, 0.0f}}, // Top-right
61 {{-1.0f, -1.0f, 1.0f}, { 0.0f, -1.0f, 0.0f}, {0.0f, 0.0f}}, // Top-left
62
63 // t (y = 1.0)
64 {{-1.0f, 1.0f, -1.0f}, { 0.0f, 1.0f, 0.0f}, {0.0f, 0.0f}}, // Bottom-left
65 {{ 1.0f, 1.0f, -1.0f}, { 0.0f, 1.0f, 0.0f}, {1.0f, 0.0f}}, // Bottom-right
66 {{ 1.0f, 1.0f, 1.0f}, { 0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}}, // Top-right
67 {{-1.0f, 1.0f, 1.0f}, { 0.0f, 1.0f, 0.0f}, {0.0f, 1.0f}} // Top-left
68 }};
69
70
74 static constexpr std::array<unsigned int, 36> indices = {
75 // n
76 0, 1, 2, 2, 3, 0,
77 // f
78 4, 5, 6, 6, 7, 4,
79 // l
80 8, 9, 10, 10, 11, 8,
81 // r
82 12, 13, 14, 14, 15, 12,
83 // b
84 16, 17, 18, 18, 19, 16,
85 // t
86 20, 21, 22, 22, 23, 20
87 };
88
93
99 static MeshData meshData() {
100 return MeshData{
101 std::span{vertices},
102 std::span{indices},
104 };
105
106 };
107
108 };
109
110}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.