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; |
323 |
|
(*dev->comout)(buf); |
324 |
|
(*dev->comin)(buf, NULL); |
325 |
|
if (sscanf(buf, "%d", &i0) != 1) |
326 |
< |
break; |
326 |
> |
return(0); |
327 |
|
} |
328 |
|
ptr->i = i0; |
329 |
< |
break; |
329 |
> |
return(1); |
330 |
|
case 'r': /* real */ |
331 |
|
if (sscanf(str, "%lf", &d0) != 1) { |
332 |
|
(*dev->comout)(dsc); |
334 |
|
(*dev->comout)(buf); |
335 |
|
(*dev->comin)(buf, NULL); |
336 |
|
if (sscanf(buf, "%lf", &d0) != 1) |
337 |
< |
break; |
337 |
> |
return(0); |
338 |
|
} |
339 |
|
ptr->d = d0; |
340 |
< |
break; |
340 |
> |
return(1); |
341 |
|
case 'b': /* boolean */ |
342 |
|
if (sscanf(str, "%1s", buf) != 1) { |
343 |
|
(*dev->comout)(dsc); |
346 |
|
(*dev->comin)(buf, NULL); |
347 |
|
if (buf[0] == '\0' || |
348 |
|
index("yY+1tTnN-0fF", buf[0]) == NULL) |
349 |
< |
break; |
349 |
> |
return(0); |
350 |
|
} |
351 |
|
ptr->i = index("yY+1tT", buf[0]) != NULL; |
352 |
< |
break; |
352 |
> |
return(1); |
353 |
|
case 'C': /* color */ |
354 |
|
if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) { |
355 |
|
(*dev->comout)(dsc); |
360 |
|
(*dev->comout)(buf); |
361 |
|
(*dev->comin)(buf, NULL); |
362 |
|
if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3) |
363 |
< |
break; |
363 |
> |
return(0); |
364 |
|
} |
365 |
|
setcolor(ptr->C, d0, d1, d2); |
366 |
< |
break; |
366 |
> |
return(1); |
367 |
|
} |
368 |
|
} |
369 |
|
|
386 |
|
extern int ambssamp; |
387 |
|
extern int ambounce; |
388 |
|
extern int directinvis; |
389 |
+ |
extern double srcsizerat; |
390 |
|
extern int do_irrad; |
391 |
|
char buf[128]; |
392 |
|
|
393 |
|
if (s[0] == '\0') { |
394 |
|
(*dev->comout)( |
395 |
< |
"aa ab ad ar as av b dc di dj dt i lr lw sp st: "); |
395 |
> |
"aa ab ad ar as av b dc di dj ds dt i lr lw sp st: "); |
396 |
|
(*dev->comin)(buf, NULL); |
397 |
|
s = buf; |
398 |
|
} |
424 |
|
getparam(s+2, "direct invisibility", |
425 |
|
'b', &directinvis); |
426 |
|
break; |
427 |
+ |
case 's': /* sampling */ |
428 |
+ |
getparam(s+2, "direct sampling", 'r', &srcsizerat); |
429 |
+ |
break; |
430 |
|
default: |
431 |
|
goto badparam; |
432 |
|
} |
455 |
|
getparam(s+2, "ambient bounces", 'i', &ambounce); |
456 |
|
break; |
457 |
|
case 'r': |
458 |
< |
getparam(s+2, "ambient resolution", 'i', &ambres); |
459 |
< |
minarad = ambres > 0 ? thescene.cusize/ambres : 0.0; |
458 |
> |
if (getparam(s+2, "ambient resolution", 'i', &ambres)) |
459 |
> |
minarad = ambres > 0 ? |
460 |
> |
thescene.cusize/ambres : 0.0; |
461 |
|
break; |
462 |
|
default: |
463 |
|
goto badparam; |
466 |
|
case 's': /* sample */ |
467 |
|
switch (s[1]) { |
468 |
|
case 'p': /* pixel */ |
469 |
< |
getparam(s+2, "sample pixel", 'i', &psample); |
470 |
< |
pdepth = 0; |
469 |
> |
if (getparam(s+2, "sample pixel", 'i', &psample)) |
470 |
> |
pdepth = 0; |
471 |
|
break; |
472 |
|
case 't': /* threshold */ |
473 |
< |
getparam(s+2, "sample threshold", 'r', &maxdiff); |
474 |
< |
pdepth = 0; |
473 |
> |
if (getparam(s+2, "sample threshold", 'r', &maxdiff)) |
474 |
> |
pdepth = 0; |
475 |
|
break; |
476 |
|
default: |
477 |
|
goto badparam; |
538 |
|
(*dev->comout)(buf); |
539 |
|
} |
540 |
|
(*dev->comin)(buf, NULL); |
541 |
< |
sprintf(buf, "with value (%.6g %.6g %.6g)", |
541 |
> |
sprintf(buf, "value (%.5g %.5g %.5g) (%.1fL)", |
542 |
|
colval(thisray.rcol,RED), |
543 |
|
colval(thisray.rcol,GRN), |
544 |
< |
colval(thisray.rcol,BLU)); |
544 |
> |
colval(thisray.rcol,BLU), |
545 |
> |
luminance(thisray.rcol)); |
546 |
|
(*dev->comout)(buf); |
547 |
|
} |
548 |
|
(*dev->comin)(buf, NULL); |
574 |
|
/* write header */ |
575 |
|
fputs(progname, fp); |
576 |
|
fprintview(&ourview, fp); |
577 |
< |
putc('\n', fp); |
577 |
> |
if (octname != NULL) |
578 |
> |
fprintf(fp, " %s\n", octname); |
579 |
> |
else |
580 |
> |
putc('\n', fp); |
581 |
> |
fprintf(fp, "SOFTWARE= %s\n", VersionID); |
582 |
|
if (exposure != 1.0) |
583 |
|
fputexpos(exposure, fp); |
584 |
|
if (dev->pixaspect != 1.0) |
585 |
|
fputaspect(dev->pixaspect, fp); |
586 |
|
fputformat(COLRFMT, fp); |
587 |
|
putc('\n', fp); |
588 |
< |
fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp); |
588 |
> |
fprtresolu(hresolu, vresolu, fp); |
589 |
|
|
590 |
|
scanline = (COLR *)malloc(hresolu*sizeof(COLR)); |
591 |
|
if (scanline == NULL) { |