diff --git a/vis/presets/atlas-24-cell.yaml b/vis/presets/atlas_24_cell.yaml similarity index 94% rename from vis/presets/atlas-24-cell.yaml rename to vis/presets/atlas_24_cell.yaml index 2cc082c..820319a 100644 --- a/vis/presets/atlas-24-cell.yaml +++ b/vis/presets/atlas_24_cell.yaml @@ -1,3 +1,4 @@ +dimension: 4 groups: - symbol: [3, 4, 3, 2] slices: diff --git a/vis/presets/b_3_ortho.yaml b/vis/presets/b_3_ortho.yaml new file mode 100644 index 0000000..ebc1e9e --- /dev/null +++ b/vis/presets/b_3_ortho.yaml @@ -0,0 +1,10 @@ +dimension: 3 +groups: + - symbol: [4, 3] + slices: + - root: [0.90, 0.09, 0.09, 0.09, 0.01] + color: [0.9, 0.9, 0.9] + wires: + - root: [0.90, 0.09, 0.09, 0.09, 0.01] + color: [0.3, 0.3, 0.3] + ortho: true diff --git a/vis/presets/b_3_stereo.yaml b/vis/presets/b_3_stereo.yaml new file mode 100644 index 0000000..83e674f --- /dev/null +++ b/vis/presets/b_3_stereo.yaml @@ -0,0 +1,10 @@ +dimension: 3 +groups: + - symbol: [4, 3] + slices: + - root: [0.90, 0.09, 0.09, 0.09, 0.01] + color: [0.9, 0.9, 0.9] + wires: + - root: [0.90, 0.09, 0.09, 0.09, 0.01] + color: [0.3, 0.3, 0.3] + ortho: false diff --git a/vis/presets/b_4_stereo.yaml b/vis/presets/b_4_stereo.yaml new file mode 100644 index 0000000..df92302 --- /dev/null +++ b/vis/presets/b_4_stereo.yaml @@ -0,0 +1,10 @@ +dimension: 4 +groups: + - symbol: [4, 3, 3] + slices: + - root: [0.90, 0.09, 0.09, 0.09, 0.01] + color: [0.9, 0.9, 0.9] + wires: + - root: [0.90, 0.09, 0.09, 0.09, 0.01] + color: [0.3, 0.3, 0.3] + ortho: false diff --git a/vis/presets/b_4_stereo_exclude.yaml b/vis/presets/b_4_stereo_exclude.yaml new file mode 100644 index 0000000..7273ed0 --- /dev/null +++ b/vis/presets/b_4_stereo_exclude.yaml @@ -0,0 +1,12 @@ +dimension: 4 +groups: + - symbol: [4, 3, 3] + slices: + - root: [0.90, 0.09, 0.09, 0.09, 0.01] + color: [0.9, 0.9, 0.9] + exclude: + - [0, 1, 2] + wires: + - root: [0.90, 0.09, 0.09, 0.09, 0.01] + color: [0.3, 0.3, 0.3] + ortho: false diff --git a/vis/presets/b_4_stereo_exclude_nowire.yaml b/vis/presets/b_4_stereo_exclude_nowire.yaml new file mode 100644 index 0000000..7dc9cab --- /dev/null +++ b/vis/presets/b_4_stereo_exclude_nowire.yaml @@ -0,0 +1,8 @@ +dimension: 4 +groups: + - symbol: [4, 3, 3] + slices: + - root: [0.90, 0.09, 0.09, 0.09, 0.01] + color: [0.9, 0.9, 0.9] + exclude: + - [0, 1, 2] diff --git a/vis/presets/b_4_stereo_exclude_thick.yaml b/vis/presets/b_4_stereo_exclude_thick.yaml new file mode 100644 index 0000000..bbab448 --- /dev/null +++ b/vis/presets/b_4_stereo_exclude_thick.yaml @@ -0,0 +1,8 @@ +dimension: 5 +groups: + - symbol: [4, 3, 3, 2] + slices: + - root: [0.90, 0.09, 0.09, 0.09, 0.09] + color: [0.9, 0.9, 0.9] + exclude: + - [0, 1, 2] diff --git a/vis/presets/default.yaml b/vis/presets/default.yaml index 2cc082c..df92302 100644 --- a/vis/presets/default.yaml +++ b/vis/presets/default.yaml @@ -1,9 +1,10 @@ +dimension: 4 groups: - - symbol: [3, 4, 3, 2] + - symbol: [4, 3, 3] slices: - - root: [0.30, 0.03, 0.03, 0.03, 0.01] - color: [0.9, 0.3, 0.3] - - root: [1.00, 0.10, 0.10, 0.10, 0.02] + - root: [0.90, 0.09, 0.09, 0.09, 0.01] + color: [0.9, 0.9, 0.9] + wires: + - root: [0.90, 0.09, 0.09, 0.09, 0.01] color: [0.3, 0.3, 0.3] - exclude: - - [0, 1, 2] + ortho: false diff --git a/vis/presets/h_4_stereo_exclude_thick.yaml b/vis/presets/h_4_stereo_exclude_thick.yaml new file mode 100644 index 0000000..817745f --- /dev/null +++ b/vis/presets/h_4_stereo_exclude_thick.yaml @@ -0,0 +1,8 @@ +dimension: 5 +groups: + - symbol: [5, 3, 3, 2] + slices: + - root: [0.90, 0.09, 0.09, 0.09, 0.09] + color: [0.9, 0.9, 0.9] + exclude: + - [0, 1, 2] diff --git a/vis/presets/h_4_stereo_wire.yaml b/vis/presets/h_4_stereo_wire.yaml new file mode 100644 index 0000000..cc2c51d --- /dev/null +++ b/vis/presets/h_4_stereo_wire.yaml @@ -0,0 +1,11 @@ +dimension: 5 +groups: + - symbol: [3, 4, 3] + slices: + - root: [0.90, 0.09, 0.09, 0.09, 0.0] + color: [0.9, 0.9, 0.9] + exclude: + - [0, 1, 2] + wires: + - root: [0.90, 0.09, 0.09, 0.09, 0.0] + color: [0.3, 0.3, 0.3] diff --git a/vis/src/main.cpp b/vis/src/main.cpp index 5ddaa7d..64ea975 100644 --- a/vis/src/main.cpp +++ b/vis/src/main.cpp @@ -34,7 +34,16 @@ struct Matrices { } }; -Matrices build(GLFWwindow *window, float st) { +struct State { + float time; + float time_delta; + + float st; + + int dimension; +}; + +Matrices build(GLFWwindow *window, State &state) { int width, height; glfwGetFramebufferSize(window, &width, &height); @@ -43,13 +52,27 @@ Matrices build(GLFWwindow *window, float st) { auto pwidth = aspect * pheight; glm::mat4 proj = glm::ortho(-pwidth, pwidth, -pheight, pheight, -10.0f, 10.0f); + if (!glfwGetKey(window, GLFW_KEY_LEFT_SHIFT)) { + state.st += state.time_delta / 8; + } + auto view = glm::identity(); - view *= utilRotate(0, 1, st * .40f); - view *= utilRotate(0, 2, st * .20f); - view *= utilRotate(0, 3, st * 1.30f); - view *= utilRotate(1, 2, st * .50f); - view *= utilRotate(1, 3, st * .25f); - view *= utilRotate(2, 3, st * 1.42f); + if (state.dimension < 4) { + view *= utilRotate(2, 3, M_PI_2f32); + } + + if (state.dimension > 1) { + view *= utilRotate(0, 1, state.st * .40f); + } + if (state.dimension > 2) { + view *= utilRotate(0, 2, state.st * .20f); + view *= utilRotate(1, 2, state.st * .50f); + } + if (state.dimension > 3) { + view *= utilRotate(0, 3, state.st * 1.30f); + view *= utilRotate(1, 3, state.st * .25f); + view *= utilRotate(2, 3, state.st * 1.42f); + } return Matrices(proj, view); } @@ -149,12 +172,13 @@ struct Slice { struct Wire { bool curve; + bool ortho; vec3 color; cgl::VertexArray vao; cgl::Buffer vbo; cgl::Buffer> ibo; - Wire(bool curve, vec3 color) : curve(curve), color(color), vao(), ibo(), vbo() {} + Wire(bool curve, bool ortho, vec3 color) : curve(curve), ortho(ortho), color(color), vao(), ibo(), vbo() {} Wire(Wire &) = delete; @@ -169,9 +193,9 @@ struct Wire { } template - static Wire build(const tc::Group &g, const C &coords, bool curve, vec3 color, T all_sg_gens, + static Wire build(const tc::Group &g, const C &coords, bool curve, bool ortho, vec3 color, T all_sg_gens, const std::vector> &exclude) { - Wire res(curve, color); + Wire res(curve, ortho, color); res.vbo.put(points(g, coords)); res.ibo.put(merge<2>(hull<2>(g, all_sg_gens, exclude))); @@ -201,6 +225,11 @@ void run(const std::string &config_file, GLFWwindow *window) { auto scene = YAML::LoadFile(config_file); + State state; + glfwSetWindowUserPointer(window, &state); + + state.dimension = scene["dimension"].as(); + auto slices = std::vector>(); auto wires = std::vector(); @@ -239,6 +268,7 @@ void run(const std::string &config_file, GLFWwindow *window) { auto color = wire_info["color"].as(); auto exclude = std::vector>(); auto curve = wire_info["curve"].IsDefined() && wire_info["curve"].as(); + auto ortho = wire_info["ortho"].IsDefined() && wire_info["ortho"].as(); if (wire_info["exclude"].IsDefined()) { exclude = wire_info["exclude"].as>>(); @@ -247,12 +277,12 @@ void run(const std::string &config_file, GLFWwindow *window) { if (wire_info["subgroups"].IsDefined()) { auto subgroups = wire_info["subgroups"].as>>(); wires.push_back(Wire::build( - group, root, curve, color, subgroups, exclude + group, root, curve, ortho, color, subgroups, exclude )); } else { auto combos = Combos(gens, 1); wires.push_back(Wire::build( - group, root, curve, color, combos, exclude + group, root, curve, ortho, color, combos, exclude )); } } @@ -263,37 +293,43 @@ void run(const std::string &config_file, GLFWwindow *window) { glBindBufferBase(GL_UNIFORM_BUFFER, 1, ubo); while (!glfwWindowShouldClose(window)) { + auto time = (float) glfwGetTime(); + state.time_delta = state.time - time; + state.time = time; + int width, height; glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - auto st = (float) glfwGetTime() / 8; - Matrices mats = build(window, st); + Matrices mats = build(window, state); ubo.put(mats); glLineWidth(1.5); - slice_pipe.bound([&]() { - for (const auto &slice : slices) { - glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, slice.vbo); - glProgramUniform3fv(sh.solid, 2, 1, &slice.color.front()); - slice.draw(); - } - }); - wire_pipe.bound([&]() { for (const auto &wire : wires) { if (wire.curve) wire_pipe.stage(sh.curve_stereo); else wire_pipe.unstage(GL_GEOMETRY_SHADER_BIT); + if (wire.ortho) wire_pipe.stage(sh.direct_ortho); + else wire_pipe.stage(sh.direct_stereo); + glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, wire.vbo); glProgramUniform3fv(sh.solid, 2, 1, &wire.color.front()); wire.draw(); } }); + slice_pipe.bound([&]() { + for (const auto &slice : slices) { + glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, slice.vbo); + glProgramUniform3fv(sh.solid, 2, 1, &slice.color.front()); + slice.draw(); + } + }); + glfwSwapInterval(2); glfwSwapBuffers(window);