| 5 |
|
# |
| 6 |
|
use strict; |
| 7 |
|
sub userror { |
| 8 |
< |
print STDERR "Usage: genambpos [-l lvl][-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; |
| 12 |
|
my $scale = 0.25; |
| 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) { |
| 24 |
|
} elsif ("$ARGV[0]" =~ /^-l/) { |
| 25 |
|
$lvlsel = $ARGV[1]; |
| 26 |
|
shift @ARGV; |
| 27 |
+ |
} elsif ("$ARGV[0]" =~ /^-w/) { |
| 28 |
+ |
$minwt = $ARGV[1]; |
| 29 |
+ |
shift @ARGV; |
| 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 { |
| 42 |
|
} |
| 43 |
|
userror() if ($#ARGV != 0); |
| 44 |
|
my $cmd = "getinfo < $ARGV[0] " . |
| 45 |
< |
q[| sed -n 's/^.* -aa \([.0-9][.0-9]*\) .*$/\1/p']; |
| 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 |
< |
$scale *= $ambacc**.25; |
| 49 |
< |
my $outfmt = ' |
| 48 |
> |
$scale *= $ambacc; |
| 49 |
> |
my $ambfmt = ' |
| 50 |
|
void glow posglow |
| 51 |
|
0 |
| 52 |
|
0 |
| 56 |
|
0 |
| 57 |
|
0 |
| 58 |
|
4 ${px} ${py} ${pz} ${psiz} |
| 59 |
+ |
'; |
| 60 |
+ |
my $posgradfmt = ' |
| 61 |
+ |
void glow arrglow |
| 62 |
+ |
0 |
| 63 |
+ |
0 |
| 64 |
+ |
4 ${wt*agr} ${wt*agg} ${wt*agb} 0 |
| 65 |
|
|
| 66 |
< |
posglow cone pgarrow${recno} |
| 66 |
> |
arrglow cone pgarrow${recno} |
| 67 |
|
0 |
| 68 |
|
0 |
| 69 |
|
8 |
| 70 |
|
${ cx0 } ${ cy0 } ${ cz0 } |
| 71 |
|
${ cx1 } ${ cy1 } ${ cz1 } |
| 72 |
|
${ cr0 } 0 |
| 73 |
< |
'; |
| 60 |
< |
my $posgradfmt = ' |
| 73 |
> |
|
| 74 |
|
void brightfunc pgpat |
| 75 |
|
2 posfunc ambpos.cal |
| 76 |
|
0 |
| 95 |
|
${ px3 } ${ py3 } ${ pz3 } |
| 96 |
|
${ px4 } ${ py4 } ${ pz4 } |
| 97 |
|
'; |
| 98 |
< |
$outfmt .= $posgradfmt if ($doposgrad); |
| 86 |
< |
my $dirgradfmt=' |
| 98 |
> |
$posgradfmt .= ' |
| 99 |
|
void glow tipglow |
| 100 |
|
0 |
| 101 |
|
0 |
| 105 |
|
0 |
| 106 |
|
0 |
| 107 |
|
4 ${ cx1 } ${ cy1 } ${ cz1 } ${psiz/7} |
| 108 |
< |
|
| 108 |
> |
' if ($dodirgrad); |
| 109 |
> |
my $dirgradfmt=' |
| 110 |
|
void brightfunc dgpat |
| 111 |
|
2 dirfunc ambpos.cal |
| 112 |
|
0 |
| 121 |
|
0 |
| 122 |
|
0 |
| 123 |
|
8 |
| 124 |
< |
${ px+dgx*.0001 } ${ py+dgy*.0001 } ${ pz+dgz*.0001 } |
| 124 |
> |
${ px+dgx*.001 } ${ py+dgy*.001 } ${ pz+dgz*.001 } |
| 125 |
|
${ dgx } ${ dgy } ${ dgz } |
| 126 |
|
0 ${ r0/2 } |
| 127 |
|
|
| 129 |
|
0 |
| 130 |
|
0 |
| 131 |
|
8 |
| 132 |
< |
${ px-dgx*.0001 } ${ py-dgy*.0001 } ${ pz-dgz*.0001 } |
| 132 |
> |
${ px-dgx*.001 } ${ py-dgy*.001 } ${ pz-dgz*.001 } |
| 133 |
|
${ -dgx } ${ -dgy } ${ -dgz } |
| 134 |
|
0 ${ r0/2 } |
| 135 |
|
'; |
| 123 |
– |
$outfmt .= $dirgradfmt if ($dodirgrad); |
| 136 |
|
# Load & convert ambient values |
| 137 |
|
print "# Output produced by: $savedARGV\n"; |
| 138 |
< |
system "lookamb -h -d $ARGV[0] | rcalc -e 'LV:$lvlsel;SF:$scale' -f rambpos.cal -o '$outfmt'\n"; |
| 138 |
> |
system "lookamb -h -d $ARGV[0] | rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" . |
| 139 |
> |
" -f rambpos.cal -e cond=acond $fixedrad -o '$ambfmt'"; |
| 140 |
> |
if ($doposgrad) { |
| 141 |
> |
system "lookamb -h -d $ARGV[0] " . |
| 142 |
> |
"| rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" . |
| 143 |
> |
" -f rambpos.cal -e cond=pcond $fixedrad -o '$posgradfmt'"; |
| 144 |
> |
} |
| 145 |
> |
if ($dodirgrad) { |
| 146 |
> |
system "lookamb -h -d $ARGV[0] " . |
| 147 |
> |
"| rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" . |
| 148 |
> |
" -f rambpos.cal -e cond=dcond -o '$dirgradfmt'"; |
| 149 |
> |
} |
| 150 |
|
exit; |