From 01763d4f12a95c8104df8b992b86fce5b1dd83dc Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 1 Jun 2019 19:58:07 +0200 Subject: [PATCH] 2D3D:: eye level --- 3d-models.cpp | 4 +++- config.cpp | 7 +++++++ geometry.cpp | 11 +++++++++++ hyper.h | 5 +++++ hypgraph.cpp | 3 ++- 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/3d-models.cpp b/3d-models.cpp index e3d08988..eebdd8ad 100644 --- a/3d-models.cpp +++ b/3d-models.cpp @@ -736,7 +736,9 @@ void geometry_information::adjust_eye(hpcshape& eye, hpcshape head, ld shift_eye qtyall++; } - if(&eye == &shSkullEyes) pos = zc(eyepos) - 0.06 * SH * 0.05; + if(&eye == &shSkullEyes) cgi.eyelevel_human = pos = zc(eyepos) - 0.06 * SH * 0.05; + if(&eye == &shWolf1) cgi.eyelevel_dog = pos; + if(&eye == &shFamiliarEye) cgi.eyelevel_familiar = pos; make_ball(eye, rad, 0); transmatrix T = zpush(-shift_eye) * rgpushxto0(center) * zpush(pos); diff --git a/config.cpp b/config.cpp index 6fe9e600..4c220f94 100644 --- a/config.cpp +++ b/config.cpp @@ -220,6 +220,9 @@ void initConfig() { addsaver(vid.gp_autoscale_heights, "3D Goldberg autoscaling", true); addsaver(vid.always3, "3D always", false); + addsaver(vid.eye, "eyelevel", 0); + addsaver(vid.auto_eye, "auto-eyelevel", false); + addsaver(memory_saving_mode, "memory_saving_mode", (ISMOBILE || ISPANDORA || ISWEB) ? 1 : 0); addsaver(rug::renderonce, "rug-renderonce"); @@ -1282,6 +1285,9 @@ void show3D() { if(WDIM == 2) { dialog::addSelItem(XLAT(GDIM == 2 ? "Camera level above the plane" : "Z shift"), fts(vid.camera), 'c'); + if(GDIM == 3) + dialog::addSelItem(XLAT("Eye level"), fts(vid.eye), 'E'); + dialog::addSelItem(XLAT("Ground level below the plane"), fts(vid.depth), 'g'); if(GDIM == 2) @@ -2089,6 +2095,7 @@ unordered_map params = { {"ballangle", vid.ballangle}, {"yshift", vid.yshift}, {"cameraangle", vid.camera_angle}, + {"eye", vid.eye}, {"depth", vid.depth}, {"camera", vid.camera}, {"wall_height", vid.wall_height}, diff --git a/geometry.cpp b/geometry.cpp index f9960078..ba5c0885 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -217,6 +217,17 @@ namespace geom3 { return vid.depth - projection_to_abslev(factor_to_projection(fac)); } + void do_auto_eye() { + if(!vid.auto_eye) return; + auto& cs = getcs(); + if(cs.charid < 4) + vid.eye = cgi.eyelevel_human; + else if(cs.charid < 8) + vid.eye = cgi.eyelevel_dog; + else if(cs.charid == 8) + vid.eye = cgi.eyelevel_familiar; + } + // how should we scale at level lev ld scale_at_lev(ld lev) { if(sphere || euclid) return 1; diff --git a/hyper.h b/hyper.h index 1554f8e9..0539cb18 100644 --- a/hyper.h +++ b/hyper.h @@ -312,6 +312,9 @@ struct videopar { int tc_alpha, tc_depth, tc_camera; ld highdetail, middetail; bool gp_autoscale_heights; + + ld eye; + bool auto_eye; }; extern videopar vid; @@ -4350,6 +4353,8 @@ struct geometry_information { ALEG0, ALEG, ABODY, AHEAD, BIRD, LOWSKY, SKY, HIGH, HIGH2; ld human_height, slev; + ld eyelevel_familiar, eyelevel_human, eyelevel_dog; + #if CAP_SHAPES hpcshape shSemiFloorSide[SIDEPARS], diff --git a/hypgraph.cpp b/hypgraph.cpp index bcb401a4..0b4cfd70 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1159,8 +1159,9 @@ void centerpc(ld aspd) { transmatrix T = cwtV; #if MAXMDIM >= 4 if(GDIM == 3 && WDIM == 2) { + geom3::do_auto_eye(); int sl = snakelevel(cwt.at); - if(sl) T = T * zpush(cgi.SLEV[sl] - cgi.FLOOR); + if(sl || vid.eye) T = T * zpush(cgi.SLEV[sl] - cgi.FLOOR + vid.eye); } #endif hyperpoint H = inverse(actual_view_transform) * tC0(T);