--- ray/src/util/genambpos.pl 2014/05/01 04:51:12 2.5 +++ ray/src/util/genambpos.pl 2022/02/15 04:08:26 2.11 @@ -1,9 +1,11 @@ #!/usr/bin/perl -w -# RCSid $Id: genambpos.pl,v 2.5 2014/05/01 04:51:12 greg Exp $ +# RCSid $Id: genambpos.pl,v 2.11 2022/02/15 04:08:26 greg Exp $ # # Visualize ambient positions and gradients # use strict; +my $windoz = ($^O eq "MSWin32" or $^O eq "MSWin64"); +die "Not supported under Windows -- sorry!\n" if ( $windoz ); sub userror { print STDERR "Usage: genambpos [-l lvl][-w minwt][-r rad][-s sf][-p][-d] scene.amb > ambloc.rad\n"; exit 1; @@ -45,6 +47,7 @@ my $cmd = "getinfo < $ARGV[0] " . q[| sed -n 's/^.* -aa \([.0-9][^ ]*\) .*$/\1/p']; my $ambacc=`$cmd`; die "Missing -aa setting in header\n" if (! $ambacc ); +die "Zero -aa setting in header\n" if ($ambacc <= .00001); $scale *= $ambacc; my $ambfmt = ' void glow posglow @@ -55,7 +58,7 @@ void glow posglow posglow sphere position${recno} 0 0 -4 ${px} ${py} ${pz} ${psiz} +4 ${ px } ${ py } ${ pz } ${ psiz } '; my $posgradfmt = ' void glow arrglow @@ -67,15 +70,20 @@ arrglow cone pgarrow${recno} 0 0 8 - ${ cx0 } ${ cy0 } ${ cz0 } - ${ cx1 } ${ cy1 } ${ cz1 } - ${ cr0 } 0 + ${ cx0 } ${ cy0 } ${ cz0 } + ${ cx1 } ${ cy1 } ${ cz1 } + ${ cr0 } 0 void brightfunc pgpat 2 posfunc ambpos.cal 0 6 ${ px } ${ py } ${ pz } ${ pgx } ${ pgy } ${ pgz } +pgpat colorfunc pgpat +4 1 if(corralled,.1,1) if(corralled,.1,1) ambpos.cal +0 +7 ${ px } ${ py } ${ pz } ${ ux } ${ uy } ${ uz } ${ cflags } + pgpat glow pgval 0 0 @@ -90,10 +98,10 @@ pgeval polygon pgellipse${recno} 0 0 12 - ${ px1 } ${ py1 } ${ pz1 } - ${ px2 } ${ py2 } ${ pz2 } - ${ px3 } ${ py3 } ${ pz3 } - ${ px4 } ${ py4 } ${ pz4 } + ${ px1 } ${ py1 } ${ pz1 } + ${ px2 } ${ py2 } ${ pz2 } + ${ px3 } ${ py3 } ${ pz3 } + ${ px4 } ${ py4 } ${ pz4 } '; $posgradfmt .= ' void glow tipglow @@ -101,10 +109,10 @@ void glow tipglow 0 4 ${2*agr} ${2*agg} ${2*agb} 0 -tipglow sphere atip +tipglow sphere atip${recno} 0 0 -4 ${ cx1 } ${ cy1 } ${ cz1 } ${psiz/7} +4 ${ cx1 } ${ cy1 } ${ cz1 } ${psiz/7} ' if ($dodirgrad); my $dirgradfmt=' void brightfunc dgpat @@ -121,17 +129,17 @@ dgval ring dgdisk${recno}a 0 0 8 - ${ px+dgx*.001 } ${ py+dgy*.001 } ${ pz+dgz*.001 } + ${ px+dgx/dg*eps*.5 } ${ py+dgy/dg*eps*.5 } ${ pz+dgz/dg*eps*.5 } ${ dgx } ${ dgy } ${ dgz } - 0 ${ r0/2 } + 0 ${ r0/2 } dgval ring dgdisk${recno}b 0 0 8 - ${ px-dgx*.001 } ${ py-dgy*.001 } ${ pz-dgz*.001 } + ${ px-dgx/dg*eps*.5 } ${ py-dgy/dg*eps*.5 } ${ pz-dgz/dg*eps*.5 } ${ -dgx } ${ -dgy } ${ -dgz } - 0 ${ r0/2 } + 0 ${ r0/2 } '; # Load & convert ambient values print "# Output produced by: $savedARGV\n";