WIP: Render 4d geometry from file

This commit is contained in:
David Allemang
2022-02-24 16:31:40 -05:00
parent 160f978e7e
commit d99e824a06
3 changed files with 79 additions and 56 deletions

View File

@@ -4,41 +4,59 @@
#include <mirror.hpp>
#include <ml/meshlib.hpp>
#include <ml/meshlib_json.hpp>
#include <fstream>
#include <iostream>
int main() {
std::vector<int> symbol = {3, 4, 3, 2};
vec5 root{0.80, 0.02, 0.02, 0.02, 0.02};
std::vector<int> symbol = {5, 3, 3};
vec4 root{0.80, 0.02, 0.02, 0.02};
auto group = tc::schlafli(symbol);
auto gens = generators(group);
auto combos = combinations(gens, 3);
auto combos = combinations(gens, 2);
const auto &inds = merge<4>(hull<4>(group, combos, {}));
const auto &inds = merge<3>(hull<3>(group, combos, {
{0, 1},
}));
auto cosets = group.solve();
auto mirrors = mirror<5>(group);
auto mirrors = mirror<4>(group);
auto corners = plane_intersections(mirrors);
auto start = barycentric(corners, root);
using Projective5f = Eigen::Transform<float, 5, Eigen::Projective>;
Projective5f transform = Projective5f::Identity();
using Projective = Eigen::Transform<float, 4, Eigen::Projective>;
Projective transform = Projective::Identity();
auto higher = cosets.path.walk<vec5, vec5>(start, mirrors, reflect<vec5>);
auto higher = cosets.path.walk<vec4, vec4>(start, mirrors, reflect<vec4>);
std::transform(
higher.begin(), higher.end(), higher.begin(),
[&](const vec5 &v) {
[&](const vec4 &v) {
return (transform * v.homogeneous()).hnormalized();
}
);
std::vector<vec4> lower(higher.size());
std::transform(higher.begin(), higher.end(), lower.begin(), stereo<4>);
// std::vector<vec4> lower(higher.size());
// std::transform(higher.begin(), higher.end(), lower.begin(), stereo<4>);
// const auto &verts = lower;
const auto &verts = lower;
const auto &verts = higher;
std::cout << inds.rows() << " " << inds.cols() << std::endl;
using PT = Eigen::Matrix<float, 4, Eigen::Dynamic>;
using CT = Eigen::Matrix<unsigned, 3, Eigen::Dynamic>;
PT points(4, verts.size());
std::copy(verts.begin(), verts.end(), points.colwise().begin());
CT cells = inds;
std::cout << points.rows() << " " << points.cols() << std::endl;
std::cout << cells.rows() << " " << cells.cols() << std::endl;
ml::Mesh mesh(points, cells);
ml::write(mesh, std::ofstream("dodeca.pak", std::ios::out | std::ios::binary));
return EXIT_SUCCESS;
}