From 9f947c70a7fa6d519b51cc57f4d58e494edb48b9 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 26 Jan 2020 00:48:56 +0100 Subject: [PATCH] fat edges in linepatterns in 3D --- 3d-models.cpp | 30 ++++++++++++++++++++++++++++++ config.cpp | 1 + geometry.cpp | 4 ++++ graph.cpp | 10 ++++++++++ pattern2.cpp | 5 ++++- 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/3d-models.cpp b/3d-models.cpp index 76c0d4e7..30c60e17 100644 --- a/3d-models.cpp +++ b/3d-models.cpp @@ -1214,6 +1214,36 @@ void geometry_information::make_3d_models() { finishshape(); } +hpcshape& geometry_information::generate_pipe(ld length, ld width) { + int id = int(length * 17 + .5) + int(157003 * log(width+.001)); + if(shPipe.count(id)) return shPipe[id]; + hpcshape& pipe = shPipe[id]; + println(hlog, "generating pipe of length ", length, " and width ", width); + bshape(pipe, PPR::WALL); + + const int MAX_X = 8; + const int MAX_R = 20; + auto at = [length, width] (int i, int a) { + return xpush(i * length / MAX_X) * cspin(1, 2, 360 * degree * a / MAX_R) * ypush0(width); + }; + for(int i=0; iflags |= POLY_TRIANGLES; + add_texture(*last); + finishshape(); + extra_vertices(); + return pipe; + } + #undef S #undef SH #undef revZ diff --git a/config.cpp b/config.cpp index 82dc823f..b05209c7 100644 --- a/config.cpp +++ b/config.cpp @@ -298,6 +298,7 @@ EX void initConfig() { addsaver(vid.linewidth, "linewidth", 1); addsaver(precise_width, "precisewidth", .5); addsaver(linepatterns::width, "pattern-linewidth", 1); + addsaver(fat_edges, "fat-edges"); addsaver(vid.scale, "scale", 1); addsaver(vid.xposition, "xposition", 0); addsaver(vid.yposition, "yposition", 0); diff --git a/geometry.cpp b/geometry.cpp index b9b91e2f..61a94917 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -249,6 +249,8 @@ hpcshape shAnimatedEagle, shAnimatedTinyEagle, shAnimatedGadfly, shAnimatedHawk, shAnimatedButterfly, shAnimatedGargoyle, shAnimatedGargoyle2, shAnimatedBat, shAnimatedBat2; + map shPipe; + vector shPlainWall3D, shWireframe3D, shWall3D, shMiniWall3D; vector walltester; @@ -401,6 +403,8 @@ hpcshape void require_shapes() { if(state & 2) return; state |= 2; prepare_shapes(); } void require_usershapes() { if(usershape_state == usershape_changes) return; usershape_state = usershape_changes; prepare_usershapes(); } int timestamp; + + hpcshape& generate_pipe(ld length, ld width); }; #endif diff --git a/graph.cpp b/graph.cpp index 7a730a7f..3bafafef 100644 --- a/graph.cpp +++ b/graph.cpp @@ -3592,8 +3592,18 @@ EX ld precise_width = .5; int grid_depth = 0; +EX bool fat_edges = false; + EX void gridline(const transmatrix& V1, const hyperpoint h1, const transmatrix& V2, const hyperpoint h2, color_t col, int prec) { ld d = hdist(V1*h1, V2*h2); + + if(WDIM == 3 && fat_edges) { + transmatrix T = V1 * rgpushxto0(h1); + transmatrix S = rspintox(inverse(T) * V2 * h2); + queuepoly(T * S, cgi.generate_pipe(d, vid.linewidth), col); + return; + } + while(d > precise_width && d < 100 && grid_depth < 10) { if(!eqmatrix(V1, V2, 1e-6)) { gridline(V1, h1, V1, inverse(V1) * V2 * h2, col, prec); return; } hyperpoint h = midz(h1, h2); diff --git a/pattern2.cpp b/pattern2.cpp index 326c7dab..efdae879 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -2863,7 +2863,10 @@ EX namespace linepatterns { }); dialog::addBoolItem_action("edit widths individually", indiv, 'I'); - + + if(GDIM == 3) + dialog::addBoolItem_action("fat edges", fat_edges, 'F'); + dialog::addBreak(50); dialog::addInfo("change the alpha parameter to show the lines");