26 |
|
#define zscan(y) (ourzbuf+(y)*hresolu) |
27 |
|
#define averaging (ourweigh != NULL) |
28 |
|
|
29 |
< |
#define MAXWT 100. /* maximum pixel weight (averaging) */ |
29 |
> |
#define MAXWT 1000. /* maximum pixel weight (averaging) */ |
30 |
|
|
31 |
|
#define F_FORE 1 /* fill foreground */ |
32 |
|
#define F_BACK 2 /* fill background */ |
52 |
|
double zeps = .02; /* allowed z epsilon */ |
53 |
|
|
54 |
|
COLR *ourpict; /* output picture (COLR's) */ |
55 |
< |
COLOR *ourspict; /* output pixel sums (-a option) */ |
56 |
< |
float *ourweigh = NULL; /* output pixel weights (-a option) */ |
55 |
> |
COLOR *ourspict; /* output pixel sums (averaging) */ |
56 |
> |
float *ourweigh = NULL; /* output pixel weights (averaging) */ |
57 |
|
float *ourzbuf; /* corresponding z-buffer */ |
58 |
|
|
59 |
|
char *progname; |
212 |
|
goto userr; |
213 |
|
if (fillsamp == 1) |
214 |
|
fillo &= ~F_BACK; |
215 |
+ |
if (doavg < 0) |
216 |
+ |
doavg = (argc-i) > 2; |
217 |
|
/* set view */ |
218 |
|
if ((err = setview(&ourview)) != NULL) { |
219 |
|
fprintf(stderr, "%s: %s\n", progname, err); |
221 |
|
} |
222 |
|
normaspect(viewaspect(&ourview), &pixaspect, &hresolu, &vresolu); |
223 |
|
/* allocate frame */ |
222 |
– |
if (doavg < 0) |
223 |
– |
doavg = (argc-i) > 2; |
224 |
|
if (doavg) { |
225 |
|
ourspict = (COLOR *)bmalloc(hresolu*vresolu*sizeof(COLOR)); |
226 |
|
ourweigh = (float *)bmalloc(hresolu*vresolu*sizeof(float)); |
490 |
|
l1 = ABS(s1x); |
491 |
|
if (p1isy = (ABS(s1y) > l1)) |
492 |
|
l1 = ABS(s1y); |
493 |
< |
if (l1 < 1) |
493 |
> |
else if (l1 < 1) |
494 |
|
l1 = 1; |
495 |
|
} else { |
496 |
|
l1 = s1x = s1y = 1; |
548 |
|
|
549 |
|
double |
550 |
|
movepixel(pos) /* reposition image point */ |
551 |
< |
FVECT pos; |
551 |
> |
register FVECT pos; |
552 |
|
{ |
553 |
– |
double d0, d1; |
553 |
|
FVECT pt, tdir, odir; |
554 |
+ |
double d; |
555 |
|
register int i; |
556 |
|
|
557 |
|
if (pos[2] <= 0) /* empty pixel */ |
558 |
|
return(0); |
559 |
– |
if (normdist && theirview.type == VT_PER) { /* adjust distance */ |
560 |
– |
d0 = pos[0] + theirview.hoff - .5; |
561 |
– |
d1 = pos[1] + theirview.voff - .5; |
562 |
– |
pos[2] /= sqrt(1. + d0*d0*theirview.hn2 + d1*d1*theirview.vn2); |
563 |
– |
} |
559 |
|
if (!averaging && hasmatrix) { |
560 |
|
pos[0] += theirview.hoff - .5; |
561 |
|
pos[1] += theirview.voff - .5; |
562 |
|
if (theirview.type == VT_PER) { |
563 |
+ |
if (normdist) /* adjust distance */ |
564 |
+ |
pos[2] /= sqrt(1. + pos[0]*pos[0]*theirview.hn2 |
565 |
+ |
+ pos[1]*pos[1]*theirview.vn2); |
566 |
|
pos[0] *= pos[2]; |
567 |
|
pos[1] *= pos[2]; |
568 |
|
} |
578 |
|
} else { |
579 |
|
if (viewray(pt, tdir, &theirview, pos[0], pos[1]) < -FTINY) |
580 |
|
return(0); |
581 |
+ |
if (!normdist && theirview.type == VT_PER) /* adjust */ |
582 |
+ |
pos[2] *= sqrt(1. + pos[0]*pos[0]*theirview.hn2 |
583 |
+ |
+ pos[1]*pos[1]*theirview.vn2); |
584 |
|
pt[0] += tdir[0]*pos[2]; |
585 |
|
pt[1] += tdir[1]*pos[2]; |
586 |
|
pt[2] += tdir[2]*pos[2]; |
597 |
|
else |
598 |
|
for (i = 0; i < 3; i++) |
599 |
|
odir[i] = (pt[i] - ourview.vp[i])/pos[2]; |
600 |
< |
d0 = DOT(odir,tdir); /* compute pixel weight */ |
601 |
< |
if (d0 <= FTINY) |
601 |
< |
return(0); /* relative angle >= 90 degrees */ |
602 |
< |
if (d0 >= 1.-1./MAXWT/MAXWT) |
600 |
> |
d = DOT(odir,tdir); /* compute pixel weight */ |
601 |
> |
if (d >= 1.-1./MAXWT/MAXWT) |
602 |
|
return(MAXWT); /* clip to maximum weight */ |
603 |
< |
return(1./sqrt(1.-d0)); |
603 |
> |
return(1./sqrt(1.-d)); |
604 |
|
} |
605 |
|
|
606 |
|
|
681 |
|
} |
682 |
|
if (yl->max >= numscans(&tresolu)) |
683 |
|
yl->max = numscans(&tresolu) - 1; |
684 |
+ |
y -= step; |
685 |
|
for (x = numscans(&tresolu) - 1; x > y; x--) /* fill bottom rows */ |
686 |
|
copystruct(xl+x, xl+y); |
687 |
|
return(yl->max >= yl->min); |
854 |
|
for (x = 0; x < hresolu; x++) { /* average pixels */ |
855 |
|
d = 1./wscan(y)[x]; |
856 |
|
scalecolor(sscan(y)[x], d); |
857 |
+ |
wscan(y)[x] = 1; |
858 |
|
} |
859 |
|
if (fwritescan(sscan(y), hresolu, stdout) < 0) |
860 |
|
syserror(progname); |