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"); }