18 #my $xres = 1024; |
18 #my $xres = 1024; |
19 #my $yres = 1024; |
19 #my $yres = 1024; |
20 my $xres = 600; |
20 my $xres = 600; |
21 my $yres = 600; |
21 my $yres = 600; |
22 my $tiny = 0.01; |
22 my $tiny = 0.01; |
|
23 my $is_ies = 0; |
23 my $rpict_cmd = "rpict -ab 0 -ds 0 -dv -av 0 0 0 -x $xres -y $yres"; |
24 my $rpict_cmd = "rpict -ab 0 -ds 0 -dv -av 0 0 0 -x $xres -y $yres"; |
24 my $pfilt_cmd = "pfilt -r .6 -x /2 -y /2"; |
25 my $pfilt_cmd = "pfilt -r .6 -x /2 -y /2"; |
25 |
26 |
|
27 my $ies = "$td/dist.ies"; |
|
28 my $fittings = "$td/fitting.rad"; |
26 my $material = "$td/lt.mat"; |
29 my $material = "$td/lt.mat"; |
27 my $testroom1 = "$td/testroom1.rad"; |
30 my $testroom1 = "$td/testroom1.rad"; |
28 my $testroom2 = "$td/testroom2.rad"; |
31 my $testroom2 = "$td/testroom2.rad"; |
29 my $testroom3 = "$td/testroom3.rad"; |
32 my $testroom3 = "$td/testroom3.rad"; |
30 my $testroom4 = "$td/testroom4.rad"; |
33 my $testroom4 = "$td/testroom4.rad"; |
31 my $octree1 = "$td/lt1.oct"; |
34 my $octree1 = "$td/lt1.oct"; |
32 my $octree2 = "$td/lt2.oct"; |
35 my $octree2 = "$td/lt2.oct"; |
33 my $octree3 = "$td/lt3.oct"; |
36 my $octree3 = "$td/lt3.oct"; |
34 my $octree4 = "$td/lt4.oct"; |
37 my $octree4 = "$td/lt4.oct"; |
35 |
38 |
|
39 # Parse command line arguments |
|
40 if ("$ARGV[0]" eq '-i') { # File is an IES file, not Radiance luminaire |
|
41 $is_ies = 1; |
|
42 shift @ARGV; |
|
43 } |
36 # We need at least one Radiance file or a scene on STDIN (but not both) |
44 # We need at least one Radiance file or a scene on STDIN (but not both) |
37 if ($#ARGV < 0) { |
45 if ($#ARGV < 0) { |
38 open(FH, ">$td/stdin.rad") or |
46 open(FH, ">$td/stdin.rad") or |
39 die("objview: Can't write to temporary file $td/stdin.rad\n"); |
47 die("objview: Can't write to temporary file $td/stdin.rad\n"); |
40 while (<>) { |
48 while (<>) { |
60 # Move fitting so centre is at origin |
68 # Move fitting so centre is at origin |
61 my $xtrans = -1.0 * ($dims[0] + $dims[1]) / 2; |
69 my $xtrans = -1.0 * ($dims[0] + $dims[1]) / 2; |
62 my $ytrans = -1.0 * ($dims[2] + $dims[3]) / 2; |
70 my $ytrans = -1.0 * ($dims[2] + $dims[3]) / 2; |
63 my $ztrans = -1.0 * ($dims[4] + $dims[5]) / 2; |
71 my $ztrans = -1.0 * ($dims[4] + $dims[5]) / 2; |
64 # Scale so that largest object dimension is unity |
72 # Scale so that largest object dimension is unity |
65 my $scale = 1 / $size; |
73 my $scale = 0.001 / $size; |
66 |
74 |
67 my $fitting = "$td/fitting.rad"; |
75 my $fitting = "$td/fitting.rad"; |
68 open(FH, ">$fitting") or |
76 open(FH, ">$fitting") or |
69 die("Can\'t write to temporary file $fitting"); |
77 die("Can\'t write to temporary file $fitting"); |
70 print FH "!xform -t $xtrans $ytrans $ztrans -s $scale @ARGV"; |
78 print FH "!xform -t $xtrans $ytrans $ztrans -s $scale @ARGV"; |