ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/genambpos.pl
Revision: 2.11
Committed: Tue Feb 15 04:08:26 2022 UTC (2 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R4, HEAD
Changes since 2.10: +3 -1 lines
Log Message:
fix(genambpos): Added error message when attempting to run under Windows

File Contents

# User Rev Content
1 greg 2.1 #!/usr/bin/perl -w
2 greg 2.11 # RCSid $Id: genambpos.pl,v 2.10 2016/04/20 20:57:57 greg Exp $
3 greg 2.1 #
4     # Visualize ambient positions and gradients
5     #
6     use strict;
7 greg 2.11 my $windoz = ($^O eq "MSWin32" or $^O eq "MSWin64");
8     die "Not supported under Windows -- sorry!\n" if ( $windoz );
9 greg 2.1 sub userror {
10 greg 2.5 print STDERR "Usage: genambpos [-l lvl][-w minwt][-r rad][-s sf][-p][-d] scene.amb > ambloc.rad\n";
11 greg 2.1 exit 1;
12     }
13     my $lvlsel = -1;
14     my $scale = 0.25;
15     my $doposgrad = 0;
16     my $dodirgrad = 0;
17 greg 2.2 my $minwt = 0.5001**6;
18 greg 2.5 my $fixedrad="";
19 greg 2.1 my $savedARGV = "genambpos @ARGV";
20     # Get options
21     while ($#ARGV >= 0) {
22     if ("$ARGV[0]" =~ /^-p/) {
23     $doposgrad=1;
24     } elsif ("$ARGV[0]" =~ /^-d/) {
25     $dodirgrad=1;
26     } elsif ("$ARGV[0]" =~ /^-l/) {
27     $lvlsel = $ARGV[1];
28     shift @ARGV;
29 greg 2.2 } elsif ("$ARGV[0]" =~ /^-w/) {
30     $minwt = $ARGV[1];
31     shift @ARGV;
32 greg 2.1 } elsif ("$ARGV[0]" =~ /^-s/) {
33     $scale = $ARGV[1];
34     shift @ARGV;
35 greg 2.5 } elsif ("$ARGV[0]" =~ /^-r/) {
36     $fixedrad = "-e psiz:$ARGV[1]";
37     shift @ARGV;
38 greg 2.1 } elsif ("$ARGV[0]" =~ /^-./) {
39     userror();
40     } else {
41     last;
42     }
43     shift @ARGV;
44     }
45     userror() if ($#ARGV != 0);
46     my $cmd = "getinfo < $ARGV[0] " .
47 greg 2.3 q[| sed -n 's/^.* -aa \([.0-9][^ ]*\) .*$/\1/p'];
48 greg 2.1 my $ambacc=`$cmd`;
49     die "Missing -aa setting in header\n" if (! $ambacc );
50 greg 2.6 die "Zero -aa setting in header\n" if ($ambacc <= .00001);
51 greg 2.4 $scale *= $ambacc;
52     my $ambfmt = '
53 greg 2.1 void glow posglow
54     0
55     0
56     4 ${agr} ${agg} ${agb} 0
57    
58     posglow sphere position${recno}
59     0
60     0
61 greg 2.6 4 ${ px } ${ py } ${ pz } ${ psiz }
62 greg 2.4 ';
63     my $posgradfmt = '
64 greg 2.2 void glow arrglow
65     0
66     0
67     4 ${wt*agr} ${wt*agg} ${wt*agb} 0
68    
69     arrglow cone pgarrow${recno}
70 greg 2.1 0
71     0
72     8
73 greg 2.7 ${ cx0 } ${ cy0 } ${ cz0 }
74     ${ cx1 } ${ cy1 } ${ cz1 }
75     ${ cr0 } 0
76 greg 2.4
77 greg 2.1 void brightfunc pgpat
78     2 posfunc ambpos.cal
79     0
80     6 ${ px } ${ py } ${ pz } ${ pgx } ${ pgy } ${ pgz }
81    
82 greg 2.9 pgpat colorfunc pgpat
83     4 1 if(corralled,.1,1) if(corralled,.1,1) ambpos.cal
84     0
85     7 ${ px } ${ py } ${ pz } ${ ux } ${ uy } ${ uz } ${ cflags }
86    
87 greg 2.1 pgpat glow pgval
88     0
89     0
90     4 ${avr} ${avg} ${avb} 0
91    
92     void mixfunc pgeval
93     4 pgval void ellipstencil ambpos.cal
94     0
95     9 ${ px } ${ py } ${ pz } ${ux/r0} ${uy/r0} ${uz/r0} ${vx/r1} ${vy/r1} ${vz/r1}
96    
97     pgeval polygon pgellipse${recno}
98     0
99     0
100     12
101 greg 2.7 ${ px1 } ${ py1 } ${ pz1 }
102     ${ px2 } ${ py2 } ${ pz2 }
103     ${ px3 } ${ py3 } ${ pz3 }
104     ${ px4 } ${ py4 } ${ pz4 }
105 greg 2.1 ';
106 greg 2.4 $posgradfmt .= '
107 greg 2.1 void glow tipglow
108     0
109     0
110     4 ${2*agr} ${2*agg} ${2*agb} 0
111    
112 greg 2.10 tipglow sphere atip${recno}
113 greg 2.1 0
114     0
115 greg 2.7 4 ${ cx1 } ${ cy1 } ${ cz1 } ${psiz/7}
116 greg 2.4 ' if ($dodirgrad);
117     my $dirgradfmt='
118 greg 2.1 void brightfunc dgpat
119     2 dirfunc ambpos.cal
120     0
121     9 ${ px } ${ py } ${ pz } ${ nx } ${ ny } ${ nz } ${ dgx } ${ dgy } ${ dgz }
122    
123     dgpat glow dgval
124     0
125     0
126     4 ${avr} ${avg} ${avb} 0
127    
128     dgval ring dgdisk${recno}a
129     0
130     0
131     8
132 greg 2.8 ${ px+dgx/dg*eps*.5 } ${ py+dgy/dg*eps*.5 } ${ pz+dgz/dg*eps*.5 }
133 greg 2.1 ${ dgx } ${ dgy } ${ dgz }
134 greg 2.7 0 ${ r0/2 }
135 greg 2.1
136     dgval ring dgdisk${recno}b
137     0
138     0
139     8
140 greg 2.8 ${ px-dgx/dg*eps*.5 } ${ py-dgy/dg*eps*.5 } ${ pz-dgz/dg*eps*.5 }
141 greg 2.1 ${ -dgx } ${ -dgy } ${ -dgz }
142 greg 2.7 0 ${ r0/2 }
143 greg 2.1 ';
144     # Load & convert ambient values
145     print "# Output produced by: $savedARGV\n";
146 greg 2.2 system "lookamb -h -d $ARGV[0] | rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" .
147 greg 2.5 " -f rambpos.cal -e cond=acond $fixedrad -o '$ambfmt'";
148 greg 2.4 if ($doposgrad) {
149     system "lookamb -h -d $ARGV[0] " .
150     "| rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" .
151 greg 2.5 " -f rambpos.cal -e cond=pcond $fixedrad -o '$posgradfmt'";
152 greg 2.4 }
153     if ($dodirgrad) {
154     system "lookamb -h -d $ARGV[0] " .
155     "| rcalc -e 'LV:$lvlsel;MW:$minwt;SF:$scale'" .
156     " -f rambpos.cal -e cond=dcond -o '$dirgradfmt'";
157     }
158 greg 2.1 exit;