16 |
|
#include "rtprocess.h" /* win_popen() */ |
17 |
|
#include "paths.h" |
18 |
|
#include "ray.h" |
19 |
– |
#include "source.h" |
19 |
|
#include "ambient.h" |
20 |
|
#include "otypes.h" |
21 |
+ |
#include "otspecial.h" |
22 |
|
#include "rpaint.h" |
23 |
|
|
24 |
|
extern int psample; /* pixel sample size */ |
399 |
|
} |
400 |
|
if (thisray.rod < 0.0) /* don't look through other side */ |
401 |
|
flipsurface(&thisray); |
402 |
< |
VSUM(nv.vp, thisray.rop, thisray.ron, 2.0*FTINY); |
402 |
> |
VSUM(nv.vp, thisray.rop, thisray.ron, 20.0*FTINY); |
403 |
|
VCOPY(nv.vdir, thisray.ron); |
404 |
|
} else if (!sscanvec(sskip2(s,3), nv.vdir) || normalize(nv.vdir) == 0.0) |
405 |
|
VCOPY(nv.vdir, ourview.vdir); |
459 |
|
return; |
460 |
|
} |
461 |
|
} |
462 |
< |
if (*cp == '+' || *cp == '-') /* f-stops */ |
462 |
> |
if ((*cp == '+') | (*cp == '-')) /* f-stops */ |
463 |
|
e *= pow(2.0, atof(cp)); |
464 |
|
else /* multiplier */ |
465 |
|
e *= atof(cp); |
483 |
|
} |
484 |
|
|
485 |
|
typedef union {int i; double d; COLOR C;} *MyUptr; |
486 |
– |
#define FEQ(x,y) (fabs((x)-(y)) <= FTINY) |
486 |
|
|
487 |
|
int |
488 |
|
getparam( /* get variable from user */ |
520 |
|
if (sscanf(buf, "%lf", &d0) != 1) |
521 |
|
return(0); |
522 |
|
} |
523 |
< |
if (FEQ(ptr->d, d0)) |
523 |
> |
if (FRELEQ(ptr->d, d0)) |
524 |
|
return(0); |
525 |
|
ptr->d = d0; |
526 |
|
break; |
552 |
|
if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3) |
553 |
|
return(0); |
554 |
|
} |
555 |
< |
if (FEQ(colval(ptr->C,RED), d0) && |
556 |
< |
FEQ(colval(ptr->C,GRN), d1) && |
557 |
< |
FEQ(colval(ptr->C,BLU), d2)) |
555 |
> |
if (FRELEQ(colval(ptr->C,RED), d0) && |
556 |
> |
FRELEQ(colval(ptr->C,GRN), d1) && |
557 |
> |
FRELEQ(colval(ptr->C,BLU), d2)) |
558 |
|
return(0); |
559 |
|
setcolor(ptr->C, d0, d1, d2); |
560 |
|
break; |
588 |
|
case 'l': /* limit */ |
589 |
|
switch (s[1]) { |
590 |
|
case 'w': /* weight */ |
591 |
< |
getparam(s+2, "limit weight", 'r', |
593 |
< |
(void *)&minweight); |
591 |
> |
getparam(s+2, "limit weight", 'r', &minweight); |
592 |
|
break; |
593 |
|
case 'r': /* reflection */ |
594 |
< |
getparam(s+2, "limit reflection", 'i', |
597 |
< |
(void *)&maxdepth); |
594 |
> |
getparam(s+2, "limit reflection", 'i', &maxdepth); |
595 |
|
break; |
596 |
|
default: |
597 |
|
goto badparam; |
600 |
|
case 'd': /* direct */ |
601 |
|
switch (s[1]) { |
602 |
|
case 'j': /* jitter */ |
603 |
< |
getparam(s+2, "direct jitter", 'r', |
607 |
< |
(void *)&dstrsrc); |
603 |
> |
getparam(s+2, "direct jitter", 'r', &dstrsrc); |
604 |
|
break; |
605 |
|
case 'c': /* certainty */ |
606 |
< |
getparam(s+2, "direct certainty", 'r', |
611 |
< |
(void *)&shadcert); |
606 |
> |
getparam(s+2, "direct certainty", 'r', &shadcert); |
607 |
|
break; |
608 |
|
case 't': /* threshold */ |
609 |
< |
getparam(s+2, "direct threshold", 'r', |
615 |
< |
(void *)&shadthresh); |
609 |
> |
getparam(s+2, "direct threshold", 'r', &shadthresh); |
610 |
|
break; |
611 |
|
case 'v': /* visibility */ |
612 |
< |
getparam(s+2, "direct visibility", 'b', |
619 |
< |
(void *)&directvis); |
612 |
> |
getparam(s+2, "direct visibility", 'b', &directvis); |
613 |
|
break; |
614 |
|
case 's': /* sampling */ |
615 |
< |
getparam(s+2, "direct sampling", 'r', |
623 |
< |
(void *)&srcsizerat); |
615 |
> |
getparam(s+2, "direct sampling", 'r', &srcsizerat); |
616 |
|
break; |
617 |
|
default: |
618 |
|
goto badparam; |
628 |
|
case ' ': |
629 |
|
case 'y': case 'Y': case 't': case 'T': case '1': case '+': |
630 |
|
case 'n': case 'N': case 'f': case 'F': case '0': case '-': |
631 |
< |
getparam(s+1, "black and white", 'b', |
640 |
< |
(void *)&greyscale); |
631 |
> |
getparam(s+1, "black and white", 'b', &greyscale); |
632 |
|
newparam = prev_newp; |
633 |
|
break; |
634 |
|
default: |
636 |
|
} |
637 |
|
break; |
638 |
|
case 'i': /* irradiance */ |
639 |
< |
getparam(s+1, "irradiance", 'b', |
649 |
< |
(void *)&do_irrad); |
639 |
> |
getparam(s+1, "irradiance", 'b', &do_irrad); |
640 |
|
break; |
641 |
|
case 'a': /* ambient */ |
642 |
|
switch (s[1]) { |
643 |
|
case 'v': /* value */ |
644 |
< |
getparam(s+2, "ambient value", 'C', |
655 |
< |
(void *)ambval); |
644 |
> |
getparam(s+2, "ambient value", 'C', ambval); |
645 |
|
break; |
646 |
|
case 'w': /* weight */ |
647 |
< |
getparam(s+2, "ambient value weight", 'i', |
659 |
< |
(void *)&ambvwt); |
647 |
> |
getparam(s+2, "ambient value weight", 'i', &ambvwt); |
648 |
|
break; |
649 |
|
case 'a': /* accuracy */ |
650 |
< |
if (getparam(s+2, "ambient accuracy", 'r', |
663 |
< |
(void *)&ambacc)) |
650 |
> |
if (getparam(s+2, "ambient accuracy", 'r', &ambacc)) |
651 |
|
setambacc(ambacc); |
652 |
|
break; |
653 |
|
case 'd': /* divisions */ |
654 |
< |
getparam(s+2, "ambient divisions", 'i', |
668 |
< |
(void *)&ambdiv); |
654 |
> |
getparam(s+2, "ambient divisions", 'i', &ambdiv); |
655 |
|
break; |
656 |
|
case 's': /* samples */ |
657 |
< |
getparam(s+2, "ambient super-samples", 'i', |
672 |
< |
(void *)&ambssamp); |
657 |
> |
getparam(s+2, "ambient super-samples", 'i', &ambssamp); |
658 |
|
break; |
659 |
|
case 'b': /* bounces */ |
660 |
< |
getparam(s+2, "ambient bounces", 'i', |
676 |
< |
(void *)&ambounce); |
660 |
> |
getparam(s+2, "ambient bounces", 'i', &ambounce); |
661 |
|
break; |
662 |
|
case 'r': |
663 |
< |
if (getparam(s+2, "ambient resolution", 'i', |
680 |
< |
(void *)&ambres)) |
663 |
> |
if (getparam(s+2, "ambient resolution", 'i', &ambres)) |
664 |
|
setambres(ambres); |
665 |
|
break; |
666 |
|
default: |
670 |
|
case 'm': /* medium */ |
671 |
|
switch (s[1]) { |
672 |
|
case 'e': /* extinction coefficient */ |
673 |
< |
getparam(s+2, "extinction coefficient", 'C', |
691 |
< |
(void *)cextinction); |
673 |
> |
getparam(s+2, "extinction coefficient", 'C', cextinction); |
674 |
|
break; |
675 |
|
case 'a': /* scattering albedo */ |
676 |
< |
getparam(s+2, "scattering albedo", 'C', |
695 |
< |
(void *)salbedo); |
676 |
> |
getparam(s+2, "scattering albedo", 'C', salbedo); |
677 |
|
break; |
678 |
|
case 'g': /* scattering eccentricity */ |
679 |
< |
getparam(s+2, "scattering eccentricity", 'r', |
699 |
< |
(void *)&seccg); |
679 |
> |
getparam(s+2, "scattering eccentricity", 'r', &seccg); |
680 |
|
break; |
681 |
|
case 's': /* sampling distance */ |
682 |
< |
getparam(s+2, "mist sampling distance", 'r', |
703 |
< |
(void *)&ssampdist); |
682 |
> |
getparam(s+2, "mist sampling distance", 'r', &ssampdist); |
683 |
|
break; |
684 |
|
default: |
685 |
|
goto badparam; |
688 |
|
case 'p': /* pixel */ |
689 |
|
switch (s[1]) { |
690 |
|
case 's': /* sample */ |
691 |
< |
if (getparam(s+2, "pixel sample", 'i', |
713 |
< |
(void *)&psample)) |
691 |
> |
if (getparam(s+2, "pixel sample", 'i', &psample)) |
692 |
|
pdepth = 0; |
693 |
|
break; |
694 |
|
case 't': /* threshold */ |
695 |
< |
if (getparam(s+2, "pixel threshold", 'r', |
718 |
< |
(void *)&maxdiff)) |
695 |
> |
if (getparam(s+2, "pixel threshold", 'r', &maxdiff)) |
696 |
|
pdepth = 0; |
697 |
|
break; |
698 |
|
default: |
703 |
|
case 's': /* specular */ |
704 |
|
switch (s[1]) { |
705 |
|
case 's': /* sampling */ |
706 |
< |
getparam(s+2, "specular sampling", 'r', |
730 |
< |
(void *)&specjitter); |
706 |
> |
getparam(s+2, "specular sampling", 'r', &specjitter); |
707 |
|
break; |
708 |
|
case 't': /* threshold */ |
709 |
< |
getparam(s+2, "specular threshold", 'r', |
734 |
< |
(void *)&specthresh); |
709 |
> |
getparam(s+2, "specular threshold", 'r', &specthresh); |
710 |
|
break; |
711 |
|
default: |
712 |
|
goto badparam; |
731 |
|
{ |
732 |
|
RAY thisray; |
733 |
|
char buf[512]; |
734 |
+ |
COLOR col; |
735 |
|
|
736 |
|
thisray.rmax = 0.0; |
737 |
|
|
769 |
|
matspec[0] = '\0'; |
770 |
|
if (thisray.ro->omod != OVOID) { |
771 |
|
mod = objptr(thisray.ro->omod); |
772 |
< |
mat = findmaterial(mod); |
772 |
> |
mat = findmaterial(thisray.ro); |
773 |
|
} |
774 |
|
if (thisray.rod < 0.0) |
775 |
|
strcpy(matspec, "back of "); |
788 |
|
ofun[ino->otype].funame, ino->oname); |
789 |
|
(*dev->comout)(buf); |
790 |
|
(*dev->comin)(buf, NULL); |
791 |
< |
if (thisray.rot >= FHUGE) |
791 |
> |
if (thisray.rot >= FHUGE*.99) |
792 |
|
(*dev->comout)("at infinity"); |
793 |
|
else { |
794 |
|
sprintf(buf, "at (%.6g %.6g %.6g) (%.6g)", |
795 |
|
thisray.rop[0], thisray.rop[1], |
796 |
< |
thisray.rop[2], thisray.rt); |
796 |
> |
thisray.rop[2], raydistance(&thisray)); |
797 |
|
(*dev->comout)(buf); |
798 |
|
} |
799 |
|
(*dev->comin)(buf, NULL); |
800 |
+ |
scolor_rgb(col, thisray.rcol); |
801 |
|
sprintf(buf, "value (%.5g %.5g %.5g) (%.3gL)", |
802 |
< |
colval(thisray.rcol,RED), |
803 |
< |
colval(thisray.rcol,GRN), |
804 |
< |
colval(thisray.rcol,BLU), |
805 |
< |
luminance(thisray.rcol)); |
802 |
> |
colval(col,RED), |
803 |
> |
colval(col,GRN), |
804 |
> |
colval(col,BLU), |
805 |
> |
luminance(col)); |
806 |
|
(*dev->comout)(buf); |
807 |
|
} |
808 |
|
(*dev->comin)(buf, NULL); |
848 |
|
fputexpos(exposure, fp); |
849 |
|
if (dev->pixaspect != 1.0) |
850 |
|
fputaspect(dev->pixaspect, fp); |
851 |
+ |
fputprims(stdprims, fp); |
852 |
|
fputformat(COLRFMT, fp); |
853 |
|
putc('\n', fp); |
854 |
|
fprtresolu(hresolu, vresolu, fp); |