| 186 |
|
if (fillsamp == 1) |
| 187 |
|
fillo &= ~F_BACK; |
| 188 |
|
/* set view */ |
| 189 |
< |
if (ourview.vaft > FTINY) |
| 190 |
< |
err = "no aft clipping plane allowed"; |
| 191 |
< |
else |
| 192 |
< |
err = setview(&ourview); |
| 193 |
< |
if (err != NULL) { |
| 189 |
> |
if ((err = setview(&ourview)) != NULL) { |
| 190 |
|
fprintf(stderr, "%s: %s\n", progname, err); |
| 191 |
|
exit(1); |
| 192 |
|
} |
| 209 |
|
fillpicture(fillfunc); |
| 210 |
|
/* close calculation */ |
| 211 |
|
caldone(); |
| 212 |
+ |
/* aft clipping */ |
| 213 |
+ |
clipaft(); |
| 214 |
|
/* add to header */ |
| 215 |
|
printargs(argc, argv, stdout); |
| 216 |
|
if (gotvfile) { |
| 470 |
|
movepixel(pos) /* reposition image point */ |
| 471 |
|
FVECT pos; |
| 472 |
|
{ |
| 473 |
+ |
double d0, d1; |
| 474 |
|
FVECT pt, direc; |
| 475 |
|
|
| 476 |
|
if (pos[2] <= 0) /* empty pixel */ |
| 477 |
|
return(-1); |
| 478 |
+ |
if (normdist && theirview.type == VT_PER) { /* adjust distance */ |
| 479 |
+ |
d0 = pos[0] + theirview.hoff - .5; |
| 480 |
+ |
d1 = pos[1] + theirview.voff - .5; |
| 481 |
+ |
pos[2] /= sqrt(1. + d0*d0*theirview.hn2 + d1*d1*theirview.vn2); |
| 482 |
+ |
} |
| 483 |
|
if (hasmatrix) { |
| 484 |
|
pos[0] += theirview.hoff - .5; |
| 485 |
|
pos[1] += theirview.voff - .5; |
| 486 |
|
if (theirview.type == VT_PER) { |
| 483 |
– |
if (normdist) /* adjust for eye-ray distance */ |
| 484 |
– |
pos[2] /= sqrt( 1. |
| 485 |
– |
+ pos[0]*pos[0]*theirview.hn2 |
| 486 |
– |
+ pos[1]*pos[1]*theirview.vn2 ); |
| 487 |
|
pos[0] *= pos[2]; |
| 488 |
|
pos[1] *= pos[2]; |
| 489 |
|
} |
| 614 |
|
for (x = 0; x < hresolu; x++) |
| 615 |
|
if (zscan(y)[x] <= 0) |
| 616 |
|
(*fill)(x,y); |
| 617 |
+ |
} |
| 618 |
+ |
|
| 619 |
+ |
|
| 620 |
+ |
clipaft() /* perform aft clipping as indicated */ |
| 621 |
+ |
{ |
| 622 |
+ |
register int x, y; |
| 623 |
+ |
double tstdist; |
| 624 |
+ |
double yzn2, vx; |
| 625 |
+ |
|
| 626 |
+ |
if (ourview.vaft <= FTINY) |
| 627 |
+ |
return; |
| 628 |
+ |
tstdist = ourview.vaft; |
| 629 |
+ |
for (y = 0; y < vresolu; y++) { |
| 630 |
+ |
if (ourview.type == VT_PER) { /* adjust distance */ |
| 631 |
+ |
yzn2 = (y+.5)/vresolu + ourview.voff - .5; |
| 632 |
+ |
yzn2 = 1. + yzn2*yzn2*ourview.vn2; |
| 633 |
+ |
tstdist = ourview.vaft * sqrt(yzn2); |
| 634 |
+ |
} |
| 635 |
+ |
for (x = 0; x < hresolu; x++) |
| 636 |
+ |
if (zscan(y)[x] > tstdist) { |
| 637 |
+ |
if (ourview.type == VT_PER) { |
| 638 |
+ |
vx = (x+.5)/hresolu + ourview.hoff - .5; |
| 639 |
+ |
if (zscan(y)[x] <= ourview.vaft * |
| 640 |
+ |
sqrt(vx*vx*ourview.hn2 + yzn2)) |
| 641 |
+ |
continue; |
| 642 |
+ |
} |
| 643 |
+ |
bzero(pscan(y)[x], sizeof(COLR)); |
| 644 |
+ |
zscan(y)[x] = 0.0; |
| 645 |
+ |
} |
| 646 |
+ |
} |
| 647 |
|
} |
| 648 |
|
|
| 649 |
|
|