Ben NanoNote 3D scans
Sign in or create your account | Project List | Help
Ben NanoNote 3D scans Commit Details
Date: | 2010-09-25 07:44:59 (12 years 11 months ago) |
---|---|
Author: | Werner Almesberger |
Commit: | 286a6bdd092f2f77ac37f7f23c1d462988366528 |
Message: | Sanitize POV-Ray output (in progress) - solidify/main.pov: set up a more traditional view than POV-Ray's "camera" model - solidify/main.pov: mark the coordinate axes with colored balls - solidify/main.pov: make the part semi-transparent so that we can see the coordinate axes - solidify/solid.c (povray_face, povray): moved dumping a face from povray() to povray_face() - solidify/solid.c (povray_face): scale the height field to its real size - solidify/solid.c (povray_face): rotate the face such that height is Z - solidify/solid.c (povray_face): translate the face such that its center is at the origin |
Files: |
solidify/main.pov (1 diff) solidify/solid.c (2 diffs) |
Change Details
solidify/main.pov | ||
---|---|---|
1 | 1 | #include "colors.inc" |
2 | 2 | #include "batcvr.inc" |
3 | 3 | |
4 | /* | |
5 | * POV-Ray defaults to a "camera" coordinate system that can be confusing. | |
6 | * We use a traditional mathematical/engineering view, with a view from | |
7 | * X-/Y-/Z+ into the X/Y plane. | |
8 | */ | |
9 | ||
4 | 10 | camera { |
5 | location < 2, 2, 3> | |
6 | look_at < 0, 0, 0> | |
11 | location <-30, -80, 40> | |
12 | look_at <20, 20, 0> | |
13 | sky z | |
14 | right -4/3*x | |
7 | 15 | } |
8 | 16 | |
9 | 17 | background { color White } |
10 | 18 | |
11 | 19 | light_source { |
12 | < 4, 7, 4> | |
20 | <-200, -300, 200> | |
13 | 21 | color White |
14 | 22 | } |
15 | 23 | |
24 | /* | |
25 | * Mark the coordinate axes: | |
26 | * - a red unit sphere at the center | |
27 | * - three green spheres at x = 10*i | |
28 | * - two blue spheres at y = 10*i | |
29 | * - one yellow sphere at z = 10 | |
30 | */ | |
31 | ||
32 | sphere { < 0, 0, 0>, 1 pigment { color Red } } | |
33 | sphere { <10, 0, 0>, 1 pigment { color Green } } | |
34 | sphere { <20, 0, 0>, 1 pigment { color Green } } | |
35 | sphere { <30, 0, 0>, 1 pigment { color Green } } | |
36 | sphere { < 0, 10, 0>, 1 pigment { color Blue } } | |
37 | sphere { < 0, 20, 0>, 1 pigment { color Blue } } | |
38 | sphere { < 0, 0, 10>, 1 pigment { color Yellow } } | |
39 | ||
40 | #declare Finish = finish { | |
41 | brilliance 2 | |
42 | phong 0.8 | |
43 | phong_size 100 | |
44 | metallic | |
45 | } | |
46 | ||
16 | 47 | union { |
17 | 48 | Part_batcvr |
18 | pigment { rgb <0.9, 0.9, 0.9> } | |
19 | finish { | |
20 | brilliance 2 | |
21 | phong 0.8 | |
22 | phong_size 100 | |
23 | metallic | |
24 | } | |
49 | pigment { rgbf <0.9, 0.9, 0.9, 0.5> } | |
50 | finish { Finish } | |
25 | 51 | } |
solidify/solid.c | ||
---|---|---|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
66 | /* | |
67 | * For now, we put the part such that its x/y/z center is at the origin. | |
68 | * Later, we will also have to consider the changes the user made and the | |
69 | * relation with the opposing face. | |
70 | */ | |
71 | ||
72 | static void povray_face(const struct face *f, const char *side, | |
73 | const char *prefix) | |
74 | { | |
75 | int sz = f->a->max_z-f->a->min_z; | |
76 | ||
77 | /* | |
78 | * 1/65535 = 0.000015..., so we set the water level a bit lower, e.g., | |
79 | * to 0.0001 | |
80 | */ | |
81 | printf( | |
82 | "\theight_field {\n" | |
83 | "\t pgm \"%s-%s.pgm\"\n" | |
84 | "\t water_level 0.00001\n" | |
85 | "\t smooth\n" | |
86 | "\t scale <%g, %g, %g>\n" | |
87 | "\t rotate <90, 0, 0>\n" | |
88 | "\t translate <%g, %g, %g>\n" | |
89 | "\t}\n", prefix, side, | |
90 | f->sx*f->x_step, sz*f->z_step, f->sy*f->y_step, | |
91 | -f->sx*f->x_step/2, f->sy*f->y_step/2, -sz*f->z_step/2); | |
92 | } | |
93 | ||
94 | ||
66 | 95 | void povray(const char *name, const struct solid *s) |
67 | 96 | { |
68 | 97 | struct matrix m; |
... | ... | |
77 | 106 | sprintf(tmp, "%s-bot.pgm", name); |
78 | 107 | height_field(tmp, s->b, &m); |
79 | 108 | |
80 | /* | |
81 | * 1/65535 = 0.000015..., so we set the water level a bit lower, e.g., | |
82 | * to 0.0001 | |
83 | */ | |
84 | 109 | sanitize(name, tmp); |
85 | printf( | |
86 | "#declare Part_%s =\n" | |
87 | " intersection {\n" | |
88 | " height_field { pgm \"%s-top.pgm\" water_level 0.00001 smooth }\n" | |
89 | " height_field { pgm \"%s-bot.pgm\" water_level 0.00001 smooth }\n" | |
90 | " }\n", tmp, name, name); | |
110 | printf("#declare Part_%s =\n intersection {\n", tmp); | |
111 | povray_face(s->a, "top", name); | |
112 | povray_face(s->b, "bot", name); | |
113 | printf(" }\n"); | |
91 | 114 | } |
Branches:
master