mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
support multiple slices
This commit is contained in:
@@ -46,20 +46,20 @@ public:
|
|||||||
cgl::Buffer<vec4> vbo;
|
cgl::Buffer<vec4> vbo;
|
||||||
cgl::VertexArray vao;
|
cgl::VertexArray vao;
|
||||||
|
|
||||||
|
vec5 root = vec5::Ones().normalized();
|
||||||
|
mat5 transform = mat5::Identity();
|
||||||
|
|
||||||
|
vec3 color = vec3::Ones();
|
||||||
|
|
||||||
explicit Slice(const tc::Group &g) : group(g) {
|
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<N>::hull(group, ctx, selected_ctxs);
|
|
||||||
ibo.put(mesh);
|
|
||||||
|
|
||||||
vao.ipointer(0, ibo, 4, GL_UNSIGNED_INT);
|
vao.ipointer(0, ibo, 4, GL_UNSIGNED_INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPoints(const vec5 &root, const mat5 &transform = mat5::Identity()) {
|
void setMesh(const Mesh<N> &mesh) {
|
||||||
|
ibo.put(mesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPoints() {
|
||||||
auto cosets = group.solve();
|
auto cosets = group.solve();
|
||||||
auto mirrors = mirror<5>(group);
|
auto mirrors = mirror<5>(group);
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ public:
|
|||||||
void draw(const Slice<N> &prop) const {
|
void draw(const Slice<N> &prop) const {
|
||||||
glBindProgramPipeline(pipe);
|
glBindProgramPipeline(pipe);
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, prop.vbo);
|
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);
|
glBindVertexArray(prop.vao);
|
||||||
glDrawArrays(GL_POINTS, 0, prop.ibo.count() * N);
|
glDrawArrays(GL_POINTS, 0, prop.ibo.count() * N);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,13 +29,10 @@ mat5 wander(float time) {
|
|||||||
|
|
||||||
class ExampleApplication : public nanogui::Screen {
|
class ExampleApplication : public nanogui::Screen {
|
||||||
public:
|
public:
|
||||||
vec5 root;
|
|
||||||
|
|
||||||
// std::unique_ptr<tc::Group> group;
|
|
||||||
std::unique_ptr<SliceRenderer<4>> ren;
|
std::unique_ptr<SliceRenderer<4>> ren;
|
||||||
std::unique_ptr<cgl::Buffer<Matrices>> ubo;
|
std::unique_ptr<cgl::Buffer<Matrices>> ubo;
|
||||||
|
|
||||||
std::unique_ptr<Slice<4>> slice;
|
std::vector<Slice<4>> slices;
|
||||||
|
|
||||||
float glfw_time = 0;
|
float glfw_time = 0;
|
||||||
float last_frame = 0;
|
float last_frame = 0;
|
||||||
@@ -66,12 +63,41 @@ public:
|
|||||||
|
|
||||||
std::cout << utilInfo();
|
std::cout << utilInfo();
|
||||||
|
|
||||||
|
{
|
||||||
std::vector<int> symbol = {3, 4, 3, 2};
|
std::vector<int> symbol = {3, 4, 3, 2};
|
||||||
root << .80, .02, .02, .02, .02;
|
|
||||||
|
|
||||||
auto group = tc::schlafli(symbol);
|
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 << .80, .02, .02, .02, .02;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::vector<int> 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<Slice<4>>(group);
|
|
||||||
ren = std::make_unique<SliceRenderer<4>>();
|
ren = std::make_unique<SliceRenderer<4>>();
|
||||||
|
|
||||||
ubo = std::make_unique<cgl::Buffer<Matrices>>();
|
ubo = std::make_unique<cgl::Buffer<Matrices>>();
|
||||||
@@ -94,12 +120,17 @@ public:
|
|||||||
if (!paused) time += frame_time;
|
if (!paused) time += frame_time;
|
||||||
|
|
||||||
auto rotation = wander(time);
|
auto rotation = wander(time);
|
||||||
slice->setPoints(root, rotation);
|
for (auto &slice : slices) {
|
||||||
|
slice.transform = rotation;
|
||||||
|
slice.setPoints();
|
||||||
|
}
|
||||||
|
|
||||||
Matrices mats = Matrices::build(*this);
|
Matrices mats = Matrices::build(*this);
|
||||||
glBindBufferBase(GL_UNIFORM_BUFFER, 1, *ubo);
|
glBindBufferBase(GL_UNIFORM_BUFFER, 1, *ubo);
|
||||||
ubo->put(mats);
|
ubo->put(mats);
|
||||||
ren->draw(*slice);
|
for (const auto &slice : slices) {
|
||||||
|
ren->draw(slice);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user