8 |
|
#include <signal.h> |
9 |
|
#include <ctype.h> |
10 |
|
|
11 |
< |
#include "platform.h" |
11 |
> |
#include "paths.h" /* win_popen() */ |
12 |
|
#include "mkillum.h" |
13 |
– |
#include "random.h" |
13 |
|
|
14 |
|
/* default parameters */ |
15 |
|
#define SAMPDENS 48 /* points per projected steradian */ |
24 |
|
|
25 |
|
struct illum_args thisillum = { /* our illum and default values */ |
26 |
|
0, |
28 |
– |
UDzpos, |
29 |
– |
0., |
27 |
|
DFLMAT, |
28 |
|
DFLDAT, |
29 |
|
0, |
30 |
|
VOIDID, |
31 |
|
SAMPDENS, |
32 |
|
NSAMPS, |
36 |
– |
NULL, |
33 |
|
0., |
34 |
|
}; |
35 |
|
|
45 |
|
int warnings = 1; /* print warnings? */ |
46 |
|
|
47 |
|
void init(char *octnm, int np); |
48 |
< |
void filter(register FILE *infp, char *name); |
48 |
> |
void filter(FILE *infp, char *name); |
49 |
|
void xoptions(char *s, char *nm); |
50 |
|
void printopts(void); |
51 |
< |
void printhead(register int ac, register char **av); |
51 |
> |
void printhead(int ac, char **av); |
52 |
|
void xobject(FILE *fp, char *nm); |
53 |
|
|
54 |
|
|
61 |
|
int nprocs = 1; |
62 |
|
FILE *fp; |
63 |
|
int rval; |
64 |
< |
register int i; |
64 |
> |
int i; |
65 |
|
/* set global arguments */ |
66 |
|
gargv = argv; |
67 |
|
progname = gargv[0]; |
68 |
|
/* set up rendering defaults */ |
69 |
< |
dstrsrc = 0.25; |
69 |
> |
dstrsrc = 0.5; |
70 |
|
directrelay = 3; |
75 |
– |
directvis = 0; |
71 |
|
ambounce = 2; |
72 |
|
/* get options from command line */ |
73 |
|
for (i = 1; i < argc; i++) { |
148 |
|
|
149 |
|
void |
150 |
|
eputs( /* put string to stderr */ |
151 |
< |
register char *s |
151 |
> |
char *s |
152 |
|
) |
153 |
|
{ |
154 |
|
static int midline = 0; |
173 |
|
|
174 |
|
|
175 |
|
void |
176 |
+ |
quit(ec) /* make sure exit is called */ |
177 |
+ |
int ec; |
178 |
+ |
{ |
179 |
+ |
if (ray_pnprocs > 0) /* close children if any */ |
180 |
+ |
ray_pclose(0); |
181 |
+ |
else if (ray_pnprocs < 0) |
182 |
+ |
_exit(ec); /* avoid flush() in child */ |
183 |
+ |
exit(ec); |
184 |
+ |
} |
185 |
+ |
|
186 |
+ |
|
187 |
+ |
void |
188 |
|
filter( /* process stream */ |
189 |
< |
register FILE *infp, |
189 |
> |
FILE *infp, |
190 |
|
char *name |
191 |
|
) |
192 |
|
{ |
193 |
|
char buf[512]; |
194 |
|
FILE *pfp; |
195 |
< |
register int c; |
195 |
> |
int c; |
196 |
|
|
197 |
|
while ((c = getc(infp)) != EOF) { |
198 |
|
if (isspace(c)) |
224 |
|
char *nm |
225 |
|
) |
226 |
|
{ |
220 |
– |
extern FILE *freopen(); |
227 |
|
char buf[64]; |
228 |
|
int negax; |
229 |
|
int nerrs = 0; |
230 |
< |
register char *cp; |
230 |
> |
char *cp; |
231 |
|
|
232 |
|
if (strncmp(s, "#@mkillum", 9) || !isspace(s[9])) { |
233 |
|
fputs(s, stdout); /* not for us */ |
305 |
|
} |
306 |
|
cp = sskip(cp); |
307 |
|
continue; |
308 |
< |
case 'd': /* sample density / BSDF data */ |
308 |
> |
case 'd': /* sample density */ |
309 |
|
if (*++cp != '=') |
310 |
|
break; |
305 |
– |
if (thisillum.sd != NULL) { |
306 |
– |
free_BSDF(thisillum.sd); |
307 |
– |
thisillum.sd = NULL; |
308 |
– |
} |
311 |
|
if (!*++cp || isspace(*cp)) |
312 |
|
continue; |
313 |
< |
if (isintd(++cp, " \t\n\r")) { |
313 |
> |
if (isintd(cp, " \t\n\r")) { |
314 |
|
thisillum.sampdens = atoi(cp); |
315 |
|
} else { |
316 |
< |
atos(buf, sizeof(buf), cp); |
317 |
< |
thisillum.sd = load_BSDF(buf); |
316 |
< |
if (thisillum.sd == NULL) |
317 |
< |
break; |
316 |
> |
error(WARNING, "direct BSDF input unsupported"); |
317 |
> |
goto opterr; |
318 |
|
} |
319 |
|
cp = sskip(cp); |
320 |
|
continue; |
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; |
363 |
|
case '!': /* processed file! */ |
364 |
|
sprintf(errmsg, "(%s): already processed!", nm); |
365 |
|
error(WARNING, errmsg); |
402 |
|
printf("l+\t\t\t\t# light type on\n"); |
403 |
|
else |
404 |
|
printf("l-\t\t\t\t# light type off\n"); |
405 |
< |
printf("d=%d\t\t\t\t# density of points\n", thisillum.sampdens); |
406 |
< |
printf("s=%d\t\t\t\t# samples per point\n", thisillum.nsamps); |
405 |
> |
printf("d=%d\t\t\t\t# density of directions\n", thisillum.sampdens); |
406 |
> |
printf("s=%d\t\t\t\t# samples per direction\n", thisillum.nsamps); |
407 |
|
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); |
408 |
|
} |
409 |
|
|
410 |
|
|
411 |
|
void |
412 |
|
printhead( /* print out header */ |
413 |
< |
register int ac, |
414 |
< |
register char **av |
413 |
> |
int ac, |
414 |
> |
char **av |
415 |
|
) |
416 |
|
{ |
417 |
|
putchar('#'); |