From f0a8bcd95e978480a1ef8a8a8f4a89b46bdc6e0d Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 25 Sep 2010 04:40:08 -0300 Subject: [PATCH] In POV-Ray output, move faces to more correct Z locations. - solidify/povray.c: update title for renaming - solidify/povray.c (povray_face, povray): flip the bottom face - solidify/povray.c (povray_face, povray): instead of centering the face on Z, shift it to its z0 position - solidify/povray.c (povray_face, povray): split the distance between faces equally among them --- solidify/povray.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/solidify/povray.c b/solidify/povray.c index 535108c..b31b853 100644 --- a/solidify/povray.c +++ b/solidify/povray.c @@ -1,5 +1,5 @@ /* - * solid.c - Data structure and handling of a solid made of two opposing faces + * povray.c - Generate POV-Ray output * * Written 2010 by Werner Almesberger * Copyright 2010 by Werner Almesberger @@ -70,7 +70,7 @@ static void sanitize(const char *s, char *res) */ static void povray_face(const struct face *f, const char *side, - const char *prefix) + const char *prefix, int flip, double dist) { int sz = f->a->max_z-f->a->min_z; @@ -86,9 +86,15 @@ static void povray_face(const struct face *f, const char *side, "\t scale <%g, %g, %g>\n" "\t rotate <90, 0, 0>\n" "\t translate <%g, %g, %g>\n" +"\t translate <0, 0, %g>\n" +"%s" /* flip bottom face */ +"\t translate <0, 0, %g>\n" "\t}\n", prefix, side, f->sx*f->x_step, sz*f->z_step, f->sy*f->y_step, - -f->sx*f->x_step/2, f->sy*f->y_step/2, -sz*f->z_step/2); + -f->sx*f->x_step/2, f->sy*f->y_step/2, f->a->min_z*f->z_step, + -f->z_ref*f->z_step, + flip ? "\t rotate <180, 0, 0>\n" : "", + dist*f->z_step); } @@ -108,7 +114,7 @@ void povray(const char *name, const struct solid *s) sanitize(name, tmp); printf("#declare Part_%s =\n intersection {\n", tmp); - povray_face(s->a, "top", name); - povray_face(s->b, "bot", name); + povray_face(s->a, "top", name, 0, s->dist/2); + povray_face(s->b, "bot", name, 1, -s->dist/2); printf(" }\n"); }