1
0
mirror of git://projects.qi-hardware.com/ben-scans.git synced 2024-11-21 21:45:55 +02:00

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
This commit is contained in:
Werner Almesberger 2010-09-25 02:44:59 -03:00
parent 01d8e411f3
commit 286a6bdd09
2 changed files with 69 additions and 20 deletions

View File

@ -1,25 +1,51 @@
#include "colors.inc"
#include "batcvr.inc"
/*
* POV-Ray defaults to a "camera" coordinate system that can be confusing.
* We use a traditional mathematical/engineering view, with a view from
* X-/Y-/Z+ into the X/Y plane.
*/
camera {
location < 2, 2, 3>
look_at < 0, 0, 0>
location <-30, -80, 40>
look_at <20, 20, 0>
sky z
right -4/3*x
}
background { color White }
light_source {
< 4, 7, 4>
<-200, -300, 200>
color White
}
/*
* Mark the coordinate axes:
* - a red unit sphere at the center
* - three green spheres at x = 10*i
* - two blue spheres at y = 10*i
* - one yellow sphere at z = 10
*/
sphere { < 0, 0, 0>, 1 pigment { color Red } }
sphere { <10, 0, 0>, 1 pigment { color Green } }
sphere { <20, 0, 0>, 1 pigment { color Green } }
sphere { <30, 0, 0>, 1 pigment { color Green } }
sphere { < 0, 10, 0>, 1 pigment { color Blue } }
sphere { < 0, 20, 0>, 1 pigment { color Blue } }
sphere { < 0, 0, 10>, 1 pigment { color Yellow } }
#declare Finish = finish {
brilliance 2
phong 0.8
phong_size 100
metallic
}
union {
Part_batcvr
pigment { rgb <0.9, 0.9, 0.9> }
finish {
brilliance 2
phong 0.8
phong_size 100
metallic
}
pigment { rgbf <0.9, 0.9, 0.9, 0.5> }
finish { Finish }
}

View File

@ -63,6 +63,35 @@ static void sanitize(const char *s, char *res)
}
/*
* For now, we put the part such that its x/y/z center is at the origin.
* Later, we will also have to consider the changes the user made and the
* relation with the opposing face.
*/
static void povray_face(const struct face *f, const char *side,
const char *prefix)
{
int sz = f->a->max_z-f->a->min_z;
/*
* 1/65535 = 0.000015..., so we set the water level a bit lower, e.g.,
* to 0.0001
*/
printf(
"\theight_field {\n"
"\t pgm \"%s-%s.pgm\"\n"
"\t water_level 0.00001\n"
"\t smooth\n"
"\t scale <%g, %g, %g>\n"
"\t rotate <90, 0, 0>\n"
"\t translate <%g, %g, %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);
}
void povray(const char *name, const struct solid *s)
{
struct matrix m;
@ -77,15 +106,9 @@ void povray(const char *name, const struct solid *s)
sprintf(tmp, "%s-bot.pgm", name);
height_field(tmp, s->b, &m);
/*
* 1/65535 = 0.000015..., so we set the water level a bit lower, e.g.,
* to 0.0001
*/
sanitize(name, tmp);
printf(
"#declare Part_%s =\n"
" intersection {\n"
" height_field { pgm \"%s-top.pgm\" water_level 0.00001 smooth }\n"
" height_field { pgm \"%s-bot.pgm\" water_level 0.00001 smooth }\n"
" }\n", tmp, name, name);
printf("#declare Part_%s =\n intersection {\n", tmp);
povray_face(s->a, "top", name);
povray_face(s->b, "bot", name);
printf(" }\n");
}