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][-s scale][-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 $savedARGV = "genambpos @ARGV"; |
17 |
|
# Get options |
18 |
|
while ($#ARGV >= 0) { |
23 |
|
} elsif ("$ARGV[0]" =~ /^-l/) { |
24 |
|
$lvlsel = $ARGV[1]; |
25 |
|
shift @ARGV; |
26 |
+ |
} elsif ("$ARGV[0]" =~ /^-w/) { |
27 |
+ |
$minwt = $ARGV[1]; |
28 |
+ |
shift @ARGV; |
29 |
|
} elsif ("$ARGV[0]" =~ /^-s/) { |
30 |
|
$scale = $ARGV[1]; |
31 |
|
shift @ARGV; |
38 |
|
} |
39 |
|
userror() if ($#ARGV != 0); |
40 |
|
my $cmd = "getinfo < $ARGV[0] " . |
41 |
< |
q[| sed -n 's/^.* -aa \([.0-9][.0-9]*\) .*$/\1/p']; |
41 |
> |
q[| sed -n 's/^.* -aa \([.0-9][^ ]*\) .*$/\1/p']; |
42 |
|
my $ambacc=`$cmd`; |
43 |
|
die "Missing -aa setting in header\n" if (! $ambacc ); |
44 |
< |
$scale *= $ambacc**.25; |
45 |
< |
my $outfmt = ' |
44 |
> |
$scale *= $ambacc; |
45 |
> |
my $ambfmt = ' |
46 |
|
void glow posglow |
47 |
|
0 |
48 |
|
0 |
52 |
|
0 |
53 |
|
0 |
54 |
|
4 ${px} ${py} ${pz} ${psiz} |
55 |
+ |
'; |
56 |
+ |
my $posgradfmt = ' |
57 |
+ |
void glow arrglow |
58 |
+ |
0 |
59 |
+ |
0 |
60 |
+ |
4 ${wt*agr} ${wt*agg} ${wt*agb} 0 |
61 |
|
|
62 |
< |
posglow cone pgarrow${recno} |
62 |
> |
arrglow cone pgarrow${recno} |
63 |
|
0 |
64 |
|
0 |
65 |
|
8 |
66 |
|
${ cx0 } ${ cy0 } ${ cz0 } |
67 |
|
${ cx1 } ${ cy1 } ${ cz1 } |
68 |
|
${ cr0 } 0 |
69 |
< |
'; |
60 |
< |
my $posgradfmt = ' |
69 |
> |
|
70 |
|
void brightfunc pgpat |
71 |
|
2 posfunc ambpos.cal |
72 |
|
0 |
91 |
|
${ px3 } ${ py3 } ${ pz3 } |
92 |
|
${ px4 } ${ py4 } ${ pz4 } |
93 |
|
'; |
94 |
< |
$outfmt .= $posgradfmt if ($doposgrad); |
86 |
< |
my $dirgradfmt=' |
94 |
> |
$posgradfmt .= ' |
95 |
|
void glow tipglow |
96 |
|
0 |
97 |
|
0 |
101 |
|
0 |
102 |
|
0 |
103 |
|
4 ${ cx1 } ${ cy1 } ${ cz1 } ${psiz/7} |
104 |
< |
|
104 |
> |
' if ($dodirgrad); |
105 |
> |
my $dirgradfmt=' |
106 |
|
void brightfunc dgpat |
107 |
|
2 dirfunc ambpos.cal |
108 |
|
0 |
117 |
|
0 |
118 |
|
0 |
119 |
|
8 |
120 |
< |
${ px+dgx*.0001 } ${ py+dgy*.0001 } ${ pz+dgz*.0001 } |
120 |
> |
${ px+dgx*.001 } ${ py+dgy*.001 } ${ pz+dgz*.001 } |
121 |
|
${ dgx } ${ dgy } ${ dgz } |
122 |
|
0 ${ r0/2 } |
123 |
|
|
125 |
|
0 |
126 |
|
0 |
127 |
|
8 |
128 |
< |
${ px-dgx*.0001 } ${ py-dgy*.0001 } ${ pz-dgz*.0001 } |
128 |
> |
${ px-dgx*.001 } ${ py-dgy*.001 } ${ pz-dgz*.001 } |
129 |
|
${ -dgx } ${ -dgy } ${ -dgz } |
130 |
|
0 ${ r0/2 } |
131 |
|
'; |
123 |
– |
$outfmt .= $dirgradfmt if ($dodirgrad); |
132 |
|
# Load & convert ambient values |
133 |
|
print "# Output produced by: $savedARGV\n"; |
134 |
< |
system "lookamb -h -d $ARGV[0] | rcalc -e 'LV:$lvlsel;SF:$scale' -f rambpos.cal -o '$outfmt'\n"; |
134 |
> |
system "lookamb -h -d $ARGV[0] | rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" . |
135 |
> |
" -f rambpos.cal -e cond=acond -o '$ambfmt'"; |
136 |
> |
if ($doposgrad) { |
137 |
> |
system "lookamb -h -d $ARGV[0] " . |
138 |
> |
"| rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" . |
139 |
> |
" -f rambpos.cal -e cond=pcond -o '$posgradfmt'"; |
140 |
> |
} |
141 |
> |
if ($dodirgrad) { |
142 |
> |
system "lookamb -h -d $ARGV[0] " . |
143 |
> |
"| rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" . |
144 |
> |
" -f rambpos.cal -e cond=dcond -o '$dirgradfmt'"; |
145 |
> |
} |
146 |
|
exit; |