| 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 |
|
while ($#ARGV >= 0) { |
| 14 |
|
if ("$ARGV[0]" eq "-c") { |
| 15 |
|
@skycolor = @ARGV[1..3]; |
| 16 |
< |
shift @ARGV; shift @ARGV; shift @ARGV; |
| 16 |
> |
shift @ARGV for (1..3); |
| 17 |
|
} elsif ("$ARGV[0]" eq "-m") { |
| 18 |
|
$mf = $ARGV[1]; |
| 19 |
|
shift @ARGV; |
| 20 |
+ |
} elsif ("$ARGV[0]" eq "-d") { |
| 21 |
+ |
$dosky = 0; |
| 22 |
|
} |
| 23 |
|
shift @ARGV; |
| 24 |
|
} |
| 84 |
|
q{-e "Rbin=$1;x1=rand(recno*.37-5.3);x2=rand(recno*-1.47+.86)" } . |
| 85 |
|
q{-e "$1=0;$2=0;$3=0;$4=Dx;$5=Dy;$6=Dz" } . |
| 86 |
|
"| rtrace -h -ab 0 -w $octree | total -16 -m"; |
| 87 |
< |
$suncmd = "cnt " . ($nbins-1) . |
| 88 |
< |
" | rcalc -e MF:$mf -e \"$rhcal\" -e Rbin=recno " . |
| 89 |
< |
"-e \"dot=Dx*$sundir[0] + Dy*$sundir[1] + Dz*$sundir[2]\" " . |
| 90 |
< |
"-e \"cond=dot-.866\" " . |
| 91 |
< |
q{-e "$1=if(1-dot,acos(dot),0);$2=Romega;$3=recno" }; |
| 87 |
> |
if (@sundir) { |
| 88 |
> |
$suncmd = "cnt " . ($nbins-1) . |
| 89 |
> |
" | rcalc -e MF:$mf -e \"$rhcal\" -e Rbin=recno " . |
| 90 |
> |
"-e \"dot=Dx*$sundir[0] + Dy*$sundir[1] + Dz*$sundir[2]\" " . |
| 91 |
> |
"-e \"cond=dot-.866\" " . |
| 92 |
> |
q{-e "$1=if(1-dot,acos(dot),0);$2=Romega;$3=recno" }; |
| 93 |
> |
} |
| 94 |
|
} else { |
| 95 |
|
$nbins = `rcalc -n -e MF:$mf -e \'$rhcal\' -e \'\$1=Rmax+1\'`; |
| 96 |
|
chomp $nbins; |
| 99 |
|
q{-e 'Rbin=$1;x1=rand(recno*.37-5.3);x2=rand(recno*-1.47+.86)' } . |
| 100 |
|
q{-e '$1=0;$2=0;$3=0;$4=Dx;$5=Dy;$6=Dz' } . |
| 101 |
|
"| rtrace -h -ff -ab 0 -w $octree | total -if3 -16 -m"; |
| 102 |
< |
$suncmd = "cnt " . ($nbins-1) . |
| 103 |
< |
" | rcalc -e MF:$mf -e '$rhcal' -e Rbin=recno " . |
| 104 |
< |
"-e 'dot=Dx*$sundir[0] + Dy*$sundir[1] + Dz*$sundir[2]' " . |
| 105 |
< |
"-e 'cond=dot-.866' " . |
| 106 |
< |
q{-e '$1=if(1-dot,acos(dot),0);$2=Romega;$3=recno' }; |
| 102 |
> |
if (@sundir) { |
| 103 |
> |
$suncmd = "cnt " . ($nbins-1) . |
| 104 |
> |
" | rcalc -e MF:$mf -e '$rhcal' -e Rbin=recno " . |
| 105 |
> |
"-e 'dot=Dx*$sundir[0] + Dy*$sundir[1] + Dz*$sundir[2]' " . |
| 106 |
> |
"-e 'cond=dot-.866' " . |
| 107 |
> |
q{-e '$1=if(1-dot,acos(dot),0);$2=Romega;$3=recno' }; |
| 108 |
> |
} |
| 109 |
|
} |
| 110 |
< |
# Create octree for rtrace |
| 111 |
< |
open OCONV, "| oconv - > $octree"; |
| 112 |
< |
print OCONV @skydesc; |
| 113 |
< |
print OCONV "skyfunc glow skyglow 0 0 4 @skycolor 0\n"; |
| 114 |
< |
print OCONV "skyglow source sky 0 0 4 0 0 1 360\n"; |
| 115 |
< |
close OCONV; |
| 116 |
< |
# Run rtrace and average output for every 16 samples |
| 117 |
< |
my @tregval = `$tregcommand`; |
| 118 |
< |
unlink $octree; |
| 110 |
> |
my @tregval; |
| 111 |
> |
if ($dosky) { |
| 112 |
> |
# Create octree for rtrace |
| 113 |
> |
open OCONV, "| oconv - > $octree"; |
| 114 |
> |
print OCONV @skydesc; |
| 115 |
> |
print OCONV "skyfunc glow skyglow 0 0 4 @skycolor 0\n"; |
| 116 |
> |
print OCONV "skyglow source sky 0 0 4 0 0 1 360\n"; |
| 117 |
> |
close OCONV; |
| 118 |
> |
# Run rtrace and average output for every 16 samples |
| 119 |
> |
@tregval = `$tregcommand`; |
| 120 |
> |
unlink $octree; |
| 121 |
> |
} else { |
| 122 |
> |
push @tregval, "0\t0\t0\n" for (1..$nbins); |
| 123 |
> |
} |
| 124 |
|
# Find closest 3 patches to sun and divvy up direct solar contribution |
| 125 |
|
sub numSort1 { |
| 126 |
|
my @a1 = split("\t", $a); |