Add dynamic rotations (in 4d)

Make simplexes argument to geometry generation functions const
Setup really cool looking parameters
This commit is contained in:
Jacob
2020-01-22 02:09:45 -05:00
parent 7c43713fa0
commit 12b8191987
2 changed files with 62 additions and 18 deletions

View File

@@ -33,7 +33,7 @@ struct Simplexes {
Simplexes(int dim, std::vector<int> &vals): dim(dim), vals(vals) {}
explicit Simplexes(SimplexesList sl);
size_t size() {
size_t size() const {
return vals.size();
}
};
@@ -136,7 +136,7 @@ struct GeomGen {
return solve_sg(sg_gens);
}
Simplexes recontext(std::vector<int> &g_gens, std::vector<int> &sg_gens, Simplexes &items) {
Simplexes recontext(std::vector<int> &g_gens, std::vector<int> &sg_gens, const Simplexes &items) {
auto s_sg_gens = prepare_gens(g_gens, sg_gens);
auto table = solve_g(g_gens);
auto path = solve_g(sg_gens).path;
@@ -153,7 +153,7 @@ struct GeomGen {
return ret;
}
Simplexes tile(std::vector<int> &g_gens, std::vector<int> &sg_gens, Simplexes &items) {
Simplexes tile(std::vector<int> &g_gens, std::vector<int> &sg_gens, const Simplexes &items) {
Simplexes base = recontext(g_gens, sg_gens, items);
auto s_sg_gens = prepare_gens(g_gens, sg_gens);
auto table = solve_g(g_gens);

View File

@@ -1,5 +1,6 @@
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <cmath>
#include <iostream>
#include <glm/gtc/type_ptr.hpp>
@@ -17,6 +18,13 @@ __attribute__((unused)) __declspec(dllexport) int NvOptimusEnablement = 0x000000
}
#endif
float floatmod(float x, float m) {
if (x < 0) {
x += (float)((int)((-x)/m) + 1)*m;
}
return x - ((float)((int)(x / m)))*m;
}
int main(int argc, char *argv[]) {
//region init window
@@ -59,8 +67,8 @@ int main(int argc, char *argv[]) {
// utilCompileFiles(GL_VERTEX_SHADER, {"shaders/ortho.vs.glsl"}),
// utilCompileFiles(GL_VERTEX_SHADER, {"shaders/stereo.vs.glsl"}),
utilCompileFiles(GL_GEOMETRY_SHADER, {"shaders/stereo-proper.gm.glsl"}),
// utilCompileFiles(GL_FRAGMENT_SHADER, {"shaders/one-color.fs.glsl"}),
utilCompileFiles(GL_FRAGMENT_SHADER, {"shaders/w-axis-hue.fs.glsl"})
utilCompileFiles(GL_FRAGMENT_SHADER, {"shaders/one-color.fs.glsl"}),
// utilCompileFiles(GL_FRAGMENT_SHADER, {"shaders/w-axis-hue.fs.glsl"})
});
} catch (const gl_error &e) {
std::cerr << e.what() << std::endl;
@@ -68,16 +76,18 @@ int main(int argc, char *argv[]) {
exit(EXIT_FAILURE);
}
auto group = tc::group::H(3)*tc::group::H(2);
auto group = tc::group::H(4);
// auto group = tc::group::B(5);
// auto group = tc::group::A(5);
GeomGen gg(group);
auto res = gg.solve();
auto mirrors = mirror(group);
auto corners = plane_intersections(mirrors);
auto start = barycentric(corners, {1.00f, 1.00f, 0.05, 1.00f});
// auto start = barycentric(corners, {1.00f, 0.05f, 0.05f, 0.05f});
// auto start = barycentric(corners, {.75f, .75f, .75f, .75f});
auto start = barycentric(corners, {1.00f, 0.1f, 0.01f, 0.005f});
// auto start = barycentric(corners, {1, 1, 0.05, 1});
auto points = res.path.walk<glm::vec4, glm::vec4>(start, mirrors, reflect_scaled);
auto points = res.path.walk<glm::vec4, glm::vec4>(start, mirrors, reflect);
GLuint vbo;
glGenBuffers(1, &vbo);
@@ -91,12 +101,14 @@ int main(int argc, char *argv[]) {
std::vector<GLuint> edge_ibo;
Simplexes base(1);
base.vals = {0,1};
auto g_gens = gg.group_gens();
std::vector<int> g_gens = gg.group_gens();
for (int i = 0; i < group.ngens; i++) {
printf("Num Edges:\n");
for (const auto i : g_gens) {
std::vector<int> sg_gens = {i};
const auto data = gg.tile(g_gens, sg_gens, base).vals;
edge_count.push_back(data.size());
printf("\t%d: %d", i, data.size());
GLuint ibo;
glGenBuffers(1, &ibo);
@@ -107,6 +119,27 @@ int main(int argc, char *argv[]) {
glBindBuffer(GL_ARRAY_BUFFER, 0);
size_t numts = 7;
float rates[numts];
rates[0] = 1.237;
rates[1] = 2.439;
rates[2] = 5.683;
rates[3] = -3.796;
rates[4] = 0.787;
rates[5] = -1.893;
rates[6] = 3.699;
float _ts[numts];
float _ts_temp[numts];
for (int i = 0; i < numts; ++i) {
_ts[i] = ((float)i - (numts/2.f))*0.1f;
}
float* ts = _ts;
float* ts_temp = _ts_temp;
float* swap_t;
float alpha = 0.0001;
float beta = 0.0002;
while (!glfwWindowShouldClose(window)) {
int width, height;
glfwGetFramebufferSize(window, &width, &height);
@@ -127,14 +160,25 @@ int main(int argc, char *argv[]) {
glm::mat4 proj = glm::ortho(-pwidth, pwidth, -pheight, pheight, -10.0f, 10.0f);
glUniformMatrix4fv(0, 1, false, glm::value_ptr(proj));
auto t = (float) glfwGetTime() / 3;
auto st = (float) glfwGetTime() / 8;
auto t = st / 7;
// printf("ts: [%f", ts[0]);
ts_temp[0] = ts[0] + alpha * (float)std::cos(rates[0] * t) + beta * (-ts[0]);
for (size_t i = 1; i < numts; i++){
// printf( ", %f", ts[i]);
ts_temp[i] = ts[i] + alpha * (float)std::cos(rates[i] * t) + beta * (-ts[i]);
}
// printf("]\n");
swap_t = ts;
ts = ts_temp;
ts_temp = swap_t;
auto view = glm::identity<glm::mat4>();
view *= utilRotate(0, 1, t * 0.8f);
view *= utilRotate(0, 2, t * 0.9f);
view *= utilRotate(0, 3, t * 1.0f);
view *= utilRotate(1, 2, -t * 1.1f);
view *= utilRotate(1, 3, -t * 1.2f);
view *= utilRotate(2, 3, -t * 1.3f);
view *= utilRotate(0, 1, st * ts[0]);
view *= utilRotate(0, 2, st * ts[1]);
view *= utilRotate(0, 3, st * ts[2]);
view *= utilRotate(1, 2, st * ts[3]);
view *= utilRotate(1, 3, st * ts[4]);
view *= utilRotate(2, 3, st * ts[5]);
glUniformMatrix4fv(1, 1, false, glm::value_ptr(view));
//endregion