ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/genambpos.pl
(Generate patch)

Comparing ray/src/util/genambpos.pl (file contents):
Revision 2.1 by greg, Thu Apr 24 23:15:42 2014 UTC vs.
Revision 2.8 by greg, Thu May 15 17:30:53 2014 UTC

# Line 5 | Line 5
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) {
# Line 22 | Line 24 | 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 {
# Line 34 | Line 42 | while ($#ARGV >= 0) {
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 > die "Zero -aa setting in header\n" if ($ambacc <= .00001);
49 > $scale *= $ambacc;
50 > my $ambfmt = '
51   void glow posglow
52   0
53   0
# Line 47 | Line 56 | 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
63 > 0
64 > 0
65 > 4 ${wt*agr} ${wt*agg} ${wt*agb} 0
66  
67 < posglow cone pgarrow${recno}
67 > arrglow cone pgarrow${recno}
68   0
69   0
70   8
71 <        ${ cx0 }        ${ cy0 }        ${ cz0 }
72 <        ${ cx1 }        ${ cy1 }        ${ cz1 }
73 <        ${ cr0 }        0
74 < ';
60 < my $posgradfmt = '
71 >        ${    cx0    }  ${    cy0    }  ${    cz0    }
72 >        ${    cx1    }  ${    cy1    }  ${    cz1    }
73 >        ${   cr0   }    0
74 >
75   void brightfunc pgpat
76   2 posfunc ambpos.cal
77   0
# Line 77 | Line 91 | pgeval polygon pgellipse${recno}
91   0
92   0
93   12
94 <        ${ px1 } ${ py1 } ${ pz1 }
95 <        ${ px2 } ${ py2 } ${ pz2 }
96 <        ${ px3 } ${ py3 } ${ pz3 }
97 <        ${ px4 } ${ py4 } ${ pz4 }
94 >        ${   px1   } ${   py1   } ${   pz1   }
95 >        ${   px2   } ${   py2   } ${   pz2   }
96 >        ${   px3   } ${   py3   } ${   pz3   }
97 >        ${   px4   } ${   py4   } ${   pz4   }
98   ';
99 < $outfmt .= $posgradfmt if ($doposgrad);
86 < my $dirgradfmt='
99 > $posgradfmt .= '
100   void glow tipglow
101   0
102   0
# Line 92 | Line 105 | void glow tipglow
105   tipglow sphere atip
106   0
107   0
108 < 4 ${ cx1 } ${ cy1 } ${ cz1 } ${psiz/7}
109 <
108 > 4 ${   cx1   } ${   cy1   } ${   cz1   } ${psiz/7}
109 > ' if ($dodirgrad);
110 > my $dirgradfmt='
111   void brightfunc dgpat
112   2 dirfunc ambpos.cal
113   0
# Line 108 | Line 122 | dgval ring dgdisk${recno}a
122   0
123   0
124   8
125 <        ${ px+dgx*.0001 } ${ py+dgy*.0001 } ${ pz+dgz*.0001 }
125 >        ${ px+dgx/dg*eps*.5 } ${ py+dgy/dg*eps*.5 } ${ pz+dgz/dg*eps*.5 }
126          ${ dgx } ${ dgy } ${ dgz }
127 <        0       ${ r0/2 }
127 >        0       ${  r0/2  }
128  
129   dgval ring dgdisk${recno}b
130   0
131   0
132   8
133 <        ${ px-dgx*.0001 } ${ py-dgy*.0001 } ${ pz-dgz*.0001 }
133 >        ${ px-dgx/dg*eps*.5 } ${ py-dgy/dg*eps*.5 } ${ pz-dgz/dg*eps*.5 }
134          ${ -dgx } ${ -dgy } ${ -dgz }
135 <        0       ${ r0/2 }
135 >        0       ${  r0/2  }
136   ';
123 $outfmt .= $dirgradfmt if ($dodirgrad);
137   # Load & convert ambient values
138   print "# Output produced by: $savedARGV\n";
139 < system "lookamb -h -d $ARGV[0] | rcalc -e 'LV:$lvlsel;SF:$scale' -f rambpos.cal -o '$outfmt'\n";
139 > system "lookamb -h -d $ARGV[0] | rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" .
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 $fixedrad -o '$posgradfmt'";
145 > }
146 > if ($dodirgrad) {
147 >        system "lookamb -h -d $ARGV[0] " .
148 >                "| rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" .
149 >                " -f rambpos.cal -e cond=dcond -o '$dirgradfmt'";
150 > }
151   exit;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines