mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-23 21:07:17 +00:00
fat edges in linepatterns in 3D
This commit is contained in:
parent
f20a6bf2f6
commit
9f947c70a7
@ -1214,6 +1214,36 @@ void geometry_information::make_3d_models() {
|
|||||||
finishshape();
|
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; 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
last->flags |= POLY_TRIANGLES;
|
||||||
|
add_texture(*last);
|
||||||
|
finishshape();
|
||||||
|
extra_vertices();
|
||||||
|
return pipe;
|
||||||
|
}
|
||||||
|
|
||||||
#undef S
|
#undef S
|
||||||
#undef SH
|
#undef SH
|
||||||
#undef revZ
|
#undef revZ
|
||||||
|
@ -298,6 +298,7 @@ EX void initConfig() {
|
|||||||
addsaver(vid.linewidth, "linewidth", 1);
|
addsaver(vid.linewidth, "linewidth", 1);
|
||||||
addsaver(precise_width, "precisewidth", .5);
|
addsaver(precise_width, "precisewidth", .5);
|
||||||
addsaver(linepatterns::width, "pattern-linewidth", 1);
|
addsaver(linepatterns::width, "pattern-linewidth", 1);
|
||||||
|
addsaver(fat_edges, "fat-edges");
|
||||||
addsaver(vid.scale, "scale", 1);
|
addsaver(vid.scale, "scale", 1);
|
||||||
addsaver(vid.xposition, "xposition", 0);
|
addsaver(vid.xposition, "xposition", 0);
|
||||||
addsaver(vid.yposition, "yposition", 0);
|
addsaver(vid.yposition, "yposition", 0);
|
||||||
|
@ -249,6 +249,8 @@ hpcshape
|
|||||||
shAnimatedEagle, shAnimatedTinyEagle, shAnimatedGadfly, shAnimatedHawk, shAnimatedButterfly,
|
shAnimatedEagle, shAnimatedTinyEagle, shAnimatedGadfly, shAnimatedHawk, shAnimatedButterfly,
|
||||||
shAnimatedGargoyle, shAnimatedGargoyle2, shAnimatedBat, shAnimatedBat2;
|
shAnimatedGargoyle, shAnimatedGargoyle2, shAnimatedBat, shAnimatedBat2;
|
||||||
|
|
||||||
|
map<int, hpcshape> shPipe;
|
||||||
|
|
||||||
vector<hpcshape> shPlainWall3D, shWireframe3D, shWall3D, shMiniWall3D;
|
vector<hpcshape> shPlainWall3D, shWireframe3D, shWall3D, shMiniWall3D;
|
||||||
vector<hyperpoint> walltester;
|
vector<hyperpoint> walltester;
|
||||||
|
|
||||||
@ -401,6 +403,8 @@ hpcshape
|
|||||||
void require_shapes() { if(state & 2) return; state |= 2; prepare_shapes(); }
|
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(); }
|
void require_usershapes() { if(usershape_state == usershape_changes) return; usershape_state = usershape_changes; prepare_usershapes(); }
|
||||||
int timestamp;
|
int timestamp;
|
||||||
|
|
||||||
|
hpcshape& generate_pipe(ld length, ld width);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
10
graph.cpp
10
graph.cpp
@ -3592,8 +3592,18 @@ EX ld precise_width = .5;
|
|||||||
|
|
||||||
int grid_depth = 0;
|
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) {
|
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);
|
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) {
|
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; }
|
if(!eqmatrix(V1, V2, 1e-6)) { gridline(V1, h1, V1, inverse(V1) * V2 * h2, col, prec); return; }
|
||||||
hyperpoint h = midz(h1, h2);
|
hyperpoint h = midz(h1, h2);
|
||||||
|
@ -2864,6 +2864,9 @@ EX namespace linepatterns {
|
|||||||
|
|
||||||
dialog::addBoolItem_action("edit widths individually", indiv, 'I');
|
dialog::addBoolItem_action("edit widths individually", indiv, 'I');
|
||||||
|
|
||||||
|
if(GDIM == 3)
|
||||||
|
dialog::addBoolItem_action("fat edges", fat_edges, 'F');
|
||||||
|
|
||||||
dialog::addBreak(50);
|
dialog::addBreak(50);
|
||||||
dialog::addInfo("change the alpha parameter to show the lines");
|
dialog::addInfo("change the alpha parameter to show the lines");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user