// Copyright (c) 2023 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #include "CubeMesh.hpp" using namespace Dawn; void Dawn::CubeMesh::buffer( const std::shared_ptr mesh, const glm::vec3 pos, const glm::vec3 size, const int32_t verticeStart, const int32_t indiceStart ) { glm::vec3 positions[CUBE_VERTICE_COUNT] = { pos, glm::vec3(pos.x+size.x, pos.y, pos.z), glm::vec3(pos.x, pos.y+size.y, pos.z), glm::vec3(pos.x+size.x, pos.y+size.y, pos.z), glm::vec3(pos.x, pos.y, pos.z+size.z), glm::vec3(pos.x+size.x, pos.y, pos.z+size.z), glm::vec3(pos.x, pos.y+size.y, pos.z+size.z), pos + size }; glm::vec2 coordinates[CUBE_VERTICE_COUNT] = { glm::vec2(0, 0), glm::vec2(1, 0), glm::vec2(0, 1), glm::vec2(1, 1), glm::vec2(0, 0), glm::vec2(1, 0), glm::vec2(0, 1), glm::vec2(1, 1) }; int32_t indices[CUBE_INDICE_COUNT] = { // Back verticeStart, verticeStart + 1, verticeStart + 3, verticeStart, verticeStart + 2, verticeStart + 3, // Right verticeStart + 1, verticeStart + 5, verticeStart + 7, verticeStart + 1, verticeStart + 3, verticeStart + 7, // Left verticeStart + 4, verticeStart, verticeStart + 2, verticeStart + 4, verticeStart + 6, verticeStart + 2, // Front verticeStart + 5, verticeStart + 4, verticeStart + 6, verticeStart + 5, verticeStart + 7, verticeStart + 6, // Top verticeStart + 7, verticeStart + 2, verticeStart + 6, verticeStart + 7, verticeStart + 3, verticeStart + 2, // Bottom verticeStart + 1, verticeStart, verticeStart + 4, verticeStart + 1, verticeStart + 4, verticeStart + 5 }; mesh->bufferPositions(verticeStart, positions, CUBE_VERTICE_COUNT); mesh->bufferCoordinates(verticeStart, coordinates, CUBE_VERTICE_COUNT); mesh->bufferIndices(indiceStart, indices, CUBE_INDICE_COUNT); }