From 96c143da8eae0a8c073752cfe60d67507a34eb16 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 18 Sep 2021 01:39:09 +0200 Subject: [PATCH] backandfront projection option --- config.cpp | 4 ++++ drawing.cpp | 10 ++++++++++ models.cpp | 2 ++ shaders.cpp | 2 ++ 4 files changed, 18 insertions(+) diff --git a/config.cpp b/config.cpp index f6f98951..52c29860 100644 --- a/config.cpp +++ b/config.cpp @@ -2164,6 +2164,10 @@ EX void show3D() { XLAT("Rotate the camera. Can be used to obtain a first person perspective, " "or third person perspective when combined with Y shift.") ); + dialog::extra_options = [] { + dialog::addBoolItem(XLAT("render behind the camera"), vpconf.back_and_front, 'R'); + dialog::add_action([] { vpconf.back_and_front = !vpconf.back_and_front; }); + }; }); } if(GDIM == 2) { diff --git a/drawing.cpp b/drawing.cpp index 0b9ae85f..e007acf4 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -2277,6 +2277,16 @@ EX void set_vr_sphere() { EX void draw_main() { DEBBI(DF_GRAPH, ("draw_main")); + if(pconf.back_and_front == 1 && vid.consider_shader_projection) { + dynamicval pa(pconf.back_and_front); + pconf.back_and_front = 0; + draw_main(); + pconf.back_and_front = 2; + reset_projection(); + draw_main(); + return; + } + set_vr_sphere(); if(sphere && GDIM == 3 && pmodel == mdPerspective && !stretch::in() && !ray::in_use) { diff --git a/models.cpp b/models.cpp index b86a11ca..f63af00e 100644 --- a/models.cpp +++ b/models.cpp @@ -1040,6 +1040,8 @@ EX namespace models { param_f(p.xposition, sp+"xposition", 0); param_f(p.yposition, sp+"yposition", 0); + param_i(p.back_and_front, sp+"backandfront", 0); + addsaver(p.alpha, sp+"projection", 1); param_custom(p.alpha, sp+"projection", menuitem_projection_distance, 'p') ->help_text = "projection distance|Gans Klein Poincare orthographic stereographic"; diff --git a/shaders.cpp b/shaders.cpp index 9540e43e..23eeaa3d 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -652,6 +652,8 @@ void display_data::set_projection(int ed, ld shift) { GLfloat sc = current_display->radius / (cd->ysize/2.); glhr::projection_multiply(glhr::frustum(cd->xsize / cd->ysize, 1)); glhr::projection_multiply(glhr::scale(sc, -sc, -1)); + if(pconf.back_and_front) + glhr::projection_multiply(glhr::scale(-1,-1,-1)); u_alpha = true; }