1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-29 19:40:35 +00:00

3d:: improved pipe texture

This commit is contained in:
Zeno Rogue 2022-07-14 11:09:25 +02:00
parent f101ddb7fd
commit 43ff375435

View File

@ -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; i<MAX_X; i++) {
for(int a=0; a<MAX_R; a++) {
hpcpush(at(i, a));
hpcpush(at(i, a+1));
hpcpush(at(i+1, a));
hpcpush(at(i+1, a+1));
hpcpush(at(i+1, a));
hpcpush(at(i, a+1));
at(i, a, 1);
at(i, a+1, 1);
at(i+1, a, 1);
at(i+1, a+1, 1);
at(i+1, a, 1);
at(i, a+1, 1);
}
}
for(int a=0; a<MAX_R; a++) {
hpcpush(at(MAX_X, a));
hpcpush(at(MAX_X, a+1));
hpcpush(xpush0(length));
hpcpush(at(MAX_X, a+1));
hpcpush(at(MAX_X, a));
hpcpush(C0);
for(int a=0; a<MAX_R; a++) for(int x: {0, MAX_X}) {
at(x, a, 1, 0);
at(x, a+1, 1, 0);
at(x, 0, 0, 0);
}
last->flags |= POLY_TRIANGLES | POLY_PRINTABLE;
add_texture(*last);
finishshape();
extra_vertices();
return pipe;