diff --git a/vis/include/rendering.hpp b/vis/include/rendering.hpp index e64c15c..ae86264 100644 --- a/vis/include/rendering.hpp +++ b/vis/include/rendering.hpp @@ -46,20 +46,20 @@ public: cgl::Buffer vbo; cgl::VertexArray vao; + vec5 root = vec5::Ones().normalized(); + mat5 transform = mat5::Identity(); + + vec3 color = vec3::Ones(); + explicit Slice(const tc::Group &g) : group(g) { - auto ctx = generators(group); - auto all_ctxs = combinations(ctx, N - 1); - auto selected_ctxs = difference(all_ctxs, { - {0, 2, 4}, - }); - - auto mesh = Mesh::hull(group, ctx, selected_ctxs); - ibo.put(mesh); - vao.ipointer(0, ibo, 4, GL_UNSIGNED_INT); } - void setPoints(const vec5 &root, const mat5 &transform = mat5::Identity()) { + void setMesh(const Mesh &mesh) { + ibo.put(mesh); + } + + void setPoints() { auto cosets = group.solve(); auto mirrors = mirror<5>(group); @@ -104,7 +104,7 @@ public: void draw(const Slice &prop) const { glBindProgramPipeline(pipe); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, prop.vbo); - glProgramUniform3f(solid, 2, 1.f, 1.f, 1.f); + glProgramUniform3fv(solid, 2, 1, prop.color.data()); glBindVertexArray(prop.vao); glDrawArrays(GL_POINTS, 0, prop.ibo.count() * N); } diff --git a/vis/src/main.cpp b/vis/src/main.cpp index 052fc1b..fab25bc 100644 --- a/vis/src/main.cpp +++ b/vis/src/main.cpp @@ -29,13 +29,10 @@ mat5 wander(float time) { class ExampleApplication : public nanogui::Screen { public: - vec5 root; - -// std::unique_ptr group; std::unique_ptr> ren; std::unique_ptr> ubo; - std::unique_ptr> slice; + std::vector> slices; float glfw_time = 0; float last_frame = 0; @@ -66,12 +63,41 @@ public: std::cout << utilInfo(); - std::vector symbol = {3, 4, 3, 2}; - root << .80, .02, .02, .02, .02; + { + std::vector symbol = {3, 4, 3, 2}; + auto group = tc::schlafli(symbol); + auto ctx = generators(group); + auto selected_ctxs = difference( + combinations(ctx, 3), + { + {0, 1, 2}, + } + ); + auto mesh = Mesh<4>::hull(group, ctx, selected_ctxs); - auto group = tc::schlafli(symbol); + auto &slice = slices.emplace_back(group); + slice.setMesh(mesh); + slice.root << .80, .02, .02, .02, .02; + } + + { + std::vector symbol = {3, 4, 3, 2}; + auto group = tc::schlafli(symbol); + auto ctx = generators(group); + auto selected_ctxs = difference( + combinations(ctx, 3), + { + {0, 1, 2}, + } + ); + auto mesh = Mesh<4>::hull(group, ctx, selected_ctxs); + + auto &slice = slices.emplace_back(group); + slice.setMesh(mesh); + slice.root << .50, .02, .02, .02, .02; + slice.color << 0.1, 0.1, 0.9; + } - slice = std::make_unique>(group); ren = std::make_unique>(); ubo = std::make_unique>(); @@ -94,12 +120,17 @@ public: if (!paused) time += frame_time; auto rotation = wander(time); - slice->setPoints(root, rotation); + for (auto &slice : slices) { + slice.transform = rotation; + slice.setPoints(); + } Matrices mats = Matrices::build(*this); glBindBufferBase(GL_UNIFORM_BUFFER, 1, *ubo); ubo->put(mats); - ren->draw(*slice); + for (const auto &slice : slices) { + ren->draw(slice); + } } };