#pragma once class Dataset { public: Dataset() {} ~Dataset() {} std::vector vertices; std::vector normals; std::vector colors; void clear() { vertices.clear(); normals.clear(); } void simpleCube() { vertices = { { -1.0, -1.0, 1.0}, { 1.0, -1.0, 1.0}, { 1.0, 1.0, 1.0}, { 1.0, 1.0, 1.0}, { -1.0, 1.0, 1.0}, { -1.0, -1.0, 1.0}, { 1.0, -1.0, 1.0}, { 1.0, -1.0, -1.0}, { 1.0, 1.0, -1.0}, { 1.0, 1.0, -1.0}, { 1.0, 1.0, 1.0}, { 1.0, -1.0, 1.0}, { -1.0, 1.0, -1.0}, { 1.0, 1.0, -1.0}, { 1.0, -1.0, -1.0}, { 1.0, -1.0, -1.0}, { -1.0, -1.0, -1.0}, { -1.0, 1.0, -1.0}, { -1.0, -1.0, -1.0}, { -1.0, -1.0, 1.0}, { -1.0, 1.0, 1.0}, { -1.0, 1.0, 1.0}, { -1.0, 1.0, -1.0}, { -1.0, -1.0, -1.0}, { -1.0, -1.0, -1.0}, { 1.0, -1.0, -1.0}, { 1.0, -1.0, 1.0}, { 1.0, -1.0, 1.0}, { -1.0, -1.0, 1.0}, { -1.0, -1.0, -1.0}, { -1.0, 1.0, 1.0}, { 1.0, 1.0, 1.0}, { 1.0, 1.0, -1.0}, { 1.0, 1.0, -1.0}, { -1.0, 1.0, -1.0}, { -1.0, 1.0, 1.0} }; colors = { {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, 1.0}, {0.0, 1.0, 0.0}, {1.0, 1.0, 1.0}, {0.0, 0.0, 1.0}, {0.0, 1.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 1.0}, {1.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 1.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, 1.0, 1.0} }, genNormals(); } void simpleFloor() { vertices = {{-10.0, 0.0, -10.0}, {-10.0, 0.0, 10.0}, {10.0, 0.0, -10.0}, {10.0, 0.0, 10.0}, {10.0, 0.0, -10.0}, {-10.0, 0.0, 10.0}}; colors = { {0.7, 0.7, 0.7}, {0.7, 0.7, 0.7}, {0.7, 0.7, 0.7}, {0.7, 0.7, 0.7}, {0.7, 0.7, 0.7}, {0.7, 0.7, 0.7} }; genNormals(); } void checkeredFloor(float size, int squares, glm::vec3 light_color, glm::vec3 dark_color) { float maxX = size / 2.f, maxY = size / 2.f; float minX = -size / 2.f, minY = -size / 2.f; float side_size = size / (float)squares; int color = 1; for (float x = minX; x < maxX; x += side_size) { for (float y = minY; y < maxY; y += side_size) { color *= -1; glm::vec3 tile_color = (color > 0) ? light_color : dark_color; //gen 1 carré vertices.emplace_back(x, 0, y); //upleft vertices.emplace_back(x, 0, y + side_size); //downleft vertices.emplace_back(x + side_size, 0, y + side_size); //downright vertices.emplace_back(x + side_size, 0, y + side_size); //downright vertices.emplace_back(x + side_size, 0, y); //upright vertices.emplace_back(x, 0, y); //upleft for (int z = 0; z < 6; z++) colors.push_back(tile_color); } color *= -1; } genNormals(); } private: void genNormals() { for (unsigned int i = 0; i < vertices.size() - 2; i += 3) { glm::vec3 norm = glm::cross(vertices[i + 1] - vertices[i], vertices[i + 2] - vertices[i]); normals.push_back(norm); normals.push_back(norm); normals.push_back(norm); } } };