18 |
|
|
19 |
|
#include "rpaint.h" |
20 |
|
|
21 |
+ |
#include "resolu.h" |
22 |
+ |
|
23 |
|
#include <ctype.h> |
24 |
|
|
25 |
|
#define CTRL(c) ('c'-'@') |
26 |
|
|
27 |
+ |
extern char VersionID[]; |
28 |
|
extern char *progname; |
29 |
+ |
extern char *octname; |
30 |
|
|
31 |
|
|
32 |
|
getframe(s) /* get a new frame */ |
144 |
|
if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */ |
145 |
|
copystruct(&nv, &stdview); |
146 |
|
if ((fname = getpath(buf, NULL, 0)) == NULL || |
147 |
< |
(success = viewfile(fname, &nv, 0, 0)) == -1) { |
147 |
> |
(success = viewfile(fname, &nv, NULL)) == -1) { |
148 |
|
sprintf(errmsg, "cannot open \"%s\"", buf); |
149 |
|
error(COMMAND, errmsg); |
150 |
|
return; |
246 |
|
getexposure(s) /* get new exposure */ |
247 |
|
char *s; |
248 |
|
{ |
245 |
– |
double atof(), pow(), fabs(); |
249 |
|
char buf[128]; |
250 |
|
register char *cp; |
251 |
|
register PNODE *p; |
322 |
|
(*dev->comout)(buf); |
323 |
|
(*dev->comin)(buf, NULL); |
324 |
|
if (sscanf(buf, "%d", &i0) != 1) |
325 |
< |
break; |
325 |
> |
return(0); |
326 |
|
} |
327 |
|
ptr->i = i0; |
328 |
< |
break; |
328 |
> |
return(1); |
329 |
|
case 'r': /* real */ |
330 |
|
if (sscanf(str, "%lf", &d0) != 1) { |
331 |
|
(*dev->comout)(dsc); |
333 |
|
(*dev->comout)(buf); |
334 |
|
(*dev->comin)(buf, NULL); |
335 |
|
if (sscanf(buf, "%lf", &d0) != 1) |
336 |
< |
break; |
336 |
> |
return(0); |
337 |
|
} |
338 |
|
ptr->d = d0; |
339 |
< |
break; |
339 |
> |
return(1); |
340 |
|
case 'b': /* boolean */ |
341 |
|
if (sscanf(str, "%1s", buf) != 1) { |
342 |
|
(*dev->comout)(dsc); |
343 |
< |
sprintf(buf, " (%c): ", ptr->i ? 'y' : 'n'); |
343 |
> |
sprintf(buf, "? (%c): ", ptr->i ? 'y' : 'n'); |
344 |
|
(*dev->comout)(buf); |
345 |
|
(*dev->comin)(buf, NULL); |
346 |
|
if (buf[0] == '\0' || |
347 |
|
index("yY+1tTnN-0fF", buf[0]) == NULL) |
348 |
< |
break; |
348 |
> |
return(0); |
349 |
|
} |
350 |
|
ptr->i = index("yY+1tT", buf[0]) != NULL; |
351 |
< |
break; |
351 |
> |
return(1); |
352 |
|
case 'C': /* color */ |
353 |
|
if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) { |
354 |
|
(*dev->comout)(dsc); |
359 |
|
(*dev->comout)(buf); |
360 |
|
(*dev->comin)(buf, NULL); |
361 |
|
if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3) |
362 |
< |
break; |
362 |
> |
return(0); |
363 |
|
} |
364 |
|
setcolor(ptr->C, d0, d1, d2); |
365 |
< |
break; |
365 |
> |
return(1); |
366 |
|
} |
367 |
|
} |
368 |
|
|
385 |
|
extern int ambssamp; |
386 |
|
extern int ambounce; |
387 |
|
extern int directinvis; |
388 |
+ |
extern double srcsizerat; |
389 |
|
extern int do_irrad; |
390 |
|
char buf[128]; |
391 |
|
|
392 |
|
if (s[0] == '\0') { |
393 |
|
(*dev->comout)( |
394 |
< |
"aa ab ad ar as av b dc di dj dt i lr lw sp st: "); |
394 |
> |
"aa ab ad ar as av b dc di dj ds dt i lr lw sp st: "); |
395 |
|
(*dev->comin)(buf, NULL); |
396 |
|
s = buf; |
397 |
|
} |
423 |
|
getparam(s+2, "direct invisibility", |
424 |
|
'b', &directinvis); |
425 |
|
break; |
426 |
+ |
case 's': /* sampling */ |
427 |
+ |
getparam(s+2, "direct sampling", 'r', &srcsizerat); |
428 |
+ |
break; |
429 |
|
default: |
430 |
|
goto badparam; |
431 |
|
} |
454 |
|
getparam(s+2, "ambient bounces", 'i', &ambounce); |
455 |
|
break; |
456 |
|
case 'r': |
457 |
< |
getparam(s+2, "ambient resolution", 'i', &ambres); |
458 |
< |
minarad = ambres > 0 ? thescene.cusize/ambres : 0.0; |
457 |
> |
if (getparam(s+2, "ambient resolution", 'i', &ambres)) |
458 |
> |
minarad = ambres > 0 ? |
459 |
> |
thescene.cusize/ambres : 0.0; |
460 |
|
break; |
461 |
|
default: |
462 |
|
goto badparam; |
465 |
|
case 's': /* sample */ |
466 |
|
switch (s[1]) { |
467 |
|
case 'p': /* pixel */ |
468 |
< |
getparam(s+2, "sample pixel", 'i', &psample); |
469 |
< |
pdepth = 0; |
468 |
> |
if (getparam(s+2, "sample pixel", 'i', &psample)) |
469 |
> |
pdepth = 0; |
470 |
|
break; |
471 |
|
case 't': /* threshold */ |
472 |
< |
getparam(s+2, "sample threshold", 'r', &maxdiff); |
473 |
< |
pdepth = 0; |
472 |
> |
if (getparam(s+2, "sample threshold", 'r', &maxdiff)) |
473 |
> |
pdepth = 0; |
474 |
|
break; |
475 |
|
default: |
476 |
|
goto badparam; |
537 |
|
(*dev->comout)(buf); |
538 |
|
} |
539 |
|
(*dev->comin)(buf, NULL); |
540 |
< |
sprintf(buf, "with value (%.6g %.6g %.6g)", |
540 |
> |
sprintf(buf, "value (%.5g %.5g %.5g) (%.1fL)", |
541 |
|
colval(thisray.rcol,RED), |
542 |
|
colval(thisray.rcol,GRN), |
543 |
< |
colval(thisray.rcol,BLU)); |
543 |
> |
colval(thisray.rcol,BLU), |
544 |
> |
luminance(thisray.rcol)); |
545 |
|
(*dev->comout)(buf); |
546 |
|
} |
547 |
|
(*dev->comin)(buf, NULL); |
573 |
|
/* write header */ |
574 |
|
fputs(progname, fp); |
575 |
|
fprintview(&ourview, fp); |
576 |
< |
putc('\n', fp); |
576 |
> |
if (octname != NULL) |
577 |
> |
fprintf(fp, " %s\n", octname); |
578 |
> |
else |
579 |
> |
putc('\n', fp); |
580 |
> |
fprintf(fp, "SOFTWARE= %s\n", VersionID); |
581 |
|
if (exposure != 1.0) |
582 |
|
fputexpos(exposure, fp); |
583 |
|
if (dev->pixaspect != 1.0) |
584 |
|
fputaspect(dev->pixaspect, fp); |
585 |
|
fputformat(COLRFMT, fp); |
586 |
|
putc('\n', fp); |
587 |
< |
fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp); |
587 |
> |
fprtresolu(hresolu, vresolu, fp); |
588 |
|
|
589 |
|
scanline = (COLR *)malloc(hresolu*sizeof(COLR)); |
590 |
|
if (scanline == NULL) { |