From 8335a271afb988437ef6224f5d3cce75ffb74dd4 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Wed, 23 Sep 2020 00:32:47 +0200 Subject: [PATCH] First playing with wireframe Added some smoothing for spheres and cylinders --- wireframe.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/wireframe.c b/wireframe.c index 3f69dec..bfeb1ba 100644 --- a/wireframe.c +++ b/wireframe.c @@ -222,7 +222,6 @@ int main(void) const stl_header_t * const hdr = (const void*) buf; const stl_face_t * const stl_faces = (const void*)(hdr+1); const int num_triangles = hdr->num_triangles; - const float thick = 7.8; const int do_square = 1; fprintf(stderr, "header: '%s'\n", hdr->header); @@ -295,17 +294,21 @@ int main(void) } fprintf(stderr, "%d unique vertices\n", num_vertex); - printf("thick=%f;\n" + printf("thick=1.0;\n" + "radius=1.0;\n" + "leg_height=1.0;\n" + "wall=0.5;\n" + "smooth=100;\n" + "leglen_percentage=0.48;\n" "module connector(len) {\n" " render() difference() {\n" - " cylinder(r=thick/2+2, h=2*thick);\n" + " cylinder(r=thick/2+wall, h=leg_height*thick, $fn=smooth);\n" //" translate([0,0,len/2+2]) cube([thick,thick,2*thick]);\n" - " translate([0,0,thick/2+2]) cylinder(r=thick/2, h=2*thick);\n" + " translate([0,0,thick/2+2]) cylinder(r=thick/2, h=2*thick, $fn=smooth);\n" " }\n" //" %%translate([0,0,len*0.48/2]) cube([thick,thick,len*0.48], center=true);\n" - " %%translate([0,0,0]) cylinder(r=thick/2, h=len*0.48);\n" - "}\n", - thick + " %%translate([0,0,0]) cylinder(r=thick/2, h=len*leglen_percentage, $fn=smooth);\n" + "}\n" ); for (int i = 0 ; i < num_vertex ; i++) @@ -317,7 +320,7 @@ int main(void) v->p.p[2] ); - printf("sphere(r=%f); // %d %p\n", thick/2+2, i, v); + printf("sphere(radius, $fn=smooth); // %d %p\n", i, v); for (int j = 0 ; j < v->num_edges ; j++) { @@ -333,7 +336,7 @@ int main(void) if (do_square) printf("connector(%f);\n", len); else - printf(" cylinder(r=1, h=%f); // %p\n", + printf(" cylinder(r=1, h=%f, $fn=smooth); // %p\n", len*.45, v2 );