8 |
|
#include <signal.h> |
9 |
|
#include <ctype.h> |
10 |
|
|
11 |
– |
#include "platform.h" |
11 |
|
#include "mkillum.h" |
13 |
– |
#include "random.h" |
12 |
|
|
13 |
|
/* default parameters */ |
14 |
|
#define SAMPDENS 48 /* points per projected steradian */ |
23 |
|
|
24 |
|
struct illum_args thisillum = { /* our illum and default values */ |
25 |
|
0, |
26 |
+ |
UDzpos, |
27 |
+ |
0., |
28 |
|
DFLMAT, |
29 |
|
DFLDAT, |
30 |
|
0, |
31 |
|
VOIDID, |
32 |
|
SAMPDENS, |
33 |
|
NSAMPS, |
34 |
+ |
NULL, |
35 |
|
0., |
36 |
|
}; |
37 |
|
|
68 |
|
gargv = argv; |
69 |
|
progname = gargv[0]; |
70 |
|
/* set up rendering defaults */ |
71 |
< |
dstrsrc = 0.25; |
71 |
> |
dstrsrc = 0.5; |
72 |
|
directrelay = 3; |
72 |
– |
directvis = 0; |
73 |
|
ambounce = 2; |
74 |
|
/* get options from command line */ |
75 |
< |
for (i = 1; i < argc-1; i++) { |
75 |
> |
for (i = 1; i < argc; i++) { |
76 |
|
while ((rval = expandarg(&argc, &argv, i)) > 0) |
77 |
|
; |
78 |
|
if (rval < 0) { |
112 |
|
init(argv[gargc-1], nprocs); |
113 |
|
if (gargc < argc) { |
114 |
|
if (gargc == argc-1 || argv[gargc][0] != '<' || argv[gargc][1]) |
115 |
< |
error(USER, "Use '< file1 file2 ..' for multiple inputs"); |
115 |
> |
error(USER, "use '< file1 file2 ..' for multiple inputs"); |
116 |
|
for (i = gargc+1; i < argc; i++) { |
117 |
|
if ((fp = fopen(argv[i], "r")) == NULL) { |
118 |
|
sprintf(errmsg, |
175 |
|
|
176 |
|
|
177 |
|
void |
178 |
+ |
quit(ec) /* make sure exit is called */ |
179 |
+ |
int ec; |
180 |
+ |
{ |
181 |
+ |
if (ray_pnprocs > 0) /* close children if any */ |
182 |
+ |
ray_pclose(0); |
183 |
+ |
exit(ec); |
184 |
+ |
} |
185 |
+ |
|
186 |
+ |
|
187 |
+ |
void |
188 |
|
filter( /* process stream */ |
189 |
|
register FILE *infp, |
190 |
|
char *name |
226 |
|
{ |
227 |
|
extern FILE *freopen(); |
228 |
|
char buf[64]; |
229 |
+ |
int negax; |
230 |
|
int nerrs = 0; |
231 |
|
register char *cp; |
232 |
|
|
306 |
|
} |
307 |
|
cp = sskip(cp); |
308 |
|
continue; |
309 |
< |
case 'd': /* point sample density */ |
309 |
> |
case 'd': /* sample density / BSDF data */ |
310 |
|
if (*++cp != '=') |
311 |
|
break; |
312 |
< |
if (!isintd(++cp, " \t\n\r")) |
313 |
< |
break; |
314 |
< |
thisillum.sampdens = atoi(cp); |
312 |
> |
if (thisillum.sd != NULL) { |
313 |
> |
free_BSDF(thisillum.sd); |
314 |
> |
thisillum.sd = NULL; |
315 |
> |
} |
316 |
> |
if (!*++cp || isspace(*cp)) |
317 |
> |
continue; |
318 |
> |
if (isintd(cp, " \t\n\r")) { |
319 |
> |
thisillum.sampdens = atoi(cp); |
320 |
> |
} else { |
321 |
> |
atos(buf, sizeof(buf), cp); |
322 |
> |
thisillum.sd = load_BSDF(buf); |
323 |
> |
if (thisillum.sd == NULL) |
324 |
> |
break; |
325 |
> |
} |
326 |
|
cp = sskip(cp); |
327 |
|
continue; |
328 |
< |
case 's': /* point super-samples */ |
328 |
> |
case 's': /* surface super-samples */ |
329 |
|
if (*++cp != '=') |
330 |
|
break; |
331 |
|
if (!isintd(++cp, " \t\n\r")) |
367 |
|
} |
368 |
|
doneheader = 0; |
369 |
|
continue; |
370 |
+ |
case 'u': /* up direction */ |
371 |
+ |
if (*++cp != '=') |
372 |
+ |
break; |
373 |
+ |
if (!*++cp || isspace(*cp)) { |
374 |
+ |
thisillum.udir = UDunknown; |
375 |
+ |
continue; |
376 |
+ |
} |
377 |
+ |
negax = 0; |
378 |
+ |
if (*cp == '+') |
379 |
+ |
cp++; |
380 |
+ |
else if (*cp == '-') { |
381 |
+ |
negax++; |
382 |
+ |
cp++; |
383 |
+ |
} |
384 |
+ |
switch (*cp++) { |
385 |
+ |
case 'x': |
386 |
+ |
case 'X': |
387 |
+ |
thisillum.udir = negax ? UDxneg : UDxpos; |
388 |
+ |
break; |
389 |
+ |
case 'y': |
390 |
+ |
case 'Y': |
391 |
+ |
thisillum.udir = negax ? UDyneg : UDypos; |
392 |
+ |
break; |
393 |
+ |
case 'z': |
394 |
+ |
case 'Z': |
395 |
+ |
thisillum.udir = negax ? UDzneg : UDzpos; |
396 |
+ |
break; |
397 |
+ |
default: |
398 |
+ |
thisillum.udir = UDunknown; |
399 |
+ |
break; |
400 |
+ |
} |
401 |
+ |
if (thisillum.udir == UDunknown || !isspace(*cp)) |
402 |
+ |
break; |
403 |
+ |
continue; |
404 |
+ |
case 't': /* object thickness */ |
405 |
+ |
if (*++cp != '=') |
406 |
+ |
break; |
407 |
+ |
if (!isfltd(++cp, " \t\n\r")) |
408 |
+ |
break; |
409 |
+ |
thisillum.thick = atof(cp); |
410 |
+ |
if (thisillum.thick < .0) |
411 |
+ |
thisillum.thick = .0; |
412 |
+ |
cp = sskip(cp); |
413 |
+ |
continue; |
414 |
|
case '!': /* processed file! */ |
415 |
|
sprintf(errmsg, "(%s): already processed!", nm); |
416 |
|
error(WARNING, errmsg); |
453 |
|
printf("l+\t\t\t\t# light type on\n"); |
454 |
|
else |
455 |
|
printf("l-\t\t\t\t# light type off\n"); |
456 |
< |
printf("d=%d\t\t\t\t# density of points\n", thisillum.sampdens); |
457 |
< |
printf("s=%d\t\t\t\t# samples per point\n", thisillum.nsamps); |
456 |
> |
printf("d=%d\t\t\t\t# density of directions\n", thisillum.sampdens); |
457 |
> |
printf("s=%d\t\t\t\t# samples per direction\n", thisillum.nsamps); |
458 |
|
printf("b=%f\t\t\t# minimum average brightness\n", thisillum.minbrt); |
459 |
+ |
switch (thisillum.udir) { |
460 |
+ |
case UDzneg: |
461 |
+ |
fputs("u=-Z\t\t\t\t# up is negative Z\n", stdout); |
462 |
+ |
break; |
463 |
+ |
case UDyneg: |
464 |
+ |
fputs("u=-Y\t\t\t\t# up is negative Y\n", stdout); |
465 |
+ |
break; |
466 |
+ |
case UDxneg: |
467 |
+ |
fputs("u=-X\t\t\t\t# up is negative X\n", stdout); |
468 |
+ |
break; |
469 |
+ |
case UDxpos: |
470 |
+ |
fputs("u=+X\t\t\t\t# up is positive X\n", stdout); |
471 |
+ |
break; |
472 |
+ |
case UDypos: |
473 |
+ |
fputs("u=+Y\t\t\t\t# up is positive Y\n", stdout); |
474 |
+ |
break; |
475 |
+ |
case UDzpos: |
476 |
+ |
fputs("u=+Z\t\t\t\t# up is positive Z\n", stdout); |
477 |
+ |
break; |
478 |
+ |
case UDunknown: |
479 |
+ |
break; |
480 |
+ |
} |
481 |
+ |
printf("t=%f\t\t\t# object thickness\n", thisillum.thick); |
482 |
|
} |
483 |
|
|
484 |
|
|