5 |
|
# |
6 |
|
use strict; |
7 |
|
sub userror { |
8 |
< |
print STDERR "Usage: genambpos [-l lvl][-w minwt][-s scale][-p][-d] scene.amb > ambloc.rad\n"; |
8 |
> |
print STDERR "Usage: genambpos [-l lvl][-w minwt][-r rad][-s sf][-p][-d] scene.amb > ambloc.rad\n"; |
9 |
|
exit 1; |
10 |
|
} |
11 |
|
my $lvlsel = -1; |
13 |
|
my $doposgrad = 0; |
14 |
|
my $dodirgrad = 0; |
15 |
|
my $minwt = 0.5001**6; |
16 |
+ |
my $fixedrad=""; |
17 |
|
my $savedARGV = "genambpos @ARGV"; |
18 |
|
# Get options |
19 |
|
while ($#ARGV >= 0) { |
30 |
|
} elsif ("$ARGV[0]" =~ /^-s/) { |
31 |
|
$scale = $ARGV[1]; |
32 |
|
shift @ARGV; |
33 |
+ |
} elsif ("$ARGV[0]" =~ /^-r/) { |
34 |
+ |
$fixedrad = "-e psiz:$ARGV[1]"; |
35 |
+ |
shift @ARGV; |
36 |
|
} elsif ("$ARGV[0]" =~ /^-./) { |
37 |
|
userror(); |
38 |
|
} else { |
45 |
|
q[| sed -n 's/^.* -aa \([.0-9][^ ]*\) .*$/\1/p']; |
46 |
|
my $ambacc=`$cmd`; |
47 |
|
die "Missing -aa setting in header\n" if (! $ambacc ); |
48 |
+ |
die "Zero -aa setting in header\n" if ($ambacc <= .00001); |
49 |
|
$scale *= $ambacc; |
50 |
|
my $ambfmt = ' |
51 |
|
void glow posglow |
56 |
|
posglow sphere position${recno} |
57 |
|
0 |
58 |
|
0 |
59 |
< |
4 ${px} ${py} ${pz} ${psiz} |
59 |
> |
4 ${ px } ${ py } ${ pz } ${ psiz } |
60 |
|
'; |
61 |
|
my $posgradfmt = ' |
62 |
|
void glow arrglow |
105 |
|
tipglow sphere atip |
106 |
|
0 |
107 |
|
0 |
108 |
< |
4 ${ cx1 } ${ cy1 } ${ cz1 } ${psiz/7} |
108 |
> |
4 ${ cx1 } ${ cy1 } ${ cz1 } ${psiz/7} |
109 |
|
' if ($dodirgrad); |
110 |
|
my $dirgradfmt=' |
111 |
|
void brightfunc dgpat |
137 |
|
# Load & convert ambient values |
138 |
|
print "# Output produced by: $savedARGV\n"; |
139 |
|
system "lookamb -h -d $ARGV[0] | rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" . |
140 |
< |
" -f rambpos.cal -e cond=acond -o '$ambfmt'"; |
140 |
> |
" -f rambpos.cal -e cond=acond $fixedrad -o '$ambfmt'"; |
141 |
|
if ($doposgrad) { |
142 |
|
system "lookamb -h -d $ARGV[0] " . |
143 |
|
"| rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" . |
144 |
< |
" -f rambpos.cal -e cond=pcond -o '$posgradfmt'"; |
144 |
> |
" -f rambpos.cal -e cond=pcond $fixedrad -o '$posgradfmt'"; |
145 |
|
} |
146 |
|
if ($dodirgrad) { |
147 |
|
system "lookamb -h -d $ARGV[0] " . |