1 |
#!/usr/bin/perl -w |
2 |
# RCSid $Id$ |
3 |
# |
4 |
# Convert Optics 5 output to correct Radiance input |
5 |
# |
6 |
use strict; |
7 |
my $windoz = ($^O eq "MSWin32" or $^O eq "MSWin64"); |
8 |
if ($#ARGV < 0) { |
9 |
print STDERR "Usage: optics2rad optics.mat ..\n"; |
10 |
exit 1; |
11 |
} |
12 |
my $optf = |
13 |
q[void glass $(name)_glass] . "\n0\n0\n3 " . |
14 |
q[${Rtn} ${Gtn} ${Btn}] . "\n\n" . |
15 |
q[void BRTDfunc $(name)_front] . "\n10\n" . |
16 |
q[ ${fRrho} ${fGrho} ${fBrho}] . "\n" . |
17 |
q[ ${Rtau} ${Gtau} ${Btau}] . "\n" . |
18 |
" 0 0 0\n .\n0\n9 0 0 0 0 0 0 0 0 0\n\n" . |
19 |
q[void BRTDfunc $(name)_back] . "\n10\n" . |
20 |
q[${bRrho} ${bGrho} ${bBrho}] . "\n" . |
21 |
q[${Rtau} ${Gtau} ${Btau}] . "\n" . |
22 |
" 0 0 0\n .\n0\n9 0 0 0 0 0 0 0 0 0\n" ; |
23 |
|
24 |
print "# Output generated by optics2rad from @ARGV\n"; |
25 |
if (! $windoz ) { |
26 |
system q{sed -e '/^[^#]/d' -e '/^$/d' } . "@ARGV" ; |
27 |
} |
28 |
my $outf = |
29 |
q[void glass $(name)] . "\n0\n0\n" . |
30 |
q[3 ${Rtn} ${Gtn} ${Btn}] . "\n\n" ; |
31 |
|
32 |
if ($windoz) { |
33 |
system "rcalc -l -e \"abs(x):if(x,x,-x);and(a,b):if(a,b,a);not(x):if(x,-1,1)\" " . |
34 |
"-e \"lum(r,g,b):.265*r+.670*g+.065*b\" " . |
35 |
"-e \"trans=lum(Rtau,Gtau,Btau)\" " . |
36 |
"-e \"rfront=lum(fRrho,fGrho,fBrho);rback=lum(bRrho,bGrho,bBrho)\" " . |
37 |
"-e \"cond=0.005-abs(rfront-rback)\" " . |
38 |
"-i \"$optf\" -o \"$outf\" @ARGV" ; |
39 |
} else { |
40 |
system "rcalc -l -e 'abs(x):if(x,x,-x);and(a,b):if(a,b,a);not(x):if(x,-1,1)' " . |
41 |
"-e 'lum(r,g,b):.265*r+.670*g+.065*b' " . |
42 |
"-e 'trans=lum(Rtau,Gtau,Btau)' " . |
43 |
"-e 'rfront=lum(fRrho,fGrho,fBrho);rback=lum(bRrho,bGrho,bBrho)' " . |
44 |
"-e 'cond=0.005-abs(rfront-rback)' " . |
45 |
"-i '$optf' -o '$outf' @ARGV" ; |
46 |
} |
47 |
$outf = |
48 |
q[void BRTDfunc $(name)] . "\n" . |
49 |
q[10 rR_clear rG_clear rB_clear] . "\n" . |
50 |
q[${Rtau}*tR_clear ${Gtau}*tG_clear ${Btau}*tB_clear] . |
51 |
"\n0 0 0 window.cal\n0\n" . |
52 |
"15 0 0 0 0 0 0 0 0 0\n" . |
53 |
q[${fRrho} ${fGrho} ${fBrho}] . "\n" . |
54 |
q[${bRrho} ${bGrho} ${bBrho}] . "\n\n" ; |
55 |
|
56 |
if ($windoz) { |
57 |
system "rcalc -l -e \"abs(x):if(x,x,-x);and(a,b):if(a,b,a);not(x):if(x,-1,1)\" " . |
58 |
"-e \"lum(r,g,b):.265*r+.670*g+.065*b\" " . |
59 |
"-e \"trans=lum(Rtau,Gtau,Btau)\" " . |
60 |
"-e \"rfront=lum(fRrho,fGrho,fBrho);rback=lum(bRrho,bGrho,bBrho)\" " . |
61 |
"-e \"cond=and(trans-.645, not(0.005-abs(rfront-rback)))\" " . |
62 |
"-i \"$optf\" -o \"$outf\" @ARGV" ; |
63 |
} else { |
64 |
system "rcalc -l -e 'abs(x):if(x,x,-x);and(a,b):if(a,b,a);not(x):if(x,-1,1)' " . |
65 |
"-e 'lum(r,g,b):.265*r+.670*g+.065*b' " . |
66 |
"-e 'trans=lum(Rtau,Gtau,Btau)' " . |
67 |
"-e 'rfront=lum(fRrho,fGrho,fBrho);rback=lum(bRrho,bGrho,bBrho)' " . |
68 |
"-e 'cond=and(trans-.645, not(0.005-abs(rfront-rback)))' " . |
69 |
"-i '$optf' -o '$outf' @ARGV" ; |
70 |
} |
71 |
$outf = |
72 |
q[void BRTDfunc $(name)] . "\n" . |
73 |
"10 rR_bronze rG_bronze rB_bronze\n" . |
74 |
q[${Rtau}*tR_bronze ${Gtau}*tG_bronze ${Btau}*tB_bronze] . |
75 |
"\n0 0 0 window.cal\n0\n" . |
76 |
"15 0 0 0 0 0 0 0 0 0\n" . |
77 |
q[${fRrho} ${fGrho} ${fBrho}] . "\n" . |
78 |
q[${bRrho} ${bGrho} ${bBrho}] . "\n\n"; |
79 |
|
80 |
if ($windoz) { |
81 |
system "rcalc -l -e \"abs(x):if(x,x,-x);and(a,b):if(a,b,a);not(x):if(x,-1,1)\" " . |
82 |
"-e \"lum(r,g,b):.265*r+.670*g+.065*b\" " . |
83 |
"-e \"trans=lum(Rtau,Gtau,Btau)\" " . |
84 |
"-e \"rfront=lum(fRrho,fGrho,fBrho);rback=lum(bRrho,bGrho,bBrho)\" " . |
85 |
"-e \"cond=and(not(trans-.645), not(0.005-abs(rfront-rback)))\" " . |
86 |
"-i \"$optf\" -o \"$outf\" @ARGV" ; |
87 |
} else { |
88 |
system "rcalc -l -e 'abs(x):if(x,x,-x);and(a,b):if(a,b,a);not(x):if(x,-1,1)' " . |
89 |
"-e 'lum(r,g,b):.265*r+.670*g+.065*b' " . |
90 |
"-e 'trans=lum(Rtau,Gtau,Btau)' " . |
91 |
"-e 'rfront=lum(fRrho,fGrho,fBrho);rback=lum(bRrho,bGrho,bBrho)' " . |
92 |
"-e 'cond=and(not(trans-.645), not(0.005-abs(rfront-rback)))' " . |
93 |
"-i '$optf' -o '$outf' @ARGV" ; |
94 |
} |