18 |
|
#endif |
19 |
|
|
20 |
|
#include <signal.h> |
21 |
– |
#include <fcntl.h> |
21 |
|
|
22 |
|
#include "view.h" |
23 |
|
|
34 |
|
VIEW ourview = STDVIEW; /* view parameters */ |
35 |
|
int hresolu = 512; /* horizontal resolution */ |
36 |
|
int vresolu = 512; /* vertical resolution */ |
37 |
< |
double pixaspect = 1.0; /* pixel aspect ratio */ |
37 |
> |
double pixaspect = 1.0; /* pixel aspect ratio */ |
38 |
|
|
39 |
|
int psample = 4; /* pixel sample size */ |
40 |
< |
double maxdiff = .05; /* max. difference for interpolation */ |
41 |
< |
double dstrpix = 0.67; /* square pixel distribution */ |
40 |
> |
double maxdiff = .05; /* max. difference for interpolation */ |
41 |
> |
double dstrpix = 0.67; /* square pixel distribution */ |
42 |
|
|
43 |
< |
double dstrsrc = 0.0; /* square source distribution */ |
44 |
< |
double shadthresh = .05; /* shadow threshold */ |
45 |
< |
double shadcert = .5; /* shadow certainty */ |
43 |
> |
double dstrsrc = 0.0; /* square source distribution */ |
44 |
> |
double shadthresh = .05; /* shadow threshold */ |
45 |
> |
double shadcert = .5; /* shadow certainty */ |
46 |
|
int directrelay = 1; /* number of source relays */ |
47 |
|
int vspretest = 512; /* virtual source pretest density */ |
48 |
|
int directinvis = 0; /* sources invisible? */ |
49 |
< |
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
49 |
> |
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
50 |
|
|
51 |
< |
double specthresh = .15; /* specular sampling threshold */ |
52 |
< |
double specjitter = 1.; /* specular sampling jitter */ |
51 |
> |
double specthresh = .15; /* specular sampling threshold */ |
52 |
> |
double specjitter = 1.; /* specular sampling jitter */ |
53 |
|
|
54 |
|
int maxdepth = 6; /* maximum recursion depth */ |
55 |
< |
double minweight = 5e-3; /* minimum ray weight */ |
55 |
> |
double minweight = 5e-3; /* minimum ray weight */ |
56 |
|
|
57 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
58 |
< |
double ambacc = 0.2; /* ambient accuracy */ |
58 |
> |
double ambacc = 0.2; /* ambient accuracy */ |
59 |
|
int ambres = 32; /* ambient resolution */ |
60 |
|
int ambdiv = 128; /* ambient divisions */ |
61 |
|
int ambssamp = 0; /* ambient super-samples */ |
63 |
|
char *amblist[128]; /* ambient include/exclude list */ |
64 |
|
int ambincl = -1; /* include == 1, exclude == 0 */ |
65 |
|
|
66 |
+ |
#ifdef MSDOS |
67 |
+ |
int ralrm = 60; /* seconds between reports */ |
68 |
+ |
#else |
69 |
|
int ralrm = 0; /* seconds between reports */ |
70 |
+ |
#endif |
71 |
|
|
72 |
< |
double pctdone = 0.0; /* percentage done */ |
72 |
> |
double pctdone = 0.0; /* percentage done */ |
73 |
|
|
74 |
|
long tlastrept = 0L; /* time at last report */ |
75 |
|
|
78 |
|
|
79 |
|
extern long nrays; /* number of rays traced */ |
80 |
|
|
81 |
< |
#define MAXDIV 16 /* maximum sample size */ |
81 |
> |
#define MAXDIV 16 /* maximum sample size */ |
82 |
|
|
83 |
< |
#define pixjitter() (.5+dstrpix*(.5-frandom())) |
83 |
> |
#define pixjitter() (.5+dstrpix*(.5-frandom())) |
84 |
|
|
85 |
< |
#define RFTEMPLATE "rfXXXXXX" |
86 |
< |
#define HFTEMPLATE TEMPLATE |
85 |
> |
#define RFTEMPLATE "rfXXXXXX" |
86 |
> |
#define HFTEMPLATE TEMPLATE |
87 |
|
|
88 |
|
static char *hfname = NULL; /* header file name */ |
89 |
|
static FILE *hfp = NULL; /* header file pointer */ |
92 |
|
|
93 |
|
extern char *mktemp(); |
94 |
|
|
95 |
< |
double pixvalue(); |
95 |
> |
double pixvalue(); |
96 |
|
|
97 |
|
|
98 |
|
quit(code) /* quit program */ |
113 |
|
report() /* report progress */ |
114 |
|
{ |
115 |
|
struct rusage rubuf; |
116 |
< |
double t; |
116 |
> |
double t; |
117 |
|
|
118 |
|
getrusage(RUSAGE_SELF, &rubuf); |
119 |
|
t = (rubuf.ru_utime.tv_usec + rubuf.ru_stime.tv_usec) / 1e6; |
155 |
|
return; |
156 |
|
if (fflush(stdout) == EOF || (hfp = fopen(hfname, "r")) == NULL) |
157 |
|
error(SYSTEM, "error reopening header file"); |
158 |
+ |
#ifdef MSDOS |
159 |
+ |
setmode(fileno(hfp), O_BINARY); |
160 |
+ |
#endif |
161 |
|
} |
162 |
|
|
163 |
|
|
190 |
|
extern char *rindex(), *strncpy(), *strcat(); |
191 |
|
char fbuf[128], fbuf2[128]; |
192 |
|
register char *cp; |
193 |
< |
RESOLU rs; |
194 |
< |
double pa; |
193 |
> |
RESOLU rs; |
194 |
> |
double pa; |
195 |
|
/* finished writing header */ |
196 |
|
closeheader(); |
197 |
|
/* check sampling */ |
244 |
|
"cannot open output file \"%s\"", fbuf); |
245 |
|
error(SYSTEM, errmsg); |
246 |
|
} |
247 |
+ |
#ifdef MSDOS |
248 |
+ |
setmode(fileno(stdout), O_BINARY); |
249 |
+ |
#endif |
250 |
|
dupheader(); |
251 |
|
} |
252 |
|
hres = hresolu; vres = vresolu; pa = pixaspect; |
338 |
|
sprintf(errmsg, "cannot open z file \"%s\"", zfile); |
339 |
|
error(SYSTEM, errmsg); |
340 |
|
} |
341 |
+ |
#ifdef MSDOS |
342 |
+ |
setmode(zfd, O_BINARY); |
343 |
+ |
#endif |
344 |
|
for (i = 0; i <= psample; i++) { |
345 |
|
zbar[i] = (float *)malloc(hres*sizeof(float)); |
346 |
|
if (zbar[i] == NULL) |
361 |
|
pctdone = 100.0*i/vres; |
362 |
|
if (ralrm > 0) /* report init stats */ |
363 |
|
report(); |
364 |
< |
#ifndef BSD |
364 |
> |
#ifndef BSD |
365 |
|
else |
366 |
|
#endif |
367 |
|
signal(SIGALRM, report); |
386 |
|
/* fill bar */ |
387 |
|
fillscanbar(scanbar, zbar, hres, ypos, ystep); |
388 |
|
/* write it out */ |
389 |
< |
#ifndef BSD |
389 |
> |
#ifndef BSD |
390 |
|
signal(SIGALRM, SIG_IGN); /* don't interrupt writes */ |
391 |
|
#endif |
392 |
|
for (i = ystep; i > 0; i--) { |
403 |
|
pctdone = 100.0*(vres-1-ypos)/vres; |
404 |
|
if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm) |
405 |
|
report(); |
406 |
< |
#ifndef BSD |
406 |
> |
#ifndef BSD |
407 |
|
else |
408 |
|
signal(SIGALRM, report); |
409 |
|
#endif |
438 |
|
|
439 |
|
|
440 |
|
fillscanline(scanline, zline, sd, xres, y, xstep) /* fill scan at y */ |
441 |
< |
register COLOR *scanline; |
442 |
< |
register float *zline; |
441 |
> |
register COLOR *scanline; |
442 |
> |
register float *zline; |
443 |
|
register char *sd; |
444 |
|
int xres, y, xstep; |
445 |
|
{ |
446 |
|
static int nc = 0; /* number of calls */ |
447 |
|
int bl = xstep, b = xstep; |
448 |
< |
double z; |
448 |
> |
double z; |
449 |
|
register int i; |
450 |
|
|
451 |
|
z = pixvalue(scanline[0], 0, y); |
473 |
|
|
474 |
|
|
475 |
|
fillscanbar(scanbar, zbar, xres, y, ysize) /* fill interior */ |
476 |
< |
register COLOR *scanbar[]; |
477 |
< |
register float *zbar[]; |
476 |
> |
register COLOR *scanbar[]; |
477 |
> |
register float *zbar[]; |
478 |
|
int xres, y, ysize; |
479 |
|
{ |
480 |
|
COLOR vline[MAXDIV+1]; |
504 |
|
|
505 |
|
|
506 |
|
int |
507 |
< |
fillsample(colline, zline, x, y, xlen, ylen, b) /* fill interior points */ |
508 |
< |
register COLOR *colline; |
509 |
< |
register float *zline; |
507 |
> |
fillsample(colline, zline, x, y, xlen, ylen, b) /* fill interior points */ |
508 |
> |
register COLOR *colline; |
509 |
> |
register float *zline; |
510 |
|
int x, y; |
511 |
|
int xlen, ylen; |
512 |
|
int b; |
513 |
|
{ |
514 |
< |
extern double fabs(); |
515 |
< |
double ratio; |
504 |
< |
double z; |
514 |
> |
double ratio; |
515 |
> |
double z; |
516 |
|
COLOR ctmp; |
517 |
|
int ncut; |
518 |
|
register int len; |
598 |
|
error(WARNING, errmsg); |
599 |
|
return(0); |
600 |
|
} |
601 |
+ |
#ifdef MSDOS |
602 |
+ |
setmode(fileno(fp), O_BINARY); |
603 |
+ |
#endif |
604 |
|
/* discard header */ |
605 |
|
getheader(fp, NULL); |
606 |
|
/* get picture size */ |