| 1 |
#!/bin/csh -f |
| 2 |
# RCSid: $Id$ |
| 3 |
# |
| 4 |
# Generate source description for window with venetian blinds. |
| 5 |
# |
| 6 |
# 1/11/88 Greg Ward |
| 7 |
# |
| 8 |
# Usage: genwindow shellfile |
| 9 |
# |
| 10 |
# Takes as input the following shell variables from file $1: |
| 11 |
# |
| 12 |
# worient Window orientation (degrees from south) |
| 13 |
# wwidth Window width |
| 14 |
# wheight Window height |
| 15 |
# wtrans Window transmission |
| 16 |
# bdepth Blind depth |
| 17 |
# bspac Blind vertical spacing |
| 18 |
# gap Gap between blinds and window |
| 19 |
# brcurv Blind curvature radius (negative upward, zero none) |
| 20 |
# bangle Blind inclination (degrees from horizontal, up and out) |
| 21 |
# material Blind material type (metal or plastic) |
| 22 |
# ucolor Blind up side color ("red green blue") |
| 23 |
# uspec Blind up side specularity (0 to 1) |
| 24 |
# urough Blind up side roughness (0 to .2) |
| 25 |
# dcolor Blind down side color (opt) |
| 26 |
# dspec Blind down side specularity (opt) |
| 27 |
# drough Blind down side roughness (opt) |
| 28 |
# lat Site latitude (degrees) |
| 29 |
# long Site longitude (degrees) |
| 30 |
# mer Site standard meridian (degrees) |
| 31 |
# hour Hour (standard 24hr time) |
| 32 |
# day Day (of month) |
| 33 |
# month Month (of year) |
| 34 |
# grefl Ground plane reflectance |
| 35 |
# sky Sky conditions (sunny, clear, cloudy) |
| 36 |
# nsources Number of sources to divide window |
| 37 |
# |
| 38 |
# Creates the following output files: |
| 39 |
# |
| 40 |
# stdout Window description for Radiance |
| 41 |
# $1.d$$ Window output distribution |
| 42 |
# |
| 43 |
|
| 44 |
if ( $#argv != 1 ) then |
| 45 |
echo Usage: $0 input |
| 46 |
exit 1 |
| 47 |
endif |
| 48 |
|
| 49 |
# Set input and output files |
| 50 |
set input = $1 |
| 51 |
set distrib = $1.d$$ |
| 52 |
set tmpdir = /tmp |
| 53 |
set descrip = $tmpdir/gw$$.des |
| 54 |
set distoct = $tmpdir/gw$$.oct |
| 55 |
set skydesc = $tmpdir/gw$$.sky |
| 56 |
set remove = ( $distoct $skydesc $descrip ) |
| 57 |
set removerr = ( $remove $distrib ) |
| 58 |
onintr error |
| 59 |
|
| 60 |
# Set default values |
| 61 |
set worient = 0. |
| 62 |
set wtrans = ( .96 .96 .96 ) |
| 63 |
set bdepth = 0.025 |
| 64 |
set bspac = 0.0155 |
| 65 |
set gap = 0. |
| 66 |
set brcurv = 0. |
| 67 |
set bangle = 0. |
| 68 |
set material = plastic |
| 69 |
set ucolor = ( 0.5 0.5 0.5 ) |
| 70 |
set uspec = 0. |
| 71 |
set urough = 0.05 |
| 72 |
set lat = 37.8 |
| 73 |
set long = 122 |
| 74 |
set mer = 120 |
| 75 |
set hour = 12 |
| 76 |
set day = 21 |
| 77 |
set month = 10 |
| 78 |
set grefl = .2 |
| 79 |
set sky = sunny |
| 80 |
set nsources = 6 |
| 81 |
|
| 82 |
# Get input |
| 83 |
source $input |
| 84 |
if ( $status ) goto error |
| 85 |
|
| 86 |
# Create window |
| 87 |
cat > $descrip <<_EOF_ |
| 88 |
|
| 89 |
void glass clear_glass |
| 90 |
0 |
| 91 |
0 |
| 92 |
3 $wtrans |
| 93 |
|
| 94 |
clear_glass polygon window |
| 95 |
0 |
| 96 |
0 |
| 97 |
12 |
| 98 |
0 0 0 |
| 99 |
0 0 $wheight |
| 100 |
$wwidth 0 $wheight |
| 101 |
$wwidth 0 0 |
| 102 |
|
| 103 |
void $material blind_upmat |
| 104 |
0 |
| 105 |
0 |
| 106 |
5 $ucolor $uspec $urough |
| 107 |
_EOF_ |
| 108 |
if ( $status ) goto error |
| 109 |
|
| 110 |
# Blinds |
| 111 |
genblinds blind_upmat blind_up $bdepth $wwidth $wheight \ |
| 112 |
`ev "ceil($wheight/$bspac)"` $bangle -r $brcurv \ |
| 113 |
| xform -t $gap -$wwidth 1e-4 -rz 90 >> $descrip |
| 114 |
if ( $status ) goto error |
| 115 |
if ( $?dcolor ) then |
| 116 |
cat >> $descrip <<_EOF_ |
| 117 |
|
| 118 |
void $material blind_dnmat |
| 119 |
0 |
| 120 |
0 |
| 121 |
5 $dcolor $dspec $drough |
| 122 |
_EOF_ |
| 123 |
genblinds blind_dnmat blind_down $bdepth $wwidth $wheight \ |
| 124 |
`ev "ceil($wheight/$bspac)"` $bangle -r $brcurv \ |
| 125 |
| xform -t $gap -$wwidth 0 -rz 90 >> $descrip |
| 126 |
if ( $status ) goto error |
| 127 |
endif |
| 128 |
|
| 129 |
# Make sky |
| 130 |
switch ($sky) |
| 131 |
case sun*: |
| 132 |
set skysw = +s |
| 133 |
breaksw |
| 134 |
case clear: |
| 135 |
set skysw = -s |
| 136 |
breaksw |
| 137 |
case cloud*: |
| 138 |
set skysw = -c |
| 139 |
breaksw |
| 140 |
endsw |
| 141 |
dosky: |
| 142 |
gensky $month $day $hour $skysw -a $lat -o $long -m $mer -g $grefl \ |
| 143 |
| xform -rz `ev "-($worient)"` > $skydesc |
| 144 |
if ( $skysw == +s ) then |
| 145 |
if ( `sed -n 13p $skydesc | rcalc -e '$1=if($3,-1,1)'` < 0 ) then |
| 146 |
set skysw = -s |
| 147 |
goto dosky |
| 148 |
endif |
| 149 |
endif |
| 150 |
cat >> $skydesc <<_EOF_ |
| 151 |
|
| 152 |
skyfunc glow skyglow |
| 153 |
0 |
| 154 |
0 |
| 155 |
4 1 1 1 0 |
| 156 |
|
| 157 |
skyglow source sky |
| 158 |
0 |
| 159 |
0 |
| 160 |
4 0 -1 0 180 |
| 161 |
_EOF_ |
| 162 |
|
| 163 |
# Make distribution |
| 164 |
oconv $skydesc $descrip > $distoct |
| 165 |
if ( $status ) goto error |
| 166 |
echo 2 5 85 9 0 340 18 > $distrib |
| 167 |
makedist -h -d -x1 0 1 0 -x2 0 0 1 -x3 1 0 0 -alpha 5-85:10 -beta 0-340:20 \ |
| 168 |
-tw $bspac -th $bspac -td `ev "2*($bdepth+$gap)"` \ |
| 169 |
-tc `ev "$wwidth/2" "$bdepth+$gap" "$wheight/2"` \ |
| 170 |
-ab 2 -aa .1 -ad 64 -as 64 \ |
| 171 |
-x 16 -y 16 $distoct >> $distrib |
| 172 |
if ( $status ) goto error |
| 173 |
|
| 174 |
set wsgrid = (`ev "floor(sqrt($nsources*$wwidth/$wheight)+.5)" "floor(sqrt($nsources*$wheight/$wwidth)+.5)"`) |
| 175 |
@ nsources = $wsgrid[1] * $wsgrid[2] |
| 176 |
# Print header |
| 177 |
cat <<_EOF_ |
| 178 |
# |
| 179 |
# Window with venetian blinds |
| 180 |
# Created from $input `date` |
| 181 |
# |
| 182 |
# Window orientation (degrees from south): $worient |
| 183 |
# Window height: $wheight |
| 184 |
# Window width: $wwidth |
| 185 |
# Window transmission: $wtrans |
| 186 |
# Blind depth: $bdepth |
| 187 |
# Blind spacing: $bspac |
| 188 |
# Gap to window: $gap |
| 189 |
# Blind curvature radius: $brcurv |
| 190 |
# Blind inclination (degrees altitude): $bangle |
| 191 |
# Blind material: $material |
| 192 |
# Up side color: $ucolor |
| 193 |
# Up side specularity: $uspec |
| 194 |
# Up side roughness: $urough |
| 195 |
_EOF_ |
| 196 |
if ( $?dcolor ) then |
| 197 |
cat <<_EOF_ |
| 198 |
# Down side color: $dcolor |
| 199 |
# Down side specularity: $dspec |
| 200 |
# Down side roughness: $drough |
| 201 |
_EOF_ |
| 202 |
else |
| 203 |
echo \#\ Down side same as up |
| 204 |
endif |
| 205 |
cat <<_EOF_ |
| 206 |
# Latitude (degrees): $lat |
| 207 |
# Longitude (degrees): $long |
| 208 |
# Standard Meridian (degrees): $mer |
| 209 |
# Month Day Hour: $month $day $hour |
| 210 |
# Ground plane reflectance: $grefl |
| 211 |
# Sky condition: $sky |
| 212 |
# Number of window sources: $nsources |
| 213 |
# |
| 214 |
_EOF_ |
| 215 |
|
| 216 |
# Send sources |
| 217 |
xform -e -rz $worient <<_EOF_ |
| 218 |
|
| 219 |
void brightdata wdistrib |
| 220 |
10 noop $distrib source.cal src_theta src_phi -rx 90 -ry -90 -mx |
| 221 |
0 |
| 222 |
0 |
| 223 |
|
| 224 |
wdistrib illum willum |
| 225 |
0 |
| 226 |
0 |
| 227 |
3 1 1 1 |
| 228 |
|
| 229 |
!gensurf willum wsource "$wwidth*t" $bdepth "$wheight*s" $wsgrid[2] $wsgrid[1] |
| 230 |
_EOF_ |
| 231 |
if ( $status ) goto error |
| 232 |
|
| 233 |
# Send window |
| 234 |
xform -rz $worient $descrip |
| 235 |
if ( $status ) goto error |
| 236 |
|
| 237 |
# All done, print and exit |
| 238 |
rm -f $remove |
| 239 |
exit 0 |
| 240 |
|
| 241 |
# Error exit |
| 242 |
error: |
| 243 |
rm -f $removerr |
| 244 |
exit 1 |