From 44cfe1af5927f3b4cd8e3d2bdd31a8ccb8237b3e Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 17 Apr 2020 17:17:22 +0200 Subject: [PATCH] rug:: nonisotropic native geometry --- geom-exp.cpp | 2 +- rug.cpp | 43 +++++++++++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/geom-exp.cpp b/geom-exp.cpp index af582e25..01ed6dea 100644 --- a/geom-exp.cpp +++ b/geom-exp.cpp @@ -940,7 +940,7 @@ EX void runGeometryExperiments() { #if CAP_COMMANDLINE -eGeometry readGeo(const string& ss) { +EX eGeometry readGeo(const string& ss) { for(int i=0; i '9') numeric = false; diff --git a/rug.cpp b/rug.cpp index b79e3fde..2b4f55f0 100644 --- a/rug.cpp +++ b/rug.cpp @@ -253,15 +253,13 @@ EX rugpoint *addRugpoint(hyperpoint h, double dist) { else { m->native = h; ld hd = h[LDIM]; - for(int d=GDIM; dnative[d] = (hd - .99) * (rand() % 1000 - rand() % 1000) / 1000; } USING_NATIVE_GEOMETRY; #if MAXMDIM >= 4 - if(euclid) - m->native[3] = 1; - else - m->native = normalize(m->native); + m->native[3] = 1; + m->native = normalize(m->native); #endif } @@ -701,7 +699,6 @@ EX void preset(rugpoint *m) { if(q>0) m->native = h / q; #endif - // printf("preset (%d) -> %s\n", q, display(m->native)); if(std::isnan(m->native[0]) || std::isnan(m->native[1]) || std::isnan(m->native[2])) throw rug_exception(); } @@ -1006,6 +1003,7 @@ void drawTriangle(triangle& t) { hyperpoint hc = (t.m[1]->native - t.m[0]->native) ^ (t.m[2]->native - t.m[0]->native); double hch = hypot_d(3, hc); col = (2 + hc[0]/hch) / 3; + if(nonisotropic) col = (9+col) / 10; } for(int i=0; i<3; i++) { @@ -1091,8 +1089,16 @@ EX void drawRugScene() { for(auto t: triangles) drawTriangle(t); auto& rug = queuecurve(0, 0xFFFFFFFF, PPR::LINE); - - rug.V = rugView; + + if(nonisotropic) { + transmatrix T2 = eupush( tC0(inverse(rugView)) ); + NLP = rugView * T2; + rug.V = inverse(NLP) * rugView; + } + else { + rug.V = rugView; + } + rug.offset_texture = 0; rug.tinf = &tinf; rug.flags = POLY_TRIANGLES | POLY_FAT | POLY_PRINTABLE | POLY_ALWAYS_IN | POLY_ISSIDE | POLY_SHADE_TEXTURE; @@ -1435,18 +1441,26 @@ EX void rug_geometry_choice() { gamescreen(0); dialog::init(XLAT("hypersian rug mode"), iinf[itPalace].color, 150, 100); - dialog::addBoolItem("Euclidean", rug_euclid(), 'a'); + USING_NATIVE_GEOMETRY; + + dialog::addBoolItem("Euclidean", euclid, 'a'); dialog::add_action([] { gwhere = rgEuclid; popScreen(); }); - dialog::addBoolItem("hyperbolic", rug_hyperbolic(), 'b'); + dialog::addBoolItem("hyperbolic", hyperbolic, 'b'); dialog::add_action([] { gwhere = rgHyperbolic; popScreen(); }); - dialog::addBoolItem("spherical", rug_sphere() && !rug_elliptic(), 'c'); + dialog::addBoolItem("spherical", sphere && !elliptic, 'c'); dialog::add_action([] { gwhere = rgSphere; popScreen(); }); - dialog::addBoolItem("elliptic", rug_elliptic(), 'd'); + dialog::addBoolItem("elliptic", elliptic, 'd'); dialog::add_action([] { gwhere = rgElliptic; popScreen(); }); + dialog::addBoolItem("Nil", nil, 'e'); + dialog::add_action([] { gwhere = gNil; popScreen(); }); + + dialog::addBoolItem("Solv", sol, 'e'); + dialog::add_action([] { gwhere = gSol; popScreen(); }); + dialog::addBack(); dialog::display(); } @@ -1732,7 +1746,7 @@ int rugArgs() { } else if(argis("-ruggeo")) { - shift(); gwhere = (eGeometry) argi(); + shift(); gwhere = readGeo(args()); if(gwhere == gEuclid) gwhere = rgEuclid; if(gwhere == gSphere) gwhere = rgSphere; if(gwhere == gNormal) gwhere = rgHyperbolic; @@ -1740,7 +1754,8 @@ int rugArgs() { } else if(argis("-rugpers")) { - rconf.model = mdPerspective; + USING_NATIVE_GEOMETRY; + rconf.model = nonisotropic ? mdGeodesic : mdPerspective; } else if(argis("-rugonce")) {