ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/genambpos.pl
Revision: 2.2
Committed: Fri Apr 25 18:13:47 2014 UTC (9 years, 11 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.1: +14 -4 lines
Log Message:
Added -w option and changed arrow to reflect weight

File Contents

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