#! /usr/bin/gawk -f # Last edited on 1999-02-13 21:03:44 by stolfi BEGIN { abort = -1; usage = ( \ "pebbles-make.awk \\\n" \ " > pebbles.incx" \ ); # Generates a POVRay "#include" file that defines the pebbles # expected by ring.incx, namely pebble_K_NN where # K is a color gun index (0..2) and NN an age index (00..15). nAges = 16; core_y_fin = 0.50 core_y_mid = (2-core_y_fin)+2*sqrt(1-core_y_fin); make_pebbles(); } function make_pebbles( gun,age) { # Writes a POV include file to standard output. write_pov_header(); for (gun=0; gun<3; gun++) { for (age=0; age 1) { sy = 1; } if (sy < 0) { sy = 0; } # pebble color "sr,sg,sb": sr = (1-sy)*0.15 + sy*r; sg = (1-sy)*0.15 + sy*g; sb = (1-sy)*0.15 + sy*b; # pebble finish "amb,dif,spc": amb = sy; dif = 0.90*(1 - amb); spc = 0.50*(1 - amb); # pebble thickness "sz" # sz = 0.33333 + 0.33333*t; sz = 0.33333; # halo radius "hrad" # hrad = 2.5*t; hrad = 0; # extra halo luminosity "hy" hy = 0.5*t; # halo color "hr,hg,hb": hr = (1-hy)*r + hy; hg = (1-hy)*g + hy; hb = (1-hy)*b + hy; printf "#declare pebble_%d_%02d = %s\n", gun, age, (hrad > sz ? "union{" : ""); printf " sphere{ <0,0,0>, 1\n"; printf " texture{\n"; printf " pigment { color rgb < %5.3f, %5.3f, %5.3f > }\n", sr, sg, sb; printf " finish { ambient %5.3f diffuse %5.3f specular %5.3f roughness 0.01 }\n", \ amb, dif, spc; printf " }\n"; printf " scale <1.00,1.00,%.2f>\n", sz; printf " }\n"; if (hrad > sz) { printf " sphere{ <0,0,0>, 1 hollow\n"; printf " pigment { color rgbt <1,1,1,1> }\n"; printf " interior{ \n"; printf " media{ \n"; printf " emission rgb <%5.3f, %5.3f, %5.3f>\n", hr, hg, hb; printf " density{ spherical scallop_wave }\n"; printf " }\n"; printf " }\n"; printf " scale %5.3f\n", hrad; printf " }\n"; } if (hrad > sz) { printf "}\n"; } printf "\n"; } function write_pov_tailer() { printf "// Done.\n"; } function arg_error(msg) { printf "*** %s\n", msg > "/dev/stderr"; abort = 1; exit abort; }