mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f9f4e568b | ||
|
|
2d6dbc6804 | ||
|
|
a28cc2d8be | ||
| fbd23aea02 | |||
| a3233c2686 | |||
| c1f5163008 | |||
|
|
01043e9bce | ||
|
|
6e3ea1900b | ||
|
|
9ce626ee64 |
2
vendor/toddcox
vendored
2
vendor/toddcox
vendored
Submodule vendor/toddcox updated: 16c9d7d62f...265de59917
@@ -62,11 +62,6 @@ namespace cgl {
|
||||
put(data.data(), data.size(), usage);
|
||||
}
|
||||
|
||||
template<>
|
||||
void put<std::vector<T>>(const std::vector<T> &data, GLenum usage = GL_STATIC_DRAW) {
|
||||
put(data.data, data.size(), usage);
|
||||
}
|
||||
|
||||
void bound(GLenum target, const std::function<void()> &action) const {
|
||||
glBindBuffer(target, id);
|
||||
action();
|
||||
|
||||
53
vis/include/combinations.hpp
Normal file
53
vis/include/combinations.hpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
template<class V>
|
||||
V select(const V &options, const std::vector<bool> &mask, size_t count) {
|
||||
V result;
|
||||
result.reserve(count);
|
||||
|
||||
for (int i = 0; i < mask.size(); ++i) {
|
||||
if (mask[i]) result.push_back(options[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<class V>
|
||||
std::set<V> combinations(const V &options, size_t count) {
|
||||
std::set<V> result;
|
||||
|
||||
std::vector<bool> mask(options.size(), false);
|
||||
std::fill(mask.begin(), mask.begin() + count, true);
|
||||
|
||||
do {
|
||||
result.insert(select(options, mask, count));
|
||||
} while (std::next_permutation(mask.begin(), mask.end(), std::greater<>()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<class V>
|
||||
std::set<V> set_difference(const std::set<V> &a, const std::set<V> &b) {
|
||||
std::set<V> result;
|
||||
std::set_difference(
|
||||
a.begin(), a.end(),
|
||||
b.begin(), b.end(),
|
||||
std::inserter(result, result.end())
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<class V>
|
||||
std::set<V> set_union(const std::set<V> &a, const std::set<V> &b) {
|
||||
std::set<V> result;
|
||||
std::set_union(
|
||||
a.begin(), a.end(),
|
||||
b.begin(), b.end(),
|
||||
std::inserter(result, result.end())
|
||||
);
|
||||
return result;
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <stdexcept>
|
||||
|
||||
size_t choose(size_t n, size_t k) {
|
||||
if (k == 0) return 1;
|
||||
return n * choose(n - 1, k - 1) / k;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
class ComboIterator {
|
||||
private:
|
||||
const std::vector<T> &options;
|
||||
|
||||
std::vector<bool> bits;
|
||||
std::vector<T> curr;
|
||||
int at;
|
||||
|
||||
void set_curr() {
|
||||
for (int i = 0, j = 0; i < bits.size(); ++i) {
|
||||
if (bits[i]) curr[j++] = options[i];
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
ComboIterator(const std::vector<T> &options, int k, int at = 0)
|
||||
: options(options), bits(options.size()), curr(k), at(at) {
|
||||
std::fill(bits.begin(), bits.begin() + k, true);
|
||||
set_curr();
|
||||
}
|
||||
|
||||
[[nodiscard]] bool operator==(const ComboIterator<T> &o) const {
|
||||
return at == o.at;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool operator!=(const ComboIterator<T> &o) const {
|
||||
return at != o.at;
|
||||
}
|
||||
|
||||
auto operator*() const {
|
||||
return curr;
|
||||
}
|
||||
|
||||
const auto &operator->() const {
|
||||
return &this;
|
||||
}
|
||||
|
||||
auto operator++(int) {
|
||||
std::prev_permutation(bits.begin(), bits.end());
|
||||
set_curr();
|
||||
++at;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto operator++() &{
|
||||
auto res = *this;
|
||||
(*this)++;
|
||||
return res;
|
||||
}
|
||||
|
||||
auto operator--(int) {
|
||||
std::next_permutation(bits.begin(), bits.end());
|
||||
set_curr();
|
||||
--at;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto operator--() &{
|
||||
auto res = *this;
|
||||
(*this)--;
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class Combos {
|
||||
private:
|
||||
const std::vector<T> options;
|
||||
int k;
|
||||
int size;
|
||||
|
||||
public:
|
||||
Combos(const std::vector<T> &options, int k)
|
||||
: options(options), k(k), size(choose(options.size(), k)) {
|
||||
}
|
||||
|
||||
ComboIterator<T> begin() const {
|
||||
return ComboIterator<T>(options, k);
|
||||
}
|
||||
|
||||
ComboIterator<T> end() const {
|
||||
return ComboIterator<T>(options, k, size);
|
||||
}
|
||||
};
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <optional>
|
||||
#include <numeric>
|
||||
#include <iostream>
|
||||
#include "combo_iterator.hpp"
|
||||
|
||||
template<unsigned N>
|
||||
using Prims = Eigen::Matrix<unsigned, N, Eigen::Dynamic>;
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#include <cgl/pipeline.hpp>
|
||||
|
||||
#include <geometry.hpp>
|
||||
#include "mirror.hpp"
|
||||
#include <mirror.hpp>
|
||||
#include <combinations.hpp>
|
||||
|
||||
struct Matrices {
|
||||
mat4 proj = mat4::Identity();
|
||||
@@ -45,14 +46,21 @@ public:
|
||||
cgl::Buffer<vec4> vbo;
|
||||
cgl::VertexArray vao;
|
||||
|
||||
template<class T>
|
||||
Slice(const tc::Group &g, T all_sg_gens, const std::vector<std::vector<int>> &exclude) : group(g) {
|
||||
const auto &data = merge<N>(hull<N>(g, all_sg_gens, exclude));
|
||||
ibo.put(data);
|
||||
vec5 root = vec5::Ones().normalized();
|
||||
vec5 center = vec5::Zero();
|
||||
mat5 transform = mat5::Identity();
|
||||
|
||||
vec3 color = vec3::Ones();
|
||||
|
||||
explicit Slice(const tc::Group &g) : group(g) {
|
||||
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 mirrors = mirror<5>(group);
|
||||
|
||||
@@ -63,7 +71,7 @@ public:
|
||||
|
||||
std::transform(
|
||||
higher.begin(), higher.end(), higher.begin(),
|
||||
[&](const vec5& v) { return transform * v; }
|
||||
[&](const vec5& v) { return center + transform * v; }
|
||||
);
|
||||
|
||||
std::vector<vec4> lower(higher.size());
|
||||
@@ -97,7 +105,7 @@ public:
|
||||
void draw(const Slice<N> &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);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <geometry.hpp>
|
||||
#include <utility>
|
||||
|
||||
#include "combo_iterator.hpp"
|
||||
#include <combinations.hpp>
|
||||
|
||||
/**
|
||||
* Produce a list of all generators for the group context. The range [0..group.ngens).
|
||||
@@ -19,10 +20,11 @@ std::vector<int> generators(const tc::Group &context) {
|
||||
return g_gens;
|
||||
}
|
||||
|
||||
/**
|
||||
namespace {
|
||||
/**
|
||||
* Determine which of g_gens are the correct names for sg_gens within the current context
|
||||
*/
|
||||
std::vector<int> recontext_gens(
|
||||
std::vector<int> recontext_gens(
|
||||
const tc::Group &context,
|
||||
std::vector<int> g_gens,
|
||||
std::vector<int> sg_gens) {
|
||||
@@ -42,181 +44,213 @@ std::vector<int> recontext_gens(
|
||||
std::sort(s_sg_gens.begin(), s_sg_gens.end());
|
||||
|
||||
return s_sg_gens;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Solve the cosets generated by sg_gens within the subgroup generated by g_gens of the group context
|
||||
*/
|
||||
tc::Cosets solve(
|
||||
tc::Cosets solve(
|
||||
const tc::Group &context,
|
||||
const std::vector<int> &g_gens,
|
||||
const std::vector<int> &sg_gens
|
||||
) {
|
||||
) {
|
||||
const auto proper_sg_gens = recontext_gens(context, g_gens, sg_gens);
|
||||
return context.subgroup(g_gens).solve(proper_sg_gens);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Apply some context transformation to all primitives of this mesh.
|
||||
*/
|
||||
template<unsigned N>
|
||||
void apply(const tc::Cosets &table, int gen, Prims<N> &mat) {
|
||||
template<unsigned N>
|
||||
void apply(const tc::Cosets &table, int gen, Prims<N> &mat) {
|
||||
auto data = mat.data();
|
||||
for (int i = 0; i < mat.size(); ++i) {
|
||||
data[i] = table.get(data[i], gen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the indexes of this mesh to those of a different context, using g_gens to build the parent context and sg_gens to build this context.
|
||||
*/
|
||||
template<unsigned N>
|
||||
[[nodiscard]]
|
||||
Prims<N> recontext(
|
||||
Prims<N> prims,
|
||||
const tc::Group &context,
|
||||
const std::vector<int> &g_gens,
|
||||
const std::vector<int> &sg_gens
|
||||
) {
|
||||
const auto proper_sg_gens = recontext_gens(context, g_gens, sg_gens);
|
||||
const auto table = solve(context, g_gens, {});
|
||||
const auto path = solve(context, sg_gens, {}).path;
|
||||
class Mesh {
|
||||
public:
|
||||
const tc::Group *g; // todo this needs to be handled more consistently
|
||||
std::vector<int> ctx;
|
||||
Prims<N> prims;
|
||||
|
||||
Mesh(const tc::Group &g_, std::vector<int> ctx_, size_t cols);
|
||||
|
||||
static Mesh<N> fill(const tc::Group &g, const std::vector<int> &ctx);
|
||||
|
||||
// template<class SC>
|
||||
// static Mesh<N> hull(const tc::Group &g, const std::vector<int> &ctx, const SC &sub_ctxs);
|
||||
|
||||
Mesh<N> recontext(std::vector<int> ctx_);
|
||||
|
||||
Mesh<N> tile(const std::vector<int> &ctx_);
|
||||
|
||||
std::vector<Mesh<N>> each_tile(const std::vector<int> &ctx_);
|
||||
|
||||
Mesh<N + 1> fan(unsigned root);
|
||||
|
||||
[[nodiscard]] size_t size() const { return prims.size(); }
|
||||
|
||||
[[nodiscard]] size_t rows() const { return prims.rows(); }
|
||||
|
||||
[[nodiscard]] size_t cols() const { return prims.cols(); }
|
||||
|
||||
[[nodiscard]] unsigned *data() { return prims.data(); }
|
||||
|
||||
[[nodiscard]] const unsigned *data() const { return prims.data(); }
|
||||
};
|
||||
|
||||
template<class M>
|
||||
M merge(const std::vector<M> &meshes) {
|
||||
if (meshes.empty()) throw std::logic_error("cannot merge an empty list of meshes");
|
||||
|
||||
auto g = meshes[0].g;
|
||||
auto ctx = meshes[0].ctx;
|
||||
|
||||
size_t cols = 0;
|
||||
for (const auto &mesh : meshes) {
|
||||
cols += mesh.prims.cols();
|
||||
}
|
||||
|
||||
M res(*g, ctx, cols);
|
||||
|
||||
size_t offset = 0;
|
||||
for (const auto &mesh : meshes) {
|
||||
res.prims.middleCols(offset, mesh.prims.cols()) = mesh.prims;
|
||||
offset += mesh.prims.cols();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
template<unsigned N>
|
||||
Mesh<N> Mesh<N>::recontext(std::vector<int> ctx_) {
|
||||
Mesh<N> res = *this;
|
||||
res.ctx = ctx_;
|
||||
|
||||
const auto proper_sg_gens = recontext_gens(*g, res.ctx, ctx);
|
||||
const auto table = solve(*g, res.ctx, {});
|
||||
const auto path = solve(*g, ctx, {}).path;
|
||||
|
||||
auto map = path.template walk<int, int>(0, proper_sg_gens, [table](int coset, int gen) {
|
||||
return table.get(coset, gen);
|
||||
});
|
||||
|
||||
Prims<N> res(prims);
|
||||
auto data = res.data();
|
||||
for (int i = 0; i < prims.size(); ++i) {
|
||||
auto data = res.prims.data();
|
||||
for (int i = 0; i < res.prims.size(); ++i) {
|
||||
data[i] = map[data[i]];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Union several meshes of the same dimension
|
||||
*/
|
||||
template<unsigned N>
|
||||
Prims<N> merge(const std::vector<Prims<N>> &meshes) {
|
||||
size_t cols = 0;
|
||||
for (const auto &mesh : meshes) {
|
||||
cols += mesh.cols();
|
||||
}
|
||||
|
||||
Prims<N> res(N, cols);
|
||||
|
||||
size_t offset = 0;
|
||||
for (const Prims<N> &mesh : meshes) {
|
||||
res.middleCols(offset, mesh.cols()) = mesh;
|
||||
offset += mesh.cols();
|
||||
}
|
||||
|
||||
return res;
|
||||
Mesh<N> Mesh<N>::tile(const std::vector<int> &ctx_) {
|
||||
return merge(each_tile(ctx_));
|
||||
}
|
||||
|
||||
template<unsigned N>
|
||||
[[nodiscard]]
|
||||
std::vector<Prims<N>> tile(
|
||||
Prims<N> prims,
|
||||
const tc::Group &context,
|
||||
const std::vector<int> &g_gens,
|
||||
const std::vector<int> &sg_gens
|
||||
) {
|
||||
Prims<N> base = recontext<N>(prims, context, g_gens, sg_gens);
|
||||
const auto proper_sg_gens = recontext_gens(context, g_gens, sg_gens);
|
||||
std::vector<Mesh<N>> Mesh<N>::each_tile(const std::vector<int> &ctx_) {
|
||||
auto base = recontext(ctx_);
|
||||
|
||||
const auto table = solve(context, g_gens, {});
|
||||
const auto path = solve(context, g_gens, sg_gens).path;
|
||||
auto table = solve(*g, base.ctx, {});
|
||||
auto path = solve(*g, base.ctx, ctx).path;
|
||||
|
||||
std::vector<int> _gens = generators(context);
|
||||
|
||||
std::vector<Prims<N>> res = path.walk<Prims<N>, int>(
|
||||
base, _gens,
|
||||
[&](Prims<N> from, int gen) {
|
||||
apply<N>(table, gen, from);
|
||||
return from;
|
||||
std::vector<Mesh<N>> res = path.template walk<Mesh<N>, int>(
|
||||
base, generators(*g),
|
||||
[&](Mesh<N> mesh, int gen) {
|
||||
apply<N>(table, gen, mesh.prims);
|
||||
return mesh;
|
||||
}
|
||||
);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce a mesh of higher dimension by fanning a single point to all primitives in this mesh.
|
||||
*/
|
||||
template<unsigned N>
|
||||
[[nodiscard]]
|
||||
Prims<N + 1> fan(Prims<N> prims, int root) {
|
||||
Prims<N + 1> res(N + 1, prims.cols());
|
||||
Mesh<N + 1> Mesh<N>::fan(unsigned root) {
|
||||
Mesh<N + 1> res(*g, ctx, prims.cols());
|
||||
|
||||
res.topRows(1) = Prims<1>::Constant(1, prims.cols(), root);
|
||||
res.bottomRows(N) = prims;
|
||||
res.prims.topRows(1) = Prims<1>::Constant(1, prims.cols(), root);
|
||||
res.prims.bottomRows(N) = prims;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce a mesh of primitives that fill out the volume of the subgroup generated by generators g_gens within the group context
|
||||
*/
|
||||
template<unsigned N>
|
||||
Prims<N> triangulate(
|
||||
const tc::Group &context,
|
||||
const std::vector<int> &g_gens
|
||||
) {
|
||||
if (g_gens.size() + 1 != N) // todo make static assert
|
||||
throw std::logic_error("g_gens size must be one less than N");
|
||||
Mesh<N>::Mesh(const tc::Group &g_, std::vector<int> ctx_, size_t cols)
|
||||
: g(&g_), ctx(std::move(ctx_)) {
|
||||
prims.setZero(N, cols);
|
||||
}
|
||||
|
||||
const auto &combos = Combos(g_gens, g_gens.size() - 1);
|
||||
template<unsigned N>
|
||||
Mesh<N> Mesh<N>::fill(const tc::Group &g, const std::vector<int> &ctx) {
|
||||
if (ctx.size() + 1 != N)
|
||||
throw std::logic_error("ctx size must be one less than N");
|
||||
|
||||
std::vector<Prims<N>> meshes;
|
||||
// const auto &combos = Combos(ctx, (int)ctx.size() - 1);
|
||||
const auto &combos = combinations(ctx, (int) ctx.size() - 1);
|
||||
|
||||
for (const auto &sg_gens : combos) {
|
||||
auto base = triangulate<N - 1>(context, sg_gens);
|
||||
auto parts = tile<N - 1>(base, context, g_gens, sg_gens);
|
||||
std::vector<Mesh<N>> meshes;
|
||||
|
||||
for (const auto &sub_ctx : combos) {
|
||||
auto base = Mesh<N - 1>::fill(g, sub_ctx);
|
||||
auto parts = base.each_tile(ctx);
|
||||
parts.erase(parts.begin(), parts.begin() + 1);
|
||||
auto raised = merge<N - 1>(parts);
|
||||
auto fanned = fan<N - 1>(raised, 0);
|
||||
|
||||
if (parts.empty()) continue;
|
||||
auto raised = merge(parts);
|
||||
|
||||
auto fanned = raised.fan(0);
|
||||
meshes.push_back(fanned);
|
||||
}
|
||||
|
||||
return merge<N>(meshes);
|
||||
return merge(meshes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Single-index primitives should not be further triangulated.
|
||||
*/
|
||||
template<>
|
||||
Prims<1> triangulate<1>(
|
||||
const tc::Group &context,
|
||||
const std::vector<int> &g_gens
|
||||
) {
|
||||
if (not g_gens.empty()) // todo make static assert
|
||||
throw std::logic_error("g_gens must be empty for a trivial Mesh");
|
||||
Mesh<1> Mesh<1>::fill(const tc::Group &g, const std::vector<int> &ctx) {
|
||||
if (not ctx.empty())
|
||||
throw std::logic_error("ctx must be empty for a trivial Mesh.");
|
||||
|
||||
return Prims<1>::Zero(1, 1);
|
||||
return Mesh<1>(g, ctx, 1);
|
||||
}
|
||||
|
||||
template<unsigned N, class T>
|
||||
auto hull(const tc::Group &group, T all_sg_gens, const std::vector<std::vector<int>> &exclude) {
|
||||
std::vector<Prims<N>> parts;
|
||||
auto g_gens = generators(group);
|
||||
for (const std::vector<int> &sg_gens : all_sg_gens) {
|
||||
bool excluded = false;
|
||||
for (const auto &test : exclude) {
|
||||
if (sg_gens == test) {
|
||||
excluded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (excluded) continue;
|
||||
template<unsigned N, class C, class SC>
|
||||
Mesh<N> fill_each_tile_merge(const tc::Group &g, const C &ctx, const SC &sub_ctxs) {
|
||||
std::vector<Mesh<N>> parts;
|
||||
|
||||
const auto &base = triangulate<N>(group, sg_gens);
|
||||
const auto &tiles = tile<N>(base, group, g_gens, sg_gens);
|
||||
for (const auto &tile : tiles) {
|
||||
parts.push_back(tile);
|
||||
for (const auto &sub_ctx : sub_ctxs) {
|
||||
auto root = Mesh<N>::fill(g, sub_ctx);
|
||||
auto faces = root.each_tile(ctx);
|
||||
parts.insert(parts.end(), faces.begin(), faces.end());
|
||||
}
|
||||
}
|
||||
return parts;
|
||||
|
||||
return merge(parts);
|
||||
}
|
||||
|
||||
template<unsigned N, class SC>
|
||||
Mesh<N> fill_each_tile_merge(const tc::Group &g, const SC &sub_ctxs) {
|
||||
return fill_each_tile_merge<N>(g, generators(g), sub_ctxs);
|
||||
}
|
||||
|
||||
template<unsigned N, class C, class SC>
|
||||
Mesh<N> fill_each_recontext_merge(const tc::Group &g, const C &ctx, const SC &sub_ctxs) {
|
||||
std::vector<Mesh<N>> parts;
|
||||
|
||||
for (const auto &sub_ctx : sub_ctxs) {
|
||||
auto root = Mesh<N>::fill(g, sub_ctx);
|
||||
auto face = root.recontext(ctx);
|
||||
parts.insert(parts.end(), face);
|
||||
}
|
||||
|
||||
return merge(parts);
|
||||
}
|
||||
|
||||
template<unsigned N, class SC>
|
||||
Mesh<N> fill_each_recontext_merge(const tc::Group &g, const SC &sub_ctxs) {
|
||||
return fill_each_recontext_merge<N>(g, generators(g), sub_ctxs);
|
||||
}
|
||||
|
||||
@@ -29,13 +29,10 @@ mat5 wander(float time) {
|
||||
|
||||
class ExampleApplication : public nanogui::Screen {
|
||||
public:
|
||||
vec5 root;
|
||||
|
||||
// std::unique_ptr<tc::Group> group;
|
||||
std::unique_ptr<SliceRenderer<4>> ren;
|
||||
std::unique_ptr<cgl::Buffer<Matrices>> ubo;
|
||||
|
||||
std::unique_ptr<Slice<4>> slice;
|
||||
std::vector<Slice<4>> slices;
|
||||
|
||||
float glfw_time = 0;
|
||||
float last_frame = 0;
|
||||
@@ -53,29 +50,36 @@ public:
|
||||
4, 5) {
|
||||
using namespace nanogui;
|
||||
|
||||
Window *window = new Window(this, "Sample Window");
|
||||
window->setPosition(Vector2i(15, 15));
|
||||
window->setFixedWidth(250);
|
||||
window->setLayout(new BoxLayout(Orientation::Vertical));
|
||||
// auto *window = new Window(this, "Sample Window");
|
||||
// window->setPosition(Vector2i(15, 15));
|
||||
// window->setFixedWidth(250);
|
||||
// window->setLayout(new BoxLayout(Orientation::Vertical));
|
||||
|
||||
auto pause = new ToolButton(window, ENTYPO_ICON_CONTROLLER_PAUS);
|
||||
pause->setFlags(Button::ToggleButton);
|
||||
pause->setChangeCallback([&](bool value) { this->paused = value; });
|
||||
// auto pause = new ToolButton(window, ENTYPO_ICON_CONTROLLER_PAUS);
|
||||
// pause->setFlags(Button::ToggleButton);
|
||||
// pause->setChangeCallback([&](bool value) { this->paused = value; });
|
||||
|
||||
performLayout();
|
||||
|
||||
std::cout << utilInfo();
|
||||
|
||||
{
|
||||
std::vector<int> symbol = {3, 4, 3, 2};
|
||||
root << .80, .02, .02, .02, .02;
|
||||
|
||||
auto group = tc::schlafli(symbol);
|
||||
auto ctx = generators(group);
|
||||
auto selected_ctxs = set_difference(
|
||||
combinations(ctx, 3),
|
||||
{
|
||||
{0, 1, 2},
|
||||
}
|
||||
);
|
||||
auto mesh = fill_each_tile_merge<4>(group, selected_ctxs);
|
||||
|
||||
auto gens = generators(group);
|
||||
auto combos = Combos<int>(gens, 3);
|
||||
std::vector<std::vector<int>> exclude = {{0, 1, 2}};
|
||||
auto &slice = slices.emplace_back(group);
|
||||
slice.setMesh(mesh);
|
||||
slice.root << .80, .02, .02, .02, .02;
|
||||
}
|
||||
|
||||
slice = std::make_unique<Slice<4>>(group, combos, exclude);
|
||||
ren = std::make_unique<SliceRenderer<4>>();
|
||||
|
||||
ubo = std::make_unique<cgl::Buffer<Matrices>>();
|
||||
@@ -98,16 +102,21 @@ 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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
int main(int argc, char **argv) {
|
||||
try {
|
||||
nanogui::init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user