From 80249361e3293f431ce6de4a74a420e4ff74ccfd Mon Sep 17 00:00:00 2001 From: David Allemang Date: Sun, 15 Sep 2019 20:03:14 -0400 Subject: [PATCH] correct orientation --- cosets/src/main.cpp | 21 +++++++++------------ cosets/src/util/mesh.hpp | 14 +++++++------- cosets/src/util/window.hpp | 2 +- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/cosets/src/main.cpp b/cosets/src/main.cpp index a9c6d5d..37e45ee 100644 --- a/cosets/src/main.cpp +++ b/cosets/src/main.cpp @@ -45,8 +45,8 @@ public: u_color = glGetUniformLocation(program, "color"); const int N = 3; - const Mults &mults = schlafli({4, 3}); - vert_data = vertices(mults, {1, 1, 1}); + const Mults &mults = schlafli({5, 3}); + vert_data = vertices(mults, {10, 1, 1}); edge_data = edges(mults); face_data = faces(mults); @@ -89,9 +89,9 @@ public: std::cout << "verts: " << vert_data.size() << std::endl; std::cout << "vendor: " << glGetString(GL_VENDOR) << std::endl - << "renderer: " << glGetString(GL_RENDERER) << std::endl - << "version: " << glGetString(GL_VERSION) << std::endl - << "shading version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl; + << "renderer: " << glGetString(GL_RENDERER) << std::endl + << "version: " << glGetString(GL_VERSION) << std::endl + << "shading version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl; } void render() override { @@ -104,7 +104,7 @@ public: const auto ax_1 = glm::vec3(0, 0, 1); const auto ax_2 = glm::vec3(.5, 1, 0.2); const auto t = glfwGetTime(); - const auto angle = (float) t / 2; + const auto angle = (float) t / 5; const float sc = 1.5f; const float ar = (float) w / (float) h; @@ -123,8 +123,8 @@ public: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glPointSize(6.0f); - glLineWidth(3.0f); + glPointSize(10.0f); + glLineWidth(5.0f); glBindVertexArray(vert_vao); glUniform4f(u_color, 1, 0, 0, 1); @@ -136,10 +136,7 @@ public: glBindVertexArray(face_vao); glCullFace(GL_BACK); - glUniform4f(u_color, .3, .3, .3, 1); - glDrawElements(GL_TRIANGLES, face_data.size(), GL_UNSIGNED_INT, 0); - glCullFace(GL_FRONT); - glUniform4f(u_color, .8, .8, .8, 1); + glUniform4f(u_color, 1, 1, 1, 1); glDrawElements(GL_TRIANGLES, face_data.size(), GL_UNSIGNED_INT, 0); swapbuffers(); diff --git a/cosets/src/util/mesh.hpp b/cosets/src/util/mesh.hpp index e5d0d39..f534ce9 100644 --- a/cosets/src/util/mesh.hpp +++ b/cosets/src/util/mesh.hpp @@ -70,15 +70,11 @@ std::vector faces(const Mults &mults) { Table *t_vert = solve({}, mults); - // todo: try the combinations individually and try to find the pattern. - // for each *kind* of face -// std::vector sg_face{0,1}; for (const auto &sg_face : combinations(N, 2)) { Table *cs_face = solve(sg_face, mults); // for each *kind* of edge -// std::vector sg_edge{1}; for (const auto &sg_edge : combinations(sg_face, 1)) { Table *cs_edge = solve(sg_face, sg_edge, mults); @@ -99,10 +95,14 @@ std::vector faces(const Mults &mults) { } res.push_back(t_vert->apply(0, c_face)); - int s = c_edge.size() + sg_edge[0]; - int t = c_face.size() + sg_face[0] + sg_face[1]; + if (c_edge.size() & 1u) + std::swap(res[res.size() - 1], res[res.size() - 2]); - if (s % 2 == 0 xor t % 2 == 0) { + unsigned ro_si1 = (sg_face[0] + sg_face[1]); + unsigned flag = sg_edge[0] == sg_face[0]; + unsigned n_mirrors = c_face.size(); + + if ((n_mirrors + flag + ro_si1) & 1u) { std::swap(res[res.size() - 1], res[res.size() - 2]); } } diff --git a/cosets/src/util/window.hpp b/cosets/src/util/window.hpp index 49dc274..2fb9634 100644 --- a/cosets/src/util/window.hpp +++ b/cosets/src/util/window.hpp @@ -34,7 +34,7 @@ public: glfwWindowHint(GLFW_ALPHA_BITS, 8); - _window = glfwCreateWindow(640, 480, "GLFW App", nullptr, nullptr); + _window = glfwCreateWindow(1920, 1080, "GLFW App", nullptr, nullptr); if (!_window) { fprintf(stderr, "Failed to create window;"); glfwTerminate();