21 Cube(
const bool mirror_textures =
false)
23 auto generateTexCoords = [mirror_textures](
const glm::vec2& input) -> glm::vec2
25 return glm::vec2((mirror_textures ? (1.f-input.x) : input.x), input.y);
30 {.position = glm::vec3( 0.5f, 0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 0.0f))},
31 {.position = glm::vec3( 0.5f, -0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 1.0f))},
32 {.position = glm::vec3(-0.5f, -0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 1.0f))},
33 {.position = glm::vec3(-0.5f, -0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 1.0f))},
34 {.position = glm::vec3(-0.5f, 0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 0.0f))},
35 {.position = glm::vec3( 0.5f, 0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 0.0f))},
37 {.position = glm::vec3(-0.5f, -0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 1.0f))},
38 {.position = glm::vec3( 0.5f, -0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 1.0f))},
39 {.position = glm::vec3( 0.5f, 0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 0.0f))},
40 {.position = glm::vec3( 0.5f, 0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 0.0f))},
41 {.position = glm::vec3(-0.5f, 0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 0.0f))},
42 {.position = glm::vec3(-0.5f, -0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 1.0f))},
44 {.position = glm::vec3(-0.5f, 0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 0.0f))},
45 {.position = glm::vec3(-0.5f, 0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 0.0f))},
46 {.position = glm::vec3(-0.5f, -0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 1.0f))},
47 {.position = glm::vec3(-0.5f, -0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 1.0f))},
48 {.position = glm::vec3(-0.5f, -0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 1.0f))},
49 {.position = glm::vec3(-0.5f, 0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 0.0f))},
51 {.position = glm::vec3( 0.5f, -0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 1.0f))},
52 {.position = glm::vec3( 0.5f, 0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 0.0f))},
53 {.position = glm::vec3( 0.5f, 0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 0.0f))},
54 {.position = glm::vec3( 0.5f, 0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 0.0f))},
55 {.position = glm::vec3( 0.5f, -0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 1.0f))},
56 {.position = glm::vec3( 0.5f, -0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 1.0f))},
58 {.position = glm::vec3(-0.5f, -0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 1.0f))},
59 {.position = glm::vec3( 0.5f, -0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 0.0f))},
60 {.position = glm::vec3( 0.5f, -0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 0.0f))},
61 {.position = glm::vec3( 0.5f, -0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 0.0f))},
62 {.position = glm::vec3(-0.5f, -0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 1.0f))},
63 {.position = glm::vec3(-0.5f, -0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 1.0f))},
65 {.position = glm::vec3( 0.5f, 0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 1.0f))},
66 {.position = glm::vec3( 0.5f, 0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 1.0f))},
67 {.position = glm::vec3(-0.5f, 0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 0.0f))},
68 {.position = glm::vec3(-0.5f, 0.5f, -0.5f), .tex_coords = generateTexCoords(glm::vec2(1.0f, 0.0f))},
69 {.position = glm::vec3(-0.5f, 0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 0.0f))},
70 {.position = glm::vec3( 0.5f, 0.5f, 0.5f), .tex_coords = generateTexCoords(glm::vec2(0.0f, 1.0f))}
73 std::vector<index_t> indices(_vertices.size());
74 std::iota(indices.begin(), indices.end(), 0);
76 _indices.push_back(indices);
78 _aabb = {glm::vec3(-0.5f), glm::vec3(0.5f)};