diff --git a/basegraph.cpp b/basegraph.cpp index 6b499186..ae174550 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -275,7 +275,11 @@ void display_data::set_projection(int ed, bool apply_models) { current_display->scrdist_text = cd->ysize; } else if(DIM == 3) { - glhr::projection_multiply(glhr::ortho(cd->xsize/current_display->radius/2, -cd->ysize/current_display->radius/2, 1)); + glhr::glmatrix M = glhr::ortho(cd->xsize/current_display->radius/2, -cd->ysize/current_display->radius/2, 1); + using conformal::clip_max, conformal::clip_min; + M[2][2] = 2 / (clip_max - clip_min); + M[3][2] = (clip_min + clip_max) / (clip_max - clip_min); + glhr::projection_multiply(M); current_display->scrdist_text = 0; } else { diff --git a/config.cpp b/config.cpp index 96f51552..d2170c7e 100644 --- a/config.cpp +++ b/config.cpp @@ -233,6 +233,8 @@ void initConfig() { addsaver(conformal::autoband, "automatic band"); addsaver(conformal::autobandhistory, "automatic band history"); addsaver(conformal::dospiral, "do spiral"); + addsaver(conformal::clip_min, "clip-min", -1); + addsaver(conformal::clip_max, "clip-max", +1); addsaver(vid.backeffects, "background particle effects", (ISMOBILE || ISPANDORA) ? false : true); // control @@ -2076,6 +2078,9 @@ unordered_map params = { {"lvspeed", conformal::lvspeed}, {"rotation", conformal::rotation}, {"mori", conformal::model_orientation}, + {"mori_yz", conformal::model_orientation_yz}, + {"clipmin", conformal::clip_min}, + {"clipmax", conformal::clip_max}, {"topz", conformal::top_z}, {"mtrans", conformal::model_transition}, {"hp", conformal::halfplane_scale}, diff --git a/conformal.cpp b/conformal.cpp index 8d5d4330..834203cd 100644 --- a/conformal.cpp +++ b/conformal.cpp @@ -275,6 +275,7 @@ namespace conformal { ld rotation = 0; int do_rotate = 1; ld model_orientation, halfplane_scale, model_orientation_yz; + ld clip_min, clip_max; ld ocos, osin, ocos_yz, osin_yz; ld cos_ball, sin_ball; bool model_straight, model_straight_yz; @@ -731,6 +732,28 @@ namespace conformal { }); } } + + if(DIM == 3 && pmodel != mdPerspective) { + const string cliphelp = XLAT( + "Your view of the 3D model is naturally bounded from four directions by your window. " + "Here, you can also set up similar bounds in the Z direction. Radius of the ball/band " + "models, and the distance from the center to the plane in the halfspace model, are 1.\n\n"); + dialog::addSelItem(XLAT("near clipping plane"), fts(clip_max), 'c'); + dialog::add_action([cliphelp] () { + dialog::editNumber(clip_max, -10, 10, 0.2, 1, XLAT("near clipping plane"), + cliphelp + XLAT("Objects with Z coordinate " + "bigger than this parameter are not shown. This is useful with the models which " + "extend infinitely in the Z direction, or if you want things close to your character " + "to be not obscured by things closer to the camera.")); + }); + dialog::addSelItem(XLAT("far clipping plane"), fts(clip_min), 'C'); + dialog::add_action([cliphelp] () { + dialog::editNumber(clip_max, -10, 10, 0.2, 1, XLAT("far clipping plane"), + cliphelp + XLAT("Objects with Z coordinate " + "smaller than this parameter are not shown; it also affects the fog effect" + " (near clipping plane = 0% fog, far clipping plane = 100% fog).")); + }); + } if(pmodel == mdPolynomial) { dialog::addSelItem(XLAT("coefficient"), @@ -1144,6 +1167,11 @@ namespace conformal { shift_arg_formula(conformal::model_orientation); shift_arg_formula(conformal::model_orientation_yz); } + else if(argis("-clip")) { + PHASEFROM(2); + shift_arg_formula(conformal::clip_min); + shift_arg_formula(conformal::clip_max); + } else if(argis("-mtrans")) { PHASEFROM(2); shift_arg_formula(conformal::model_transition); diff --git a/hyper.h b/hyper.h index 453bf6a7..8cb2fc60 100644 --- a/hyper.h +++ b/hyper.h @@ -1405,6 +1405,7 @@ namespace conformal { extern ld top_z; extern ld spiral_angle, spiral_x, spiral_y; extern ld spiral_cone; + extern ld clip_min, clip_max; // screen coordinates to logical coordinates: apply_orientation(x,y) // logical coordinates back to screen coordinates: apply_orientation(y,x) diff --git a/shaders.cpp b/shaders.cpp index 4072b76e..497347ae 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -590,7 +590,7 @@ void init() { sh3 || sr3 || ball,"t[3] = 1.0;", band || hp || s3 || ball,"gl_Position = uP * t;", - dim3 && !s3, "vColor.xyz = vColor.xyz * (1.0 - gl_Position.z / 2.0);", + dim3 && !s3, "vColor.xyz = vColor.xyz * (0.5 - gl_Position.z / 2.0);", 1, "}"), stringbuilder(