| 1 |
< |
/* Copyright (c) 1993 Regents of the University of California */ |
| 1 |
> |
/* Copyright (c) 1994 Regents of the University of California */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
| 11 |
|
#include "standard.h" |
| 12 |
|
#include "paths.h" |
| 13 |
|
#include <ctype.h> |
| 14 |
+ |
#include <sys/types.h> |
| 15 |
|
|
| 16 |
|
|
| 17 |
|
typedef struct { |
| 22 |
|
int (*fixval)(); /* assignment checking function */ |
| 23 |
|
} VARIABLE; |
| 24 |
|
|
| 25 |
< |
int onevalue(), catvalues(); |
| 25 |
> |
int onevalue(), catvalues(), boolvalue(), |
| 26 |
> |
qualvalue(), fltvalue(), intvalue(); |
| 27 |
|
|
| 28 |
|
/* variables */ |
| 29 |
|
#define OBJECT 0 /* object files */ |
| 63 |
|
{"pfilt", 2, 0, NULL, catvalues}, |
| 64 |
|
{"view", 2, 0, NULL, NULL}, |
| 65 |
|
{"ZONE", 2, 0, NULL, onevalue}, |
| 66 |
< |
{"QUALITY", 3, 0, NULL, onevalue}, |
| 66 |
> |
{"QUALITY", 3, 0, NULL, qualvalue}, |
| 67 |
|
{"OCTREE", 3, 0, NULL, onevalue}, |
| 68 |
|
{"PICTURE", 3, 0, NULL, onevalue}, |
| 69 |
|
{"AMBFILE", 3, 0, NULL, onevalue}, |
| 70 |
|
{"OPTFILE", 3, 0, NULL, onevalue}, |
| 71 |
< |
{"EXPOSURE", 3, 0, NULL, onevalue}, |
| 71 |
> |
{"EXPOSURE", 3, 0, NULL, fltvalue}, |
| 72 |
|
{"RESOLUTION", 3, 0, NULL, onevalue}, |
| 73 |
|
{"UP", 2, 0, NULL, onevalue}, |
| 74 |
< |
{"INDIRECT", 3, 0, NULL, onevalue}, |
| 75 |
< |
{"DETAIL", 3, 0, NULL, onevalue}, |
| 76 |
< |
{"PENUMBRAS", 3, 0, NULL, onevalue}, |
| 77 |
< |
{"VARIABILITY", 3, 0, NULL, onevalue}, |
| 74 |
> |
{"INDIRECT", 3, 0, NULL, intvalue}, |
| 75 |
> |
{"DETAIL", 3, 0, NULL, qualvalue}, |
| 76 |
> |
{"PENUMBRAS", 3, 0, NULL, boolvalue}, |
| 77 |
> |
{"VARIABILITY", 3, 0, NULL, qualvalue}, |
| 78 |
|
{"REPORT", 3, 0, NULL, onevalue}, |
| 79 |
|
}; |
| 80 |
|
|
| 81 |
|
VARIABLE *matchvar(); |
| 82 |
|
char *nvalue(); |
| 81 |
– |
int vscale(); |
| 83 |
|
|
| 84 |
|
#define UPPER(c) ((c)&~0x20) /* ASCII trick */ |
| 85 |
|
|
| 88 |
|
#define vval(vc) (vv[vc].value) |
| 89 |
|
#define vint(vc) atoi(vval(vc)) |
| 90 |
|
#define vlet(vc) UPPER(vval(vc)[0]) |
| 91 |
+ |
#define vscale vlet |
| 92 |
|
#define vbool(vc) (vlet(vc)=='T') |
| 93 |
|
|
| 94 |
< |
#define HIGH 2 |
| 95 |
< |
#define MEDIUM 1 |
| 96 |
< |
#define LOW 0 |
| 94 |
> |
#define HIGH 'H' |
| 95 |
> |
#define MEDIUM 'M' |
| 96 |
> |
#define LOW 'L' |
| 97 |
|
|
| 96 |
– |
int lowqopts(), medqopts(), hiqopts(); |
| 97 |
– |
int (*setqopts[3])() = {lowqopts, medqopts, hiqopts}; |
| 98 |
– |
|
| 99 |
– |
#define renderopts (*setqopts[vscale(QUALITY)]) |
| 100 |
– |
|
| 98 |
|
/* overture calculation file */ |
| 99 |
|
#ifdef NIX |
| 100 |
|
char overfile[] = "overture.raw"; |
| 102 |
|
char overfile[] = "/dev/null"; |
| 103 |
|
#endif |
| 104 |
|
|
| 105 |
< |
extern unsigned long fdate(), time(); |
| 105 |
> |
extern time_t fdate(), time(); |
| 106 |
|
|
| 107 |
< |
unsigned long scenedate; /* date of latest scene or object file */ |
| 108 |
< |
unsigned long octreedate; /* date of octree */ |
| 109 |
< |
unsigned long matdate; /* date of latest material file */ |
| 110 |
< |
unsigned long illumdate; /* date of last illum file */ |
| 107 |
> |
time_t scenedate; /* date of latest scene or object file */ |
| 108 |
> |
time_t octreedate; /* date of octree */ |
| 109 |
> |
time_t matdate; /* date of latest material file */ |
| 110 |
> |
time_t illumdate; /* date of last illum file */ |
| 111 |
|
|
| 112 |
|
char *oct0name; /* name of pre-mkillum octree */ |
| 113 |
< |
unsigned long oct0date; /* date of pre-mkillum octree */ |
| 113 |
> |
time_t oct0date; /* date of pre-mkillum octree */ |
| 114 |
|
char *oct1name; /* name of post-mkillum octree */ |
| 115 |
< |
unsigned long oct1date; /* date of post-mkillum octree (>= matdate) */ |
| 115 |
> |
time_t oct1date; /* date of post-mkillum octree (>= matdate) */ |
| 116 |
|
|
| 117 |
+ |
int nowarn = 0; /* no warnings */ |
| 118 |
|
int explicate = 0; /* explicate variables */ |
| 119 |
|
int silent = 0; /* do work silently */ |
| 120 |
|
int noaction = 0; /* don't do anything */ |
| 159 |
|
case 'v': |
| 160 |
|
viewselect = argv[++i]; |
| 161 |
|
break; |
| 162 |
+ |
case 'w': |
| 163 |
+ |
nowarn++; |
| 164 |
+ |
break; |
| 165 |
|
default: |
| 166 |
|
goto userr; |
| 167 |
|
} |
| 257 |
|
register char *ass; |
| 258 |
|
{ |
| 259 |
|
char varname[32]; |
| 259 |
– |
char varval[512]; |
| 260 |
|
int n; |
| 261 |
|
register char *cp; |
| 262 |
|
register VARIABLE *vp; |
| 277 |
|
for (n = strlen(ass); n > 0; n--) |
| 278 |
|
if (!isspace(ass[n-1])) |
| 279 |
|
break; |
| 280 |
< |
if (!n) { |
| 280 |
> |
if (!n && !nowarn) { |
| 281 |
|
fprintf(stderr, "%s: warning - missing value for variable '%s'\n", |
| 282 |
|
progname, varname); |
| 283 |
|
return; |
| 348 |
|
} |
| 349 |
|
|
| 350 |
|
|
| 351 |
– |
int |
| 352 |
– |
vscale(vc) /* return scale for variable vc */ |
| 353 |
– |
int vc; |
| 354 |
– |
{ |
| 355 |
– |
switch(vlet(vc)) { |
| 356 |
– |
case 'H': |
| 357 |
– |
return(HIGH); |
| 358 |
– |
case 'M': |
| 359 |
– |
return(MEDIUM); |
| 360 |
– |
case 'L': |
| 361 |
– |
return(LOW); |
| 362 |
– |
} |
| 363 |
– |
badvalue(vc); |
| 364 |
– |
} |
| 365 |
– |
|
| 366 |
– |
|
| 351 |
|
checkvalues() /* check assignments */ |
| 352 |
|
{ |
| 353 |
|
register int i; |
| 363 |
|
{ |
| 364 |
|
if (vp->nass < 2) |
| 365 |
|
return; |
| 366 |
< |
fprintf(stderr, "%s: warning - multiple assignment of variable '%s'\n", |
| 366 |
> |
if (!nowarn) |
| 367 |
> |
fprintf(stderr, |
| 368 |
> |
"%s: warning - multiple assignment of variable '%s'\n", |
| 369 |
|
progname, vp->name); |
| 370 |
|
do |
| 371 |
|
vp->value += strlen(vp->value)+1; |
| 388 |
|
} |
| 389 |
|
|
| 390 |
|
|
| 391 |
< |
unsigned long |
| 391 |
> |
int |
| 392 |
> |
badmatch(tv, cv) /* case insensitive truncated comparison */ |
| 393 |
> |
register char *tv, *cv; |
| 394 |
> |
{ |
| 395 |
> |
if (!*tv) return(1); /* null string cannot match */ |
| 396 |
> |
do |
| 397 |
> |
if (UPPER(*tv) != *cv++) |
| 398 |
> |
return(1); |
| 399 |
> |
while (*++tv); |
| 400 |
> |
return(0); /* OK */ |
| 401 |
> |
} |
| 402 |
> |
|
| 403 |
> |
|
| 404 |
> |
boolvalue(vp) /* check boolean for legal values */ |
| 405 |
> |
register VARIABLE *vp; |
| 406 |
> |
{ |
| 407 |
> |
if (!vp->nass) return; |
| 408 |
> |
onevalue(vp); |
| 409 |
> |
switch (UPPER(vp->value[0])) { |
| 410 |
> |
case 'T': |
| 411 |
> |
if (badmatch(vp->value, "TRUE")) break; |
| 412 |
> |
return; |
| 413 |
> |
case 'F': |
| 414 |
> |
if (badmatch(vp->value, "FALSE")) break; |
| 415 |
> |
return; |
| 416 |
> |
} |
| 417 |
> |
fprintf(stderr, "%s: illegal value for boolean variable '%s'\n", |
| 418 |
> |
progname, vp->name); |
| 419 |
> |
exit(1); |
| 420 |
> |
} |
| 421 |
> |
|
| 422 |
> |
|
| 423 |
> |
qualvalue(vp) /* check qualitative var. for legal values */ |
| 424 |
> |
register VARIABLE *vp; |
| 425 |
> |
{ |
| 426 |
> |
if (!vp->nass) return; |
| 427 |
> |
onevalue(vp); |
| 428 |
> |
switch (UPPER(vp->value[0])) { |
| 429 |
> |
case 'L': |
| 430 |
> |
if (badmatch(vp->value, "LOW")) break; |
| 431 |
> |
return; |
| 432 |
> |
case 'M': |
| 433 |
> |
if (badmatch(vp->value, "MEDIUM")) break; |
| 434 |
> |
return; |
| 435 |
> |
case 'H': |
| 436 |
> |
if (badmatch(vp->value, "HIGH")) break; |
| 437 |
> |
return; |
| 438 |
> |
} |
| 439 |
> |
fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n", |
| 440 |
> |
progname, vp->name); |
| 441 |
> |
exit(1); |
| 442 |
> |
} |
| 443 |
> |
|
| 444 |
> |
|
| 445 |
> |
intvalue(vp) /* check integer variable for legal values */ |
| 446 |
> |
register VARIABLE *vp; |
| 447 |
> |
{ |
| 448 |
> |
if (!vp->nass) return; |
| 449 |
> |
onevalue(vp); |
| 450 |
> |
if (isint(vp->value)) return; |
| 451 |
> |
fprintf(stderr, "%s: illegal value for integer variable '%s'\n", |
| 452 |
> |
progname, vp->name); |
| 453 |
> |
exit(1); |
| 454 |
> |
} |
| 455 |
> |
|
| 456 |
> |
|
| 457 |
> |
fltvalue(vp) /* check float variable for legal values */ |
| 458 |
> |
register VARIABLE *vp; |
| 459 |
> |
{ |
| 460 |
> |
if (!vp->nass) return; |
| 461 |
> |
onevalue(vp); |
| 462 |
> |
if (isflt(vp->value)) return; |
| 463 |
> |
fprintf(stderr, "%s: illegal value for real variable '%s'\n", |
| 464 |
> |
progname, vp->name); |
| 465 |
> |
exit(1); |
| 466 |
> |
} |
| 467 |
> |
|
| 468 |
> |
|
| 469 |
> |
time_t |
| 470 |
|
checklast(fnames) /* check files and find most recent */ |
| 471 |
|
register char *fnames; |
| 472 |
|
{ |
| 473 |
|
char thisfile[MAXPATH]; |
| 474 |
< |
unsigned long thisdate, lastdate = 0; |
| 474 |
> |
time_t thisdate, lastdate = 0; |
| 475 |
|
register char *cp; |
| 476 |
|
|
| 477 |
|
if (fnames == NULL) |
| 519 |
|
|
| 520 |
|
checkfiles() /* check for existence and modified times */ |
| 521 |
|
{ |
| 522 |
< |
unsigned long objdate; |
| 522 |
> |
time_t objdate; |
| 523 |
|
|
| 524 |
|
if (!vdef(OCTREE)) { |
| 525 |
|
if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL) |
| 647 |
|
|
| 648 |
|
printvals() /* print variable values */ |
| 649 |
|
{ |
| 650 |
< |
register int i, j; |
| 650 |
> |
int i, j, clipline; |
| 651 |
> |
register char *cp; |
| 652 |
> |
register int k; |
| 653 |
|
|
| 654 |
< |
for (i = 0; i < NVARS; i++) |
| 655 |
< |
for (j = 0; j < vdef(i); j++) |
| 656 |
< |
printf("%s= %s\n", vnam(i), nvalue(vv+i, j)); |
| 654 |
> |
for (i = 0; i < NVARS; i++) /* print each variable */ |
| 655 |
> |
for (j = 0; j < vdef(i); j++) { /* print each assignment */ |
| 656 |
> |
fputs(vnam(i), stdout); |
| 657 |
> |
fputs("= ", stdout); |
| 658 |
> |
k = clipline = ( vv[i].fixval == catvalues ? 64 : 320 ) |
| 659 |
> |
- strlen(vnam(i)) ; |
| 660 |
> |
cp = nvalue(vv+i, j); |
| 661 |
> |
while (*cp) { |
| 662 |
> |
putchar(*cp++); |
| 663 |
> |
if (--k <= 0) { /* line too long */ |
| 664 |
> |
while (*cp && !isspace(*cp)) |
| 665 |
> |
putchar(*cp++); /* finish this word */ |
| 666 |
> |
if (*cp) { /* start new line */ |
| 667 |
> |
putchar('\n'); |
| 668 |
> |
fputs(vnam(i), stdout); |
| 669 |
> |
putchar('='); |
| 670 |
> |
k = clipline; |
| 671 |
> |
} |
| 672 |
> |
} |
| 673 |
> |
} |
| 674 |
> |
putchar('\n'); |
| 675 |
> |
} |
| 676 |
|
fflush(stdout); |
| 677 |
|
} |
| 678 |
|
|
| 699 |
|
unlink(vval(OCTREE)); |
| 700 |
|
exit(1); |
| 701 |
|
} |
| 702 |
< |
octreedate = time(0); |
| 702 |
> |
octreedate = time((time_t *)NULL); |
| 703 |
|
} |
| 704 |
|
if (oct1name == vval(OCTREE)) /* no mkillum? */ |
| 705 |
|
oct1date = octreedate > matdate ? octreedate : matdate; |
| 725 |
|
unlink(oct0name); |
| 726 |
|
exit(1); |
| 727 |
|
} |
| 728 |
< |
oct0date = time(0); |
| 728 |
> |
oct0date = time((time_t *)NULL); |
| 729 |
|
} |
| 730 |
|
mkillumopts(mkopts); /* build mkillum command */ |
| 731 |
|
mktemp(illumtmp); |
| 753 |
|
unlink(oct1name); |
| 754 |
|
exit(1); |
| 755 |
|
} |
| 756 |
< |
oct1date = time(0); |
| 756 |
> |
oct1date = time((time_t *)NULL); |
| 757 |
|
rmfile(illumtmp); |
| 758 |
|
} |
| 759 |
|
|
| 793 |
|
|
| 794 |
|
checkambfile() /* check date on ambient file */ |
| 795 |
|
{ |
| 796 |
< |
unsigned long afdate; |
| 796 |
> |
time_t afdate; |
| 797 |
|
|
| 798 |
|
if (!vdef(AMBFILE)) |
| 799 |
|
return; |
| 808 |
|
ambval() /* compute ambient value */ |
| 809 |
|
{ |
| 810 |
|
if (vdef(EXPOSURE)) { |
| 726 |
– |
if (!isflt(vval(EXPOSURE))) |
| 727 |
– |
badvalue(EXPOSURE); |
| 811 |
|
if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-') |
| 812 |
|
return(.5/pow(2.,atof(vval(EXPOSURE)))); |
| 813 |
|
return(.5/atof(vval(EXPOSURE))); |
| 820 |
|
} |
| 821 |
|
|
| 822 |
|
|
| 823 |
+ |
renderopts(op) /* set rendering options */ |
| 824 |
+ |
char *op; |
| 825 |
+ |
{ |
| 826 |
+ |
switch(vscale(QUALITY)) { |
| 827 |
+ |
case LOW: |
| 828 |
+ |
lowqopts(op); |
| 829 |
+ |
break; |
| 830 |
+ |
case MEDIUM: |
| 831 |
+ |
medqopts(op); |
| 832 |
+ |
break; |
| 833 |
+ |
case HIGH: |
| 834 |
+ |
hiqopts(op); |
| 835 |
+ |
break; |
| 836 |
+ |
} |
| 837 |
+ |
} |
| 838 |
+ |
|
| 839 |
+ |
|
| 840 |
|
lowqopts(op) /* low quality rendering options */ |
| 841 |
|
register char *op; |
| 842 |
|
{ |
| 932 |
|
} |
| 933 |
|
op = addarg(op, "-pt .08"); |
| 934 |
|
if (vbool(PENUMBRAS)) |
| 935 |
< |
op = addarg(op, "-ds .2 -dj .35"); |
| 935 |
> |
op = addarg(op, "-ds .2 -dj .5"); |
| 936 |
|
else |
| 937 |
|
op = addarg(op, "-ds .3"); |
| 938 |
|
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); |
| 1323 |
|
sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname); |
| 1324 |
|
if (rvdevice != NULL) |
| 1325 |
|
sprintf(combuf+strlen(combuf), "-o %s ", rvdevice); |
| 1326 |
+ |
if (vdef(EXPOSURE)) |
| 1327 |
+ |
sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE)); |
| 1328 |
|
strcat(combuf, oct1name); |
| 1329 |
|
if (runcom(combuf)) { /* run it */ |
| 1330 |
|
fprintf(stderr, "%s: error running rview\n", progname); |
| 1344 |
|
/* get pfilt options */ |
| 1345 |
|
pfiltopts(pfopts); |
| 1346 |
|
/* get resolution, reporting */ |
| 1347 |
< |
mult = vscale(QUALITY)+1; |
| 1347 |
> |
switch (vscale(QUALITY)) { |
| 1348 |
> |
case LOW: |
| 1349 |
> |
mult = 1; |
| 1350 |
> |
break; |
| 1351 |
> |
case MEDIUM: |
| 1352 |
> |
mult = 2; |
| 1353 |
> |
break; |
| 1354 |
> |
case HIGH: |
| 1355 |
> |
mult = 3; |
| 1356 |
> |
break; |
| 1357 |
> |
} |
| 1358 |
|
{ |
| 1359 |
|
int xres, yres; |
| 1360 |
|
double aspect; |
| 1415 |
|
} |
| 1416 |
|
sprintf(combuf, "rpict%s %s %s%s %s > %s", |
| 1417 |
|
rep, vw, res, opts, |
| 1418 |
< |
oct1name, rawfile); |
| 1418 |
> |
oct1name, rawfile); |
| 1419 |
|
} |
| 1420 |
|
if (runcom(combuf)) { /* run rpict */ |
| 1421 |
|
fprintf(stderr, "%s: error rendering view %s\n", |