From cee667d1b3be5484e280b6ee64b5cd4c315fa532 Mon Sep 17 00:00:00 2001 From: allem Date: Tue, 7 Jan 2020 19:47:41 -0500 Subject: [PATCH] decomposing "build" into reusable steps. raise is still broken. --- vis/src/main.cpp | 97 ++++++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/vis/src/main.cpp b/vis/src/main.cpp index 531dd6b..32dccd9 100644 --- a/vis/src/main.cpp +++ b/vis/src/main.cpp @@ -53,20 +53,17 @@ tc::Group shrink(const tc::Group &g, const std::array &sub) { } template -std::vector raise( - const tc::Cosets &cosets, - const std::vector &path, - const std::array &gen_map +std::vector raise( + const tc::Cosets &g_res, + const tc::Cosets &h_res, + const std::array &gen_map, + const std::vector &path ) { - std::vector res(path.size(), {0, 0, 0}); + std::vector res(path.size(), 0); for (size_t i = 1; i < path.size(); ++i) { - auto action = path[i]; + auto action = h_res.path[path[i]]; - auto coset = res[action.coset].target; - auto gen = gen_map[action.gen]; - auto target = cosets.get(coset, gen); - - res[i] = {coset, gen, target}; + res[i] = g_res.get(res[action.coset], gen_map[action.gen]); } return res; } @@ -97,9 +94,8 @@ std::vector build(const tc::Group &g, const std::array &sub) { auto hres = tc::solve(h); // recursion would happen here auto gres = tc::solve(g); - auto path = raise(gres, hres.path, sub); - - const std::vector &geom = targets(path); + std::vector geom = targets(hres.path); + geom = raise(gres, hres, sub, geom); return tile(gres, geom); } @@ -133,7 +129,7 @@ int main(int argc, char *argv[]) { << " OpenGL version: " << glGetString(GL_VERSION) << std::endl << " Shading version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl; - auto group = tc::group::H(4); + auto group = tc::group::B(2); auto res = tc::solve(group); auto mirrors = mirror(group); auto corners = plane_intersections(mirrors); @@ -145,10 +141,22 @@ int main(int argc, char *argv[]) { points[i] = reflect(points[action.coset], mirrors[action.gen]); } - auto g0 = build<2>(group, {0}); - auto g1 = build<2>(group, {1}); - auto g2 = build<2>(group, {2}); - auto g3 = build<2>(group, {3}); + auto h = shrink<2>(group, {0, 1}); + auto i = shrink<1>(h, {0}); + + auto g_map = res; + auto h_map = tc::solve(h); + auto i_map = tc::solve(i); + + auto g0 = targets(i_map.path); + g0 = raise<1>(h_map, i_map, {0}, g0); + g0 = tile(h_map, g0); + g0 = raise<2>(g_map, h_map, {0, 1}, g0); + +// auto g0 = build<2>(group, {0}); +// auto g1 = build<2>(group, {1}); +// auto g2 = build<2>(group, {2}); +// auto g3 = build<2>(group, {3}); GLuint vs = glCreateShader(GL_VERTEX_SHADER); utilShaderSource(vs, { @@ -164,6 +172,7 @@ int main(int argc, char *argv[]) { "void main() {" " int i = gl_VertexID;" " vpos = view * pos;" + // " gl_Position = proj * vec4(vpos.xyz / (1), 1);" " gl_Position = proj * vec4(vpos.xyz / (1 - vpos.w), 1);" " gl_PointSize = 5;" "}" @@ -223,20 +232,20 @@ int main(int argc, char *argv[]) { glBindBuffer(GL_ARRAY_BUFFER, ibo0); glBufferData(GL_ARRAY_BUFFER, sizeof(int) * g0.size(), &g0[0], GL_STATIC_DRAW); - GLuint ibo1; - glGenBuffers(1, &ibo1); - glBindBuffer(GL_ARRAY_BUFFER, ibo1); - glBufferData(GL_ARRAY_BUFFER, sizeof(int) * g1.size(), &g1[0], GL_STATIC_DRAW); - - GLuint ibo2; - glGenBuffers(1, &ibo2); - glBindBuffer(GL_ARRAY_BUFFER, ibo2); - glBufferData(GL_ARRAY_BUFFER, sizeof(int) * g2.size(), &g2[0], GL_STATIC_DRAW); - - GLuint ibo3; - glGenBuffers(1, &ibo3); - glBindBuffer(GL_ARRAY_BUFFER, ibo3); - glBufferData(GL_ARRAY_BUFFER, sizeof(int) * g3.size(), &g3[0], GL_STATIC_DRAW); +// GLuint ibo1; +// glGenBuffers(1, &ibo1); +// glBindBuffer(GL_ARRAY_BUFFER, ibo1); +// glBufferData(GL_ARRAY_BUFFER, sizeof(int) * g1.size(), &g1[0], GL_STATIC_DRAW); +// +// GLuint ibo2; +// glGenBuffers(1, &ibo2); +// glBindBuffer(GL_ARRAY_BUFFER, ibo2); +// glBufferData(GL_ARRAY_BUFFER, sizeof(int) * g2.size(), &g2[0], GL_STATIC_DRAW); +// +// GLuint ibo3; +// glGenBuffers(1, &ibo3); +// glBindBuffer(GL_ARRAY_BUFFER, ibo3); +// glBufferData(GL_ARRAY_BUFFER, sizeof(int) * g3.size(), &g3[0], GL_STATIC_DRAW); while (!glfwWindowShouldClose(window)) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -270,17 +279,17 @@ int main(int argc, char *argv[]) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo0); glDrawElements(GL_LINES, g0.size(), GL_UNSIGNED_INT, nullptr); - glUniform3f(2, 0.0f, 1.0f, 0.0f); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo1); - glDrawElements(GL_LINES, g1.size(), GL_UNSIGNED_INT, nullptr); - - glUniform3f(2, 0.0f, 0.0f, 1.0f); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo2); - glDrawElements(GL_LINES, g2.size(), GL_UNSIGNED_INT, nullptr); - - glUniform3f(2, 0.5f, 0.5f, 0.0f); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo3); - glDrawElements(GL_LINES, g3.size(), GL_UNSIGNED_INT, nullptr); +// glUniform3f(2, 0.0f, 1.0f, 0.0f); +// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo1); +// glDrawElements(GL_LINES, g1.size(), GL_UNSIGNED_INT, nullptr); +// +// glUniform3f(2, 0.0f, 0.0f, 1.0f); +// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo2); +// glDrawElements(GL_LINES, g2.size(), GL_UNSIGNED_INT, nullptr); +// +// glUniform3f(2, 0.7f, 0.7f, 0.0f); +// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo3); +// glDrawElements(GL_LINES, g3.size(), GL_UNSIGNED_INT, nullptr); glfwSwapBuffers(window);