68 |
|
|
69 |
|
int fillo = F_FORE|F_BACK; /* selected fill options */ |
70 |
|
int fillsamp = 0; /* sample separation (0 == inf) */ |
71 |
– |
extern int backfill(), rcalfill(); /* fill functions */ |
72 |
– |
int (*fillfunc)() = backfill; /* selected fill function */ |
71 |
|
COLR backcolr = BLKCOLR; /* background color */ |
72 |
|
COLOR backcolor = BLKCOLOR; /* background color (float) */ |
73 |
|
double backz = 0.0; /* background z value */ |
90 |
|
int packsiz; /* actual packet size */ |
91 |
|
int queuesiz = 0; /* number of pixels pending */ |
92 |
|
|
93 |
< |
extern double movepixel(); |
93 |
> |
typedef void fillfunc_t(int x, int y); |
94 |
|
|
95 |
+ |
static gethfunc headline; |
96 |
+ |
static int nextview(FILE *fp); |
97 |
+ |
static void compavgview(void); |
98 |
+ |
static void addpicture(char *pfile, char *zspec); |
99 |
+ |
static int pixform(MAT4 xfmat, VIEW *vw1, VIEW *vw2); |
100 |
+ |
static void addscanline(struct bound *xl, int y, |
101 |
+ |
COLR *pline, float *zline, struct position *lasty); |
102 |
+ |
static void addpixel(struct position *p0, struct position *p1, |
103 |
+ |
struct position *p2, COLR pix, double w, double z); |
104 |
+ |
static double movepixel(FVECT pos); |
105 |
+ |
static int getperim(struct bound *xl, struct bound *yl, float *zline, int zfd); |
106 |
+ |
static void backpicture(fillfunc_t *fill, int samp); |
107 |
+ |
static void fillpicture(fillfunc_t *fill); |
108 |
+ |
static int clipaft(void); |
109 |
+ |
static int addblur(void); |
110 |
+ |
static void writepicture(void); |
111 |
+ |
static void writedistance(char *fname); |
112 |
+ |
static fillfunc_t backfill; |
113 |
+ |
static fillfunc_t rcalfill; |
114 |
+ |
static void calstart(char *prog, char *args); |
115 |
+ |
static void caldone(void); |
116 |
+ |
static void clearqueue(void); |
117 |
+ |
static void syserror(char *s); |
118 |
|
|
119 |
< |
main(argc, argv) /* interpolate pictures */ |
120 |
< |
int argc; |
121 |
< |
char *argv[]; |
119 |
> |
fillfunc_t *fillfunc = backfill; /* selected fill function */ |
120 |
> |
|
121 |
> |
int |
122 |
> |
main( /* interpolate pictures */ |
123 |
> |
int argc, |
124 |
> |
char *argv[] |
125 |
> |
) |
126 |
|
{ |
127 |
|
#define check(ol,al) if (argv[an][ol] || \ |
128 |
|
badarg(argc-an-1,argv+an+1,al)) \ |
134 |
|
char *expcomp = NULL; |
135 |
|
int i, an, rval; |
136 |
|
|
137 |
+ |
SET_DEFAULT_BINARY(); |
138 |
+ |
SET_FILE_BINARY(stdout); |
139 |
+ |
|
140 |
|
progname = argv[0]; |
141 |
|
|
142 |
|
for (an = 1; an < argc && argv[an][0] == '-'; an++) { |
355 |
|
} |
356 |
|
|
357 |
|
|
358 |
< |
int |
359 |
< |
headline(s) /* process header string */ |
360 |
< |
char *s; |
358 |
> |
static int |
359 |
> |
headline( /* process header string */ |
360 |
> |
char *s, |
361 |
> |
void *p |
362 |
> |
) |
363 |
|
{ |
364 |
|
char fmt[32]; |
365 |
|
|
387 |
|
} |
388 |
|
|
389 |
|
|
390 |
< |
nextview(fp) /* get and set next view */ |
391 |
< |
FILE *fp; |
390 |
> |
static int |
391 |
> |
nextview( /* get and set next view */ |
392 |
> |
FILE *fp |
393 |
> |
) |
394 |
|
{ |
395 |
|
char linebuf[256]; |
396 |
|
char *err; |
417 |
|
avgview.vdir[i] += ourview.vdir[i]; |
418 |
|
avgview.vup[i] += ourview.vup[i]; |
419 |
|
} |
420 |
+ |
avgview.vdist += ourview.vdist; |
421 |
|
avgview.horiz += ourview.horiz; |
422 |
|
avgview.vert += ourview.vert; |
423 |
|
avgview.hoff += ourview.hoff; |
428 |
|
} |
429 |
|
|
430 |
|
|
431 |
< |
compavgview() /* compute average view */ |
431 |
> |
static void |
432 |
> |
compavgview(void) /* compute average view */ |
433 |
|
{ |
434 |
|
register int i; |
435 |
|
double f; |
442 |
|
avgview.vdir[i] *= f; |
443 |
|
avgview.vup[i] *= f; |
444 |
|
} |
445 |
+ |
avgview.vdist *= f; |
446 |
|
avgview.horiz *= f; |
447 |
|
avgview.vert *= f; |
448 |
|
avgview.hoff *= f; |
455 |
|
} |
456 |
|
|
457 |
|
|
458 |
< |
addpicture(pfile, zspec) /* add picture to output */ |
459 |
< |
char *pfile, *zspec; |
458 |
> |
static void |
459 |
> |
addpicture( /* add picture to output */ |
460 |
> |
char *pfile, |
461 |
> |
char *zspec |
462 |
> |
) |
463 |
|
{ |
464 |
|
FILE *pfp; |
465 |
|
int zfd; |
556 |
|
} |
557 |
|
|
558 |
|
|
559 |
< |
pixform(xfmat, vw1, vw2) /* compute view1 to view2 matrix */ |
560 |
< |
register MAT4 xfmat; |
561 |
< |
register VIEW *vw1, *vw2; |
559 |
> |
static int |
560 |
> |
pixform( /* compute view1 to view2 matrix */ |
561 |
> |
register MAT4 xfmat, |
562 |
> |
register VIEW *vw1, |
563 |
> |
register VIEW *vw2 |
564 |
> |
) |
565 |
|
{ |
566 |
|
double m4t[4][4]; |
567 |
|
|
600 |
|
} |
601 |
|
|
602 |
|
|
603 |
< |
addscanline(xl, y, pline, zline, lasty) /* add scanline to output */ |
604 |
< |
struct bound *xl; |
605 |
< |
int y; |
606 |
< |
COLR *pline; |
607 |
< |
float *zline; |
608 |
< |
struct position *lasty; /* input/output */ |
603 |
> |
static void |
604 |
> |
addscanline( /* add scanline to output */ |
605 |
> |
struct bound *xl, |
606 |
> |
int y, |
607 |
> |
COLR *pline, |
608 |
> |
float *zline, |
609 |
> |
struct position *lasty /* input/output */ |
610 |
> |
) |
611 |
|
{ |
612 |
|
FVECT pos; |
613 |
|
struct position lastx, newpos; |
634 |
|
} |
635 |
|
|
636 |
|
|
637 |
< |
addpixel(p0, p1, p2, pix, w, z) /* fill in pixel parallelogram */ |
638 |
< |
struct position *p0, *p1, *p2; |
639 |
< |
COLR pix; |
640 |
< |
double w; |
641 |
< |
double z; |
637 |
> |
static void |
638 |
> |
addpixel( /* fill in pixel parallelogram */ |
639 |
> |
struct position *p0, |
640 |
> |
struct position *p1, |
641 |
> |
struct position *p2, |
642 |
> |
COLR pix, |
643 |
> |
double w, |
644 |
> |
double z |
645 |
> |
) |
646 |
|
{ |
647 |
|
double zt = 2.*zeps*p0->z; /* threshold */ |
648 |
|
COLOR pval; /* converted+weighted pixel */ |
715 |
|
} |
716 |
|
|
717 |
|
|
718 |
< |
double |
719 |
< |
movepixel(pos) /* reposition image point */ |
720 |
< |
register FVECT pos; |
718 |
> |
static double |
719 |
> |
movepixel( /* reposition image point */ |
720 |
> |
register FVECT pos |
721 |
> |
) |
722 |
|
{ |
723 |
|
FVECT pt, tdir, odir; |
724 |
|
double d; |
781 |
|
} |
782 |
|
|
783 |
|
|
784 |
< |
getperim(xl, yl, zline, zfd) /* compute overlapping image area */ |
785 |
< |
register struct bound *xl; |
786 |
< |
struct bound *yl; |
787 |
< |
float *zline; |
788 |
< |
int zfd; |
784 |
> |
static int |
785 |
> |
getperim( /* compute overlapping image area */ |
786 |
> |
register struct bound *xl, |
787 |
> |
struct bound *yl, |
788 |
> |
float *zline, |
789 |
> |
int zfd |
790 |
> |
) |
791 |
|
{ |
792 |
|
int step; |
793 |
|
FVECT pos; |
867 |
|
} |
868 |
|
|
869 |
|
|
870 |
< |
backpicture(fill, samp) /* background fill algorithm */ |
871 |
< |
int (*fill)(); |
872 |
< |
int samp; |
870 |
> |
static void |
871 |
> |
backpicture( /* background fill algorithm */ |
872 |
> |
fillfunc_t *fill, |
873 |
> |
int samp |
874 |
> |
) |
875 |
|
{ |
876 |
|
int *yback, xback; |
877 |
|
int y; |
977 |
|
} |
978 |
|
|
979 |
|
|
980 |
< |
fillpicture(fill) /* paint in empty pixels using fill */ |
981 |
< |
int (*fill)(); |
980 |
> |
static void |
981 |
> |
fillpicture( /* paint in empty pixels using fill */ |
982 |
> |
fillfunc_t *fill |
983 |
> |
) |
984 |
|
{ |
985 |
|
register int x, y; |
986 |
|
|
993 |
|
} |
994 |
|
|
995 |
|
|
996 |
< |
clipaft() /* perform aft clipping as indicated */ |
996 |
> |
static int |
997 |
> |
clipaft(void) /* perform aft clipping as indicated */ |
998 |
|
{ |
999 |
|
register int x, y; |
1000 |
|
int adjtest = (ourview.type == VT_PER) & zisnorm; |
1030 |
|
} |
1031 |
|
|
1032 |
|
|
1033 |
< |
addblur() /* add to blurred picture */ |
1033 |
> |
static int |
1034 |
> |
addblur(void) /* add to blurred picture */ |
1035 |
|
{ |
1036 |
|
COLOR cval; |
1037 |
|
double d; |
1071 |
|
} |
1072 |
|
|
1073 |
|
|
1074 |
< |
writepicture() /* write out picture (alters buffer) */ |
1074 |
> |
static void |
1075 |
> |
writepicture(void) /* write out picture (alters buffer) */ |
1076 |
|
{ |
1077 |
|
int y; |
1078 |
|
register int x; |
1103 |
|
} |
1104 |
|
|
1105 |
|
|
1106 |
< |
writedistance(fname) /* write out z file (alters buffer) */ |
1107 |
< |
char *fname; |
1106 |
> |
static void |
1107 |
> |
writedistance( /* write out z file (alters buffer) */ |
1108 |
> |
char *fname |
1109 |
> |
) |
1110 |
|
{ |
1111 |
|
int donorm = normdist & !zisnorm ? 1 : |
1112 |
|
(ourview.type == VT_PER) & !normdist & zisnorm ? -1 : 0; |
1138 |
|
} |
1139 |
|
|
1140 |
|
|
1141 |
< |
backfill(x, y) /* fill pixel with background */ |
1142 |
< |
int x, y; |
1141 |
> |
static void |
1142 |
> |
backfill( /* fill pixel with background */ |
1143 |
> |
int x, |
1144 |
> |
int y |
1145 |
> |
) |
1146 |
|
{ |
1147 |
|
if (averaging) { |
1148 |
|
copycolor(sscan(y)[x], backcolor); |
1153 |
|
} |
1154 |
|
|
1155 |
|
|
1156 |
< |
calstart(prog, args) /* start fill calculation */ |
1157 |
< |
char *prog, *args; |
1156 |
> |
static void |
1157 |
> |
calstart( /* start fill calculation */ |
1158 |
> |
char *prog, |
1159 |
> |
char *args |
1160 |
> |
) |
1161 |
|
{ |
1162 |
|
char combuf[512]; |
1163 |
|
char *argv[64]; |
1196 |
|
} |
1197 |
|
|
1198 |
|
|
1199 |
< |
caldone() /* done with calculation */ |
1199 |
> |
static void |
1200 |
> |
caldone(void) /* done with calculation */ |
1201 |
|
{ |
1202 |
|
if (!PDesc.running) |
1203 |
|
return; |
1206 |
|
} |
1207 |
|
|
1208 |
|
|
1209 |
< |
rcalfill(x, y) /* fill with ray-calculated pixel */ |
1210 |
< |
int x, y; |
1209 |
> |
static void |
1210 |
> |
rcalfill( /* fill with ray-calculated pixel */ |
1211 |
> |
int x, |
1212 |
> |
int y |
1213 |
> |
) |
1214 |
|
{ |
1215 |
|
if (queuesiz >= packsiz) /* flush queue if needed */ |
1216 |
|
clearqueue(); |
1221 |
|
} |
1222 |
|
|
1223 |
|
|
1224 |
< |
clearqueue() /* process queue */ |
1224 |
> |
static void |
1225 |
> |
clearqueue(void) /* process queue */ |
1226 |
|
{ |
1227 |
|
FVECT orig, dir; |
1228 |
|
float fbuf[6*(PACKSIZ+1)]; |
1278 |
|
} |
1279 |
|
|
1280 |
|
|
1281 |
< |
syserror(s) /* report error and exit */ |
1282 |
< |
char *s; |
1281 |
> |
static void |
1282 |
> |
syserror( /* report error and exit */ |
1283 |
> |
char *s |
1284 |
> |
) |
1285 |
|
{ |
1286 |
|
perror(s); |
1287 |
|
exit(1); |