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 |
|
|
113 |
|
init(argv[gargc-1], nprocs); |
114 |
|
if (gargc < argc) { |
115 |
|
if (gargc == argc-1 || argv[gargc][0] != '<' || argv[gargc][1]) |
116 |
< |
error(USER, "Use '< file1 file2 ..' for multiple inputs"); |
116 |
> |
error(USER, "use '< file1 file2 ..' for multiple inputs"); |
117 |
|
for (i = gargc+1; i < argc; i++) { |
118 |
|
if ((fp = fopen(argv[i], "r")) == NULL) { |
119 |
|
sprintf(errmsg, |
217 |
|
{ |
218 |
|
extern FILE *freopen(); |
219 |
|
char buf[64]; |
220 |
+ |
int negax; |
221 |
|
int nerrs = 0; |
222 |
|
register char *cp; |
223 |
|
|
297 |
|
} |
298 |
|
cp = sskip(cp); |
299 |
|
continue; |
300 |
< |
case 'd': /* point sample density */ |
300 |
> |
case 'd': /* sample density / BSDF data */ |
301 |
|
if (*++cp != '=') |
302 |
|
break; |
303 |
< |
if (!isintd(++cp, " \t\n\r")) |
304 |
< |
break; |
305 |
< |
thisillum.sampdens = atoi(cp); |
303 |
> |
if (thisillum.sd != NULL) { |
304 |
> |
free_BSDF(thisillum.sd); |
305 |
> |
thisillum.sd = NULL; |
306 |
> |
} |
307 |
> |
if (!*++cp || isspace(*cp)) |
308 |
> |
continue; |
309 |
> |
if (isintd(++cp, " \t\n\r")) { |
310 |
> |
thisillum.sampdens = atoi(cp); |
311 |
> |
} else { |
312 |
> |
atos(buf, sizeof(buf), cp); |
313 |
> |
thisillum.sd = load_BSDF(buf); |
314 |
> |
if (thisillum.sd == NULL) |
315 |
> |
break; |
316 |
> |
} |
317 |
|
cp = sskip(cp); |
318 |
|
continue; |
319 |
< |
case 's': /* point super-samples */ |
319 |
> |
case 's': /* surface super-samples */ |
320 |
|
if (*++cp != '=') |
321 |
|
break; |
322 |
|
if (!isintd(++cp, " \t\n\r")) |
358 |
|
} |
359 |
|
doneheader = 0; |
360 |
|
continue; |
361 |
+ |
case 'u': /* up direction */ |
362 |
+ |
if (*++cp != '=') |
363 |
+ |
break; |
364 |
+ |
if (!*++cp || isspace(*cp)) { |
365 |
+ |
thisillum.udir = UDunknown; |
366 |
+ |
continue; |
367 |
+ |
} |
368 |
+ |
negax = 0; |
369 |
+ |
if (*cp == '+') |
370 |
+ |
cp++; |
371 |
+ |
else if (*cp == '-') { |
372 |
+ |
negax++; |
373 |
+ |
cp++; |
374 |
+ |
} |
375 |
+ |
switch (*cp++) { |
376 |
+ |
case 'x': |
377 |
+ |
case 'X': |
378 |
+ |
thisillum.udir = negax ? UDxneg : UDxpos; |
379 |
+ |
break; |
380 |
+ |
case 'y': |
381 |
+ |
case 'Y': |
382 |
+ |
thisillum.udir = negax ? UDyneg : UDypos; |
383 |
+ |
break; |
384 |
+ |
case 'z': |
385 |
+ |
case 'Z': |
386 |
+ |
thisillum.udir = negax ? UDxneg : UDxpos; |
387 |
+ |
break; |
388 |
+ |
default: |
389 |
+ |
thisillum.udir = UDunknown; |
390 |
+ |
break; |
391 |
+ |
} |
392 |
+ |
if (thisillum.udir == UDunknown || !isspace(*cp)) |
393 |
+ |
break; |
394 |
+ |
continue; |
395 |
+ |
case 't': /* object thickness */ |
396 |
+ |
if (*++cp != '=') |
397 |
+ |
break; |
398 |
+ |
if (!isfltd(++cp, " \t\n\r")) |
399 |
+ |
break; |
400 |
+ |
thisillum.thick = atof(cp); |
401 |
+ |
if (thisillum.thick < .0) |
402 |
+ |
thisillum.thick = .0; |
403 |
+ |
cp = sskip(cp); |
404 |
+ |
continue; |
405 |
|
case '!': /* processed file! */ |
406 |
|
sprintf(errmsg, "(%s): already processed!", nm); |
407 |
|
error(WARNING, errmsg); |
447 |
|
printf("d=%d\t\t\t\t# density of points\n", thisillum.sampdens); |
448 |
|
printf("s=%d\t\t\t\t# samples per point\n", thisillum.nsamps); |
449 |
|
printf("b=%f\t\t\t# minimum average brightness\n", thisillum.minbrt); |
450 |
+ |
switch (thisillum.udir) { |
451 |
+ |
case UDzneg: |
452 |
+ |
fputs("u=-Z\t\t\t\t# up is negative Z\n", stdout); |
453 |
+ |
break; |
454 |
+ |
case UDyneg: |
455 |
+ |
fputs("u=-Y\t\t\t\t# up is negative Y\n", stdout); |
456 |
+ |
break; |
457 |
+ |
case UDxneg: |
458 |
+ |
fputs("u=-X\t\t\t\t# up is negative X\n", stdout); |
459 |
+ |
break; |
460 |
+ |
case UDxpos: |
461 |
+ |
fputs("u=+X\t\t\t\t# up is positive X\n", stdout); |
462 |
+ |
break; |
463 |
+ |
case UDypos: |
464 |
+ |
fputs("u=+Y\t\t\t\t# up is positive Y\n", stdout); |
465 |
+ |
break; |
466 |
+ |
case UDzpos: |
467 |
+ |
fputs("u=+Z\t\t\t\t# up is positive Z\n", stdout); |
468 |
+ |
break; |
469 |
+ |
case UDunknown: |
470 |
+ |
break; |
471 |
+ |
} |
472 |
+ |
printf("t=%f\t\t\t# object thickness\n", thisillum.thick); |
473 |
|
} |
474 |
|
|
475 |
|
|