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.3 by greg, Sat Apr 26 04:02:03 2014 UTC vs.
Revision 2.10 by greg, Wed Apr 20 20:57:57 2016 UTC

# Line 5 | Line 5
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;
# Line 13 | Line 13 | 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 29 | Line 30 | 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 {
# Line 41 | Line 45 | my $cmd = "getinfo < $ARGV[0] " .
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 51 | Line 56 | void glow posglow
56   posglow sphere position${recno}
57   0
58   0
59 < 4 ${px} ${py} ${pz} ${psiz}
60 <
59 > 4 ${  px  } ${  py  } ${  pz  } ${ psiz }
60 > ';
61 > my $posgradfmt = '
62   void glow arrglow
63   0
64   0
# Line 62 | Line 68 | arrglow cone pgarrow${recno}
68   0
69   0
70   8
71 <        ${ cx0 }        ${ cy0 }        ${ cz0 }
72 <        ${ cx1 }        ${ cy1 }        ${ cz1 }
73 <        ${ cr0 }        0
74 < ';
69 < 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
78   6 ${ px } ${ py } ${ pz } ${ pgx } ${ pgy } ${ pgz }
79  
80 + pgpat colorfunc pgpat
81 + 4 1 if(corralled,.1,1) if(corralled,.1,1) ambpos.cal
82 + 0
83 + 7 ${ px } ${ py } ${ pz } ${  ux  } ${  uy  } ${  uz  } ${   cflags    }
84 +
85   pgpat glow pgval
86   0
87   0
# Line 86 | Line 96 | pgeval polygon pgellipse${recno}
96   0
97   0
98   12
99 <        ${ px1 } ${ py1 } ${ pz1 }
100 <        ${ px2 } ${ py2 } ${ pz2 }
101 <        ${ px3 } ${ py3 } ${ pz3 }
102 <        ${ px4 } ${ py4 } ${ pz4 }
99 >        ${   px1   } ${   py1   } ${   pz1   }
100 >        ${   px2   } ${   py2   } ${   pz2   }
101 >        ${   px3   } ${   py3   } ${   pz3   }
102 >        ${   px4   } ${   py4   } ${   pz4   }
103   ';
104 < $outfmt .= $posgradfmt if ($doposgrad);
95 < my $dirgradfmt='
104 > $posgradfmt .= '
105   void glow tipglow
106   0
107   0
108   4 ${2*agr} ${2*agg} ${2*agb} 0
109  
110 < tipglow sphere atip
110 > tipglow sphere atip${recno}
111   0
112   0
113 < 4 ${ cx1 } ${ cy1 } ${ cz1 } ${psiz/7}
114 <
113 > 4 ${   cx1   } ${   cy1   } ${   cz1   } ${psiz/7}
114 > ' if ($dodirgrad);
115 > my $dirgradfmt='
116   void brightfunc dgpat
117   2 dirfunc ambpos.cal
118   0
# Line 117 | Line 127 | dgval ring dgdisk${recno}a
127   0
128   0
129   8
130 <        ${ px+dgx*.0001 } ${ py+dgy*.0001 } ${ pz+dgz*.0001 }
130 >        ${ px+dgx/dg*eps*.5 } ${ py+dgy/dg*eps*.5 } ${ pz+dgz/dg*eps*.5 }
131          ${ dgx } ${ dgy } ${ dgz }
132 <        0       ${ r0/2 }
132 >        0       ${  r0/2  }
133  
134   dgval ring dgdisk${recno}b
135   0
136   0
137   8
138 <        ${ px-dgx*.0001 } ${ py-dgy*.0001 } ${ pz-dgz*.0001 }
138 >        ${ px-dgx/dg*eps*.5 } ${ py-dgy/dg*eps*.5 } ${ pz-dgz/dg*eps*.5 }
139          ${ -dgx } ${ -dgy } ${ -dgz }
140 <        0       ${ r0/2 }
140 >        0       ${  r0/2  }
141   ';
132 $outfmt .= $dirgradfmt if ($dodirgrad);
142   # Load & convert ambient values
143   print "# Output produced by: $savedARGV\n";
144   system "lookamb -h -d $ARGV[0] | rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" .
145 <                " -f rambpos.cal -o '$outfmt'";
145 >                " -f rambpos.cal -e cond=acond $fixedrad -o '$ambfmt'";
146 > if ($doposgrad) {
147 >        system "lookamb -h -d $ARGV[0] " .
148 >                "| rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" .
149 >                " -f rambpos.cal -e cond=pcond $fixedrad -o '$posgradfmt'";
150 > }
151 > if ($dodirgrad) {
152 >        system "lookamb -h -d $ARGV[0] " .
153 >                "| rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" .
154 >                " -f rambpos.cal -e cond=dcond -o '$dirgradfmt'";
155 > }
156   exit;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines