From 43ff3754353ef8398cd1d9d2ab842a8031b9521d Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 14 Jul 2022 11:09:25 +0200 Subject: [PATCH] 3d:: improved pipe texture --- 3d-models.cpp | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/3d-models.cpp b/3d-models.cpp index 55b91763..6cf9d7a5 100644 --- a/3d-models.cpp +++ b/3d-models.cpp @@ -1242,33 +1242,41 @@ hpcshape& geometry_information::generate_pipe(ld length, ld width) { println(hlog, "generating pipe of length ", length, " and width ", width); bshape(pipe, PPR::WALL); +#if CAP_GL + auto& utt = models_texture; + if(floor_textures) { + pipe.tinf = &utt; + pipe.texture_offset = isize(utt.tvertices); + } +#endif + 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); + auto at = [&] (int i, int a, ld z = 1, ld s = 1) { + ld alpha = 360 * degree * a / MAX_R; + hpcpush(xpush(i * length / MAX_X) * cspin(1, 2, alpha) * ypush0(width*z)); + #if CAP_GL + if(floor_textures) utt.tvertices.push_back(glhr::makevertex(0, 0.55 + s * 0.45 * sin(alpha), 0)); + #endif }; for(int i=0; iflags |= POLY_TRIANGLES | POLY_PRINTABLE; - add_texture(*last); finishshape(); extra_vertices(); return pipe;