| 19 |
|
char *rtargv[32] = {"rtrace", "-h", "-ov", "-fff"}; |
| 20 |
|
int rtargc = 4; |
| 21 |
|
|
| 22 |
< |
VIEW ourview; /* our view */ |
| 22 |
> |
VIEW ourview = STDVIEW; /* our view */ |
| 23 |
|
VIEW pictview = STDVIEW; /* picture view */ |
| 24 |
|
VIEW leftview, rightview; /* leftmost and rightmost views */ |
| 25 |
|
|
| 29 |
|
int verbose = 0; /* verbose reporting */ |
| 30 |
|
char *progname; /* global argv[0] */ |
| 31 |
|
|
| 32 |
+ |
int sampdens = SAMPDENS; /* sample density */ |
| 33 |
|
ANGLE glarang[180] = {AEND}; /* glare calculation angles */ |
| 34 |
|
int nglarangs = 0; |
| 35 |
|
double maxtheta; /* maximum angle (in radians) */ |
| 57 |
|
continue; |
| 58 |
|
} |
| 59 |
|
switch (argv[i][1]) { |
| 60 |
+ |
case 'r': |
| 61 |
+ |
sampdens = atoi(argv[++i])/2; |
| 62 |
+ |
break; |
| 63 |
|
case 'v': |
| 64 |
|
if (argv[i][2] == '\0') { |
| 65 |
|
verbose++; |
| 205 |
|
} |
| 206 |
|
nglarangs = i; |
| 207 |
|
/* nglardirs = 2*nglarangs + 1; */ |
| 208 |
< |
/* vsize = SAMPDENS; */ |
| 208 |
> |
/* vsize = sampdens - 1; */ |
| 209 |
|
if (nglarangs > 0) |
| 210 |
|
maxtheta = (PI/180.)*glarang[nglarangs-1]; |
| 211 |
|
else |
| 212 |
|
maxtheta = 0.0; |
| 213 |
< |
hlim = SAMPDENS*maxtheta; |
| 214 |
< |
hsize = SAMPDENS + hlim; |
| 215 |
< |
if (hsize > (int)(PI*SAMPDENS)) |
| 216 |
< |
hsize = PI*SAMPDENS; |
| 213 |
> |
hlim = sampdens*maxtheta; |
| 214 |
> |
hsize = hlim + sampdens - 1; |
| 215 |
> |
if (hsize > (int)(PI*sampdens)) |
| 216 |
> |
hsize = PI*sampdens; |
| 217 |
|
indirect = (struct illum *)calloc(nglardirs, sizeof(struct illum)); |
| 218 |
|
if (indirect == NULL) |
| 219 |
|
memerr("indirect illuminances"); |
| 220 |
|
copystruct(&leftview, &ourview); |
| 221 |
|
copystruct(&rightview, &ourview); |
| 222 |
< |
spinvector(leftview.vdir, ourview.vdir, ourview.vup, -maxtheta); |
| 223 |
< |
spinvector(rightview.vdir, ourview.vdir, ourview.vup, maxtheta); |
| 222 |
> |
spinvector(leftview.vdir, ourview.vdir, ourview.vup, maxtheta); |
| 223 |
> |
spinvector(rightview.vdir, ourview.vdir, ourview.vup, -maxtheta); |
| 224 |
|
setview(&leftview); |
| 225 |
|
setview(&rightview); |
| 226 |
|
indirect[nglarangs].lcos = |
| 281 |
|
|
| 282 |
|
if (x <= -hlim) /* left region */ |
| 283 |
|
return(viewray(org, vd, &leftview, |
| 284 |
< |
(x+hlim)/(2.*SAMPDENS)+.5, |
| 285 |
< |
y/(2.*SAMPDENS)+.5)); |
| 284 |
> |
(x+hlim)/(2.*sampdens)+.5, |
| 285 |
> |
y/(2.*sampdens)+.5)); |
| 286 |
|
if (x >= hlim) /* right region */ |
| 287 |
|
return(viewray(org, vd, &rightview, |
| 288 |
< |
(x-hlim)/(2.*SAMPDENS)+.5, |
| 289 |
< |
y/(2.*SAMPDENS)+.5)); |
| 288 |
> |
(x-hlim)/(2.*sampdens)+.5, |
| 289 |
> |
y/(2.*sampdens)+.5)); |
| 290 |
|
/* central region */ |
| 291 |
< |
if (viewray(org, vd, &ourview, .5, y/(2.*SAMPDENS)+.5) < 0) |
| 291 |
> |
if (viewray(org, vd, &ourview, .5, y/(2.*sampdens)+.5) < 0) |
| 292 |
|
return(-1); |
| 293 |
|
spinvector(vd, vd, ourview.vup, h_theta(x)); |
| 294 |
|
return(0); |
| 295 |
|
} |
| 296 |
|
|
| 297 |
|
|
| 294 |
– |
spinvector(vres, vorig, vnorm, theta) /* rotate vector around normal */ |
| 295 |
– |
FVECT vres, vorig, vnorm; |
| 296 |
– |
double theta; |
| 297 |
– |
{ |
| 298 |
– |
extern double sin(), cos(); |
| 299 |
– |
double sint, cost, dotp; |
| 300 |
– |
FVECT vperp; |
| 301 |
– |
register int i; |
| 302 |
– |
|
| 303 |
– |
sint = sin(theta); |
| 304 |
– |
cost = cos(theta); |
| 305 |
– |
dotp = DOT(vorig, vnorm); |
| 306 |
– |
fcross(vperp, vnorm, vorig); |
| 307 |
– |
for (i = 0; i < 3; i++) |
| 308 |
– |
vres[i] = vnorm[i]*dotp*(1.-cost) + |
| 309 |
– |
vorig[i]*cost + vperp[i]*sint; |
| 310 |
– |
} |
| 311 |
– |
|
| 312 |
– |
|
| 298 |
|
memerr(s) /* malloc failure */ |
| 299 |
|
char *s; |
| 300 |
|
{ |
| 301 |
< |
fprintf(stderr, "%s: out of memory for %s\n", s); |
| 301 |
> |
fprintf(stderr, "%s: out of memory for %s\n", progname, s); |
| 302 |
|
exit(1); |
| 303 |
|
} |
| 304 |
|
|
| 322 |
|
|
| 323 |
|
printf("BEGIN indirect illuminance\n"); |
| 324 |
|
for (i = 0; i < nglardirs; i++) |
| 325 |
< |
printf("\t%f\t%f\n", (180.0/PI)*indirect[i].theta, |
| 325 |
> |
printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta, |
| 326 |
|
PI * indirect[i].sum / (double)indirect[i].n); |
| 327 |
|
printf("END indirect illuminance\n"); |
| 328 |
|
} |