mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 09:50:34 +00:00
rotational model of Nil, and change Nil rotation
This commit is contained in:
parent
59a7d3e562
commit
18ab187547
@ -413,6 +413,7 @@ EX void initConfig() {
|
||||
addsaver(pconf.top_z, "topz", 5);
|
||||
addsaver(pconf.model_transition, "model transition", 1);
|
||||
addsaver(pconf.halfplane_scale, "halfplane scale", 1);
|
||||
addsaver(pconf.rotational_nil, "rotnil", 1);
|
||||
addsaver(history::autoband, "automatic band");
|
||||
addsaver(history::autobandhistory, "automatic band history");
|
||||
addsaver(history::dospiral, "do spiral");
|
||||
|
5
glhr.cpp
5
glhr.cpp
@ -275,6 +275,7 @@ struct GLprogram {
|
||||
|
||||
GLint uFog, uFogColor, uColor, tTexture, tInvExpTable, tAirMap, uMV, uProjection, uAlpha, uFogBase, uPP;
|
||||
GLint uPRECX, uPRECY, uPRECZ, uIndexSL, uIterations, uLevelLines, uSV, uRadarTransform;
|
||||
GLint uRotSin, uRotCos, uRotNil;
|
||||
|
||||
flagtype shader_flags;
|
||||
|
||||
@ -402,6 +403,10 @@ GLprogram::GLprogram(string vsh, string fsh) {
|
||||
uIterations = glGetUniformLocation(_program, "uIterations");
|
||||
uLevelLines = glGetUniformLocation(_program, "uLevelLines");
|
||||
uRadarTransform = glGetUniformLocation(_program, "uRadarTransform");
|
||||
|
||||
uRotCos = glGetUniformLocation(_program, "uRotCos");
|
||||
uRotSin = glGetUniformLocation(_program, "uRotSin");
|
||||
uRotNil = glGetUniformLocation(_program, "uRotNil");
|
||||
}
|
||||
|
||||
GLprogram::~GLprogram() {
|
||||
|
2
hyper.h
2
hyper.h
@ -256,9 +256,11 @@ struct projection_configuration {
|
||||
ld spiral_cone;
|
||||
ld skiprope;
|
||||
ld product_z_scale;
|
||||
ld rotational_nil;
|
||||
|
||||
projection_configuration() {
|
||||
formula = "z^2"; top_z = 5; model_transition = 1; spiral_angle = 70; spiral_x = 10; spiral_y = 7;
|
||||
rotational_nil = 1;
|
||||
right_spiral_multiplier = 1;
|
||||
any_spiral_multiplier = 1;
|
||||
sphere_spiral_multiplier = 2;
|
||||
|
50
hypgraph.cpp
50
hypgraph.cpp
@ -345,6 +345,24 @@ EX ld signed_sqrt(ld x) { return x > 0 ? sqrt(x) : -sqrt(-x); }
|
||||
|
||||
EX int axial_x, axial_y;
|
||||
|
||||
EX void apply_perspective(const hyperpoint& H, hyperpoint& ret) {
|
||||
if(H[2] == 0) { ret[0] = 1e6; ret[1] = 1e6; ret[2] = 1; return; }
|
||||
ld ratio = vid.xres / current_display->tanfov / current_display->radius / 2;
|
||||
ret[0] = H[0]/H[2] * ratio;
|
||||
ret[1] = H[1]/H[2] * ratio;
|
||||
ret[2] = 1;
|
||||
ret[3] = 1;
|
||||
}
|
||||
|
||||
EX void apply_nil_rotation(hyperpoint& H) {
|
||||
if(nil) {
|
||||
H[2] -= H[0] * H[1] / 2;
|
||||
models::apply_orientation(H[0], H[1]);
|
||||
H[2] += H[0] * H[1] / 2 * pconf.rotational_nil;
|
||||
models::apply_orientation(H[1], H[0]);
|
||||
}
|
||||
}
|
||||
|
||||
EX void applymodel(shiftpoint H_orig, hyperpoint& ret) {
|
||||
|
||||
hyperpoint H = H_orig.h;
|
||||
@ -360,22 +378,16 @@ EX void applymodel(shiftpoint H_orig, hyperpoint& ret) {
|
||||
|
||||
switch(pmodel) {
|
||||
case mdPerspective: {
|
||||
ld ratio = vid.xres / current_display->tanfov / current_display->radius / 2;
|
||||
if(prod) H = product::inverse_exp(H);
|
||||
apply_nil_rotation(H);
|
||||
H = lp_apply(H);
|
||||
if(H[2] == 0) { ret[0] = 1e6; ret[1] = 1e6; ret[2] = 1; return; }
|
||||
ret[0] = H[0]/H[2] * ratio;
|
||||
ret[1] = H[1]/H[2] * ratio;
|
||||
ret[2] = 1;
|
||||
return;
|
||||
apply_perspective(H, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
case mdGeodesic: {
|
||||
auto S = lp_apply(inverse_exp(H_orig, pNORMAL | pfNO_DISTANCE));
|
||||
ld ratio = vid.xres / current_display->tanfov / current_display->radius / 2;
|
||||
ret[0] = S[0]/S[2] * ratio;
|
||||
ret[1] = S[1]/S[2] * ratio;
|
||||
ret[2] = 1;
|
||||
apply_perspective(S, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -558,19 +570,25 @@ EX void applymodel(shiftpoint H_orig, hyperpoint& ret) {
|
||||
case mdHorocyclic: {
|
||||
|
||||
find_zlev(H);
|
||||
|
||||
apply_nil_rotation(H);
|
||||
|
||||
models::apply_orientation_yz(H[1], H[2]);
|
||||
models::apply_orientation(H[0], H[1]);
|
||||
if(hyperbolic) {
|
||||
models::apply_orientation_yz(H[1], H[2]);
|
||||
models::apply_orientation(H[0], H[1]);
|
||||
}
|
||||
|
||||
ret = hyperbolic ? deparabolic10(H) : H;
|
||||
ret *= .5;
|
||||
ret[LDIM] = 1;
|
||||
|
||||
models::apply_orientation(ret[1], ret[0]);
|
||||
models::apply_orientation_yz(ret[2], ret[1]);
|
||||
|
||||
if(hyperbolic) {
|
||||
models::apply_orientation(ret[1], ret[0]);
|
||||
models::apply_orientation_yz(ret[2], ret[1]);
|
||||
}
|
||||
|
||||
if(nonisotropic) ret = lp_apply(ret);
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
17
models.cpp
17
models.cpp
@ -449,7 +449,18 @@ EX namespace models {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(among(vpmodel, mdPerspective, mdHorocyclic) && nil) {
|
||||
dialog::addSelItem(XLAT("model orientation"), fts(vpconf.model_orientation) + "°", 'l');
|
||||
dialog::add_action([] () {
|
||||
dialog::editNumber(vpconf.model_orientation, 0, 360, 90, 0, XLAT("model orientation"), "");
|
||||
});
|
||||
dialog::addSelItem(XLAT("rotational or Heisenberg"), fts(vpconf.rotational_nil), 'L');
|
||||
dialog::add_action([] () {
|
||||
dialog::editNumber(vpconf.rotational_nil, 0, 1, 1, 1, XLAT("1 = Heisenberg, 0 = rotational"), "");
|
||||
});
|
||||
}
|
||||
|
||||
if(GDIM == 3 && vpmodel != mdPerspective) {
|
||||
const string cliphelp = XLAT(
|
||||
"Your view of the 3D model is naturally bounded from four directions by your window. "
|
||||
@ -737,6 +748,10 @@ EX namespace models {
|
||||
PHASEFROM(2);
|
||||
shift_arg_formula(vpconf.model_orientation);
|
||||
}
|
||||
else if(argis("-mnil")) {
|
||||
PHASEFROM(2);
|
||||
shift_arg_formula(vpconf.rotational_nil);
|
||||
}
|
||||
else if(argis("-mori2")) {
|
||||
PHASEFROM(2);
|
||||
shift_arg_formula(vpconf.model_orientation);
|
||||
|
12
shaders.cpp
12
shaders.cpp
@ -269,6 +269,12 @@ shared_ptr<glhr::GLprogram> write_shader(flagtype shader_flags) {
|
||||
if(dim3) shader_flags |= SF_ZFOG;
|
||||
}
|
||||
|
||||
if(nil && pmodel == mdPerspective) {
|
||||
vsh += "uniform mediump float uRotCos, uRotSin, uRotNil;\n";
|
||||
coordinator +=
|
||||
"t.z += (uRotCos * t.x + uRotSin * t.y) * (uRotCos * t.y - uRotSin * t.x) * uRotNil / 2. - t.x * t.y / 2.;\n";
|
||||
}
|
||||
|
||||
if(!skip_t) {
|
||||
vmain += "mediump vec4 t = uMV * aPosition;\n";
|
||||
vmain += coordinator;
|
||||
@ -503,6 +509,12 @@ void display_data::set_projection(int ed, ld shift) {
|
||||
if(ed) glhr::projection_multiply(glhr::translate(vid.ipd * ed/2, 0, 0));
|
||||
}
|
||||
|
||||
if(selected->uRotNil != -1) {
|
||||
glUniform1f(selected->uRotCos, models::ocos);
|
||||
glUniform1f(selected->uRotSin, models::osin);
|
||||
glUniform1f(selected->uRotNil, pconf.rotational_nil);
|
||||
}
|
||||
|
||||
if(selected->uPP != -1) {
|
||||
glhr::glmatrix pp = glhr::id;
|
||||
if(get_shader_flags() & SF_USE_ALPHA)
|
||||
|
Loading…
Reference in New Issue
Block a user