--- ray/src/util/genambpos.pl 2014/05/01 02:52:03 2.4 +++ ray/src/util/genambpos.pl 2014/09/03 14:05:55 2.9 @@ -1,11 +1,11 @@ #!/usr/bin/perl -w -# RCSid $Id: genambpos.pl,v 2.4 2014/05/01 02:52:03 greg Exp $ +# RCSid $Id: genambpos.pl,v 2.9 2014/09/03 14:05:55 greg Exp $ # # Visualize ambient positions and gradients # use strict; sub userror { - print STDERR "Usage: genambpos [-l lvl][-w minwt][-s scale][-p][-d] scene.amb > ambloc.rad\n"; + print STDERR "Usage: genambpos [-l lvl][-w minwt][-r rad][-s sf][-p][-d] scene.amb > ambloc.rad\n"; exit 1; } my $lvlsel = -1; @@ -13,6 +13,7 @@ my $scale = 0.25; my $doposgrad = 0; my $dodirgrad = 0; my $minwt = 0.5001**6; +my $fixedrad=""; my $savedARGV = "genambpos @ARGV"; # Get options while ($#ARGV >= 0) { @@ -29,6 +30,9 @@ while ($#ARGV >= 0) { } elsif ("$ARGV[0]" =~ /^-s/) { $scale = $ARGV[1]; shift @ARGV; + } elsif ("$ARGV[0]" =~ /^-r/) { + $fixedrad = "-e psiz:$ARGV[1]"; + shift @ARGV; } elsif ("$ARGV[0]" =~ /^-./) { userror(); } else { @@ -41,6 +45,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 @@ -51,7 +56,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 @@ -63,15 +68,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 @@ -86,10 +96,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 @@ -100,7 +110,7 @@ void glow tipglow tipglow sphere atip 0 0 -4 ${ cx1 } ${ cy1 } ${ cz1 } ${psiz/7} +4 ${ cx1 } ${ cy1 } ${ cz1 } ${psiz/7} ' if ($dodirgrad); my $dirgradfmt=' void brightfunc dgpat @@ -117,26 +127,26 @@ 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"; system "lookamb -h -d $ARGV[0] | rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" . - " -f rambpos.cal -e cond=acond -o '$ambfmt'"; + " -f rambpos.cal -e cond=acond $fixedrad -o '$ambfmt'"; if ($doposgrad) { system "lookamb -h -d $ARGV[0] " . "| rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" . - " -f rambpos.cal -e cond=pcond -o '$posgradfmt'"; + " -f rambpos.cal -e cond=pcond $fixedrad -o '$posgradfmt'"; } if ($dodirgrad) { system "lookamb -h -d $ARGV[0] " .