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