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

Comparing ray/src/util/genskyvec.pl (file contents):
Revision 2.6 by greg, Mon May 16 23:56:32 2011 UTC vs.
Revision 2.9 by greg, Wed Sep 17 22:40:49 2014 UTC

# Line 9 | Line 9 | use strict;
9   my $windoz = ($^O eq "MSWin32" or $^O eq "MSWin64");
10   my @skycolor = (0.960, 1.004, 1.118);
11   my $mf = 4;
12 + my $dosky = 1;
13 + my $headout = 1;
14 + my @origARGV = @ARGV;
15   while ($#ARGV >= 0) {
16          if ("$ARGV[0]" eq "-c") {
17                  @skycolor = @ARGV[1..3];
18 <                shift @ARGV; shift @ARGV; shift @ARGV;
18 >                shift @ARGV for (1..3);
19          } elsif ("$ARGV[0]" eq "-m") {
20                  $mf = $ARGV[1];
21                  shift @ARGV;
22 +        } elsif ("$ARGV[0]" eq "-d") {
23 +                $dosky = 0;
24 +        } elsif ("$ARGV[0]" eq "-h") {
25 +                $headout = 0;
26          }
27          shift @ARGV;
28   }
# Line 81 | Line 88 | if ($windoz) {
88                  q{-e "Rbin=$1;x1=rand(recno*.37-5.3);x2=rand(recno*-1.47+.86)" } .
89                  q{-e "$1=0;$2=0;$3=0;$4=Dx;$5=Dy;$6=Dz" } .
90                  "| rtrace -h -ab 0 -w $octree | total -16 -m";
91 <        $suncmd = "cnt " . ($nbins-1) .
92 <                " | rcalc -e MF:$mf -e \"$rhcal\" -e Rbin=recno " .
93 <                "-e \"dot=Dx*$sundir[0] + Dy*$sundir[1] + Dz*$sundir[2]\" " .
94 <                "-e \"cond=dot-.866\" " .
95 <                q{-e "$1=if(1-dot,acos(dot),0);$2=Romega;$3=recno" };
91 >        if (@sundir) {
92 >                $suncmd = "cnt " . ($nbins-1) .
93 >                        " | rcalc -e MF:$mf -e \"$rhcal\" -e Rbin=recno " .
94 >                        "-e \"dot=Dx*$sundir[0] + Dy*$sundir[1] + Dz*$sundir[2]\" " .
95 >                        "-e \"cond=dot-.866\" " .
96 >                        q{-e "$1=if(1-dot,acos(dot),0);$2=Romega;$3=recno" };
97 >        }
98   } else {
99          $nbins = `rcalc -n -e MF:$mf -e \'$rhcal\' -e \'\$1=Rmax+1\'`;
100          chomp $nbins;
# Line 94 | Line 103 | if ($windoz) {
103                  q{-e 'Rbin=$1;x1=rand(recno*.37-5.3);x2=rand(recno*-1.47+.86)' } .
104                  q{-e '$1=0;$2=0;$3=0;$4=Dx;$5=Dy;$6=Dz' } .
105                  "| rtrace -h -ff -ab 0 -w $octree | total -if3 -16 -m";
106 <        $suncmd = "cnt " . ($nbins-1) .
107 <                " | rcalc -e MF:$mf -e '$rhcal' -e Rbin=recno " .
108 <                "-e 'dot=Dx*$sundir[0] + Dy*$sundir[1] + Dz*$sundir[2]' " .
109 <                "-e 'cond=dot-.866' " .
110 <                q{-e '$1=if(1-dot,acos(dot),0);$2=Romega;$3=recno' };
106 >        if (@sundir) {
107 >                $suncmd = "cnt " . ($nbins-1) .
108 >                        " | rcalc -e MF:$mf -e '$rhcal' -e Rbin=recno " .
109 >                        "-e 'dot=Dx*$sundir[0] + Dy*$sundir[1] + Dz*$sundir[2]' " .
110 >                        "-e 'cond=dot-.866' " .
111 >                        q{-e '$1=if(1-dot,acos(dot),0);$2=Romega;$3=recno' };
112 >        }
113   }
114 < # Create octree for rtrace
115 < open OCONV, "| oconv - > $octree";
116 < print OCONV @skydesc;
117 < print OCONV "skyfunc glow skyglow 0 0 4 @skycolor 0\n";
118 < print OCONV "skyglow source sky 0 0 4 0 0 1 360\n";
119 < close OCONV;
120 < # Run rtrace and average output for every 16 samples
121 < my @tregval = `$tregcommand`;
122 < unlink $octree;
114 > my @tregval;
115 > if ($dosky) {
116 >        # Create octree for rtrace
117 >        open OCONV, "| oconv - > $octree";
118 >        print OCONV @skydesc;
119 >        print OCONV "skyfunc glow skyglow 0 0 4 @skycolor 0\n";
120 >        print OCONV "skyglow source sky 0 0 4 0 0 1 360\n";
121 >        close OCONV;
122 >        # Run rtrace and average output for every 16 samples
123 >        @tregval = `$tregcommand`;
124 >        unlink $octree;
125 > } else {
126 >        push @tregval, "0\t0\t0\n" for (1..$nbins);
127 > }
128   # Find closest 3 patches to sun and divvy up direct solar contribution
129   sub numSort1 {
130          my @a1 = split("\t", $a);
# Line 131 | Line 147 | if (@sundir) {
147                  for my $j (0..2) { $scolor[$j] += $wt * $sunval[$j]; }
148                  $tregval[$ndx[$i]] = "$scolor[0]\t$scolor[1]\t$scolor[2]\n";
149          }
150 + }
151 + # Output header if requested
152 + if ($headout) {
153 +        print "#?RADIANCE\n";
154 +        print "genskyvec @origARGV\n";
155 +        print "NROWS=", $#tregval+1, "\n";
156 +        print "NCOLS=1\nNCOMP=3\n";
157 +        print "FORMAT=ascii\n";
158 +        print "\n";
159   }
160   # Output our final vector
161   print @tregval;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines