mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
decomposing "build" into reusable steps. raise is still broken.
This commit is contained in:
@@ -53,20 +53,17 @@ tc::Group shrink(const tc::Group &g, const std::array<int, D> &sub) {
|
||||
}
|
||||
|
||||
template<int D>
|
||||
std::vector<tc::Action> raise(
|
||||
const tc::Cosets &cosets,
|
||||
const std::vector<tc::Action> &path,
|
||||
const std::array<int, D> &gen_map
|
||||
std::vector<int> raise(
|
||||
const tc::Cosets &g_res,
|
||||
const tc::Cosets &h_res,
|
||||
const std::array<int, D> &gen_map,
|
||||
const std::vector<int> &path
|
||||
) {
|
||||
std::vector<tc::Action> res(path.size(), {0, 0, 0});
|
||||
std::vector<int> res(path.size(), 0);
|
||||
for (size_t i = 1; i < path.size(); ++i) {
|
||||
auto action = path[i];
|
||||
auto action = h_res.path[path[i]];
|
||||
|
||||
auto coset = res[action.coset].target;
|
||||
auto gen = gen_map[action.gen];
|
||||
auto target = cosets.get(coset, gen);
|
||||
|
||||
res[i] = {coset, gen, target};
|
||||
res[i] = g_res.get(res[action.coset], gen_map[action.gen]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -97,9 +94,8 @@ std::vector<int> build(const tc::Group &g, const std::array<int, D> &sub) {
|
||||
auto hres = tc::solve(h); // recursion would happen here
|
||||
|
||||
auto gres = tc::solve(g);
|
||||
auto path = raise<D>(gres, hres.path, sub);
|
||||
|
||||
const std::vector<int> &geom = targets(path);
|
||||
std::vector<int> geom = targets(hres.path);
|
||||
geom = raise<D>(gres, hres, sub, geom);
|
||||
|
||||
return tile(gres, geom);
|
||||
}
|
||||
@@ -133,7 +129,7 @@ int main(int argc, char *argv[]) {
|
||||
<< " OpenGL version: " << glGetString(GL_VERSION) << std::endl
|
||||
<< " Shading version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
|
||||
|
||||
auto group = tc::group::H(4);
|
||||
auto group = tc::group::B(2);
|
||||
auto res = tc::solve(group);
|
||||
auto mirrors = mirror(group);
|
||||
auto corners = plane_intersections(mirrors);
|
||||
@@ -145,10 +141,22 @@ int main(int argc, char *argv[]) {
|
||||
points[i] = reflect(points[action.coset], mirrors[action.gen]);
|
||||
}
|
||||
|
||||
auto g0 = build<2>(group, {0});
|
||||
auto g1 = build<2>(group, {1});
|
||||
auto g2 = build<2>(group, {2});
|
||||
auto g3 = build<2>(group, {3});
|
||||
auto h = shrink<2>(group, {0, 1});
|
||||
auto i = shrink<1>(h, {0});
|
||||
|
||||
auto g_map = res;
|
||||
auto h_map = tc::solve(h);
|
||||
auto i_map = tc::solve(i);
|
||||
|
||||
auto g0 = targets(i_map.path);
|
||||
g0 = raise<1>(h_map, i_map, {0}, g0);
|
||||
g0 = tile(h_map, g0);
|
||||
g0 = raise<2>(g_map, h_map, {0, 1}, g0);
|
||||
|
||||
// auto g0 = build<2>(group, {0});
|
||||
// auto g1 = build<2>(group, {1});
|
||||
// auto g2 = build<2>(group, {2});
|
||||
// auto g3 = build<2>(group, {3});
|
||||
|
||||
GLuint vs = glCreateShader(GL_VERTEX_SHADER);
|
||||
utilShaderSource(vs, {
|
||||
@@ -164,6 +172,7 @@ int main(int argc, char *argv[]) {
|
||||
"void main() {"
|
||||
" int i = gl_VertexID;"
|
||||
" vpos = view * pos;"
|
||||
// " gl_Position = proj * vec4(vpos.xyz / (1), 1);"
|
||||
" gl_Position = proj * vec4(vpos.xyz / (1 - vpos.w), 1);"
|
||||
" gl_PointSize = 5;"
|
||||
"}"
|
||||
@@ -223,20 +232,20 @@ int main(int argc, char *argv[]) {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, ibo0);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(int) * g0.size(), &g0[0], GL_STATIC_DRAW);
|
||||
|
||||
GLuint ibo1;
|
||||
glGenBuffers(1, &ibo1);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, ibo1);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(int) * g1.size(), &g1[0], GL_STATIC_DRAW);
|
||||
|
||||
GLuint ibo2;
|
||||
glGenBuffers(1, &ibo2);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, ibo2);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(int) * g2.size(), &g2[0], GL_STATIC_DRAW);
|
||||
|
||||
GLuint ibo3;
|
||||
glGenBuffers(1, &ibo3);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, ibo3);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(int) * g3.size(), &g3[0], GL_STATIC_DRAW);
|
||||
// GLuint ibo1;
|
||||
// glGenBuffers(1, &ibo1);
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, ibo1);
|
||||
// glBufferData(GL_ARRAY_BUFFER, sizeof(int) * g1.size(), &g1[0], GL_STATIC_DRAW);
|
||||
//
|
||||
// GLuint ibo2;
|
||||
// glGenBuffers(1, &ibo2);
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, ibo2);
|
||||
// glBufferData(GL_ARRAY_BUFFER, sizeof(int) * g2.size(), &g2[0], GL_STATIC_DRAW);
|
||||
//
|
||||
// GLuint ibo3;
|
||||
// glGenBuffers(1, &ibo3);
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, ibo3);
|
||||
// glBufferData(GL_ARRAY_BUFFER, sizeof(int) * g3.size(), &g3[0], GL_STATIC_DRAW);
|
||||
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
@@ -270,17 +279,17 @@ int main(int argc, char *argv[]) {
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo0);
|
||||
glDrawElements(GL_LINES, g0.size(), GL_UNSIGNED_INT, nullptr);
|
||||
|
||||
glUniform3f(2, 0.0f, 1.0f, 0.0f);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo1);
|
||||
glDrawElements(GL_LINES, g1.size(), GL_UNSIGNED_INT, nullptr);
|
||||
|
||||
glUniform3f(2, 0.0f, 0.0f, 1.0f);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo2);
|
||||
glDrawElements(GL_LINES, g2.size(), GL_UNSIGNED_INT, nullptr);
|
||||
|
||||
glUniform3f(2, 0.5f, 0.5f, 0.0f);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo3);
|
||||
glDrawElements(GL_LINES, g3.size(), GL_UNSIGNED_INT, nullptr);
|
||||
// glUniform3f(2, 0.0f, 1.0f, 0.0f);
|
||||
// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo1);
|
||||
// glDrawElements(GL_LINES, g1.size(), GL_UNSIGNED_INT, nullptr);
|
||||
//
|
||||
// glUniform3f(2, 0.0f, 0.0f, 1.0f);
|
||||
// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo2);
|
||||
// glDrawElements(GL_LINES, g2.size(), GL_UNSIGNED_INT, nullptr);
|
||||
//
|
||||
// glUniform3f(2, 0.7f, 0.7f, 0.0f);
|
||||
// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo3);
|
||||
// glDrawElements(GL_LINES, g3.size(), GL_UNSIGNED_INT, nullptr);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user