50 |
|
double shadcert = .5; /* shadow certainty */ |
51 |
|
int directrelay = 1; /* number of source relays */ |
52 |
|
int vspretest = 512; /* virtual source pretest density */ |
53 |
< |
int directinvis = 0; /* sources invisible? */ |
53 |
> |
int directvis = 1; /* sources visible? */ |
54 |
|
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
55 |
|
|
56 |
|
double specthresh = .15; /* specular sampling threshold */ |
73 |
|
static RAY thisray; /* for our convenience */ |
74 |
|
|
75 |
|
static int oputo(), oputd(), oputv(), oputl(), oputL(), |
76 |
< |
oputp(), oputn(), oputs(), oputw(), oputm(); |
76 |
> |
oputp(), oputn(), oputN(), oputs(), oputw(), oputm(); |
77 |
|
|
78 |
+ |
static int ourtrace(), tabin(); |
79 |
|
static int (*ray_out[10])(), (*every_out[10])(); |
80 |
|
static int castonly; |
81 |
|
|
87 |
|
quit(code) /* quit program */ |
88 |
|
int code; |
89 |
|
{ |
90 |
+ |
#ifndef NIX |
91 |
+ |
headclean(); /* delete header file */ |
92 |
+ |
pfclean(); /* clean up persist files */ |
93 |
+ |
#endif |
94 |
|
exit(code); |
95 |
|
} |
96 |
|
|
123 |
|
sprintf(errmsg, "cannot open input file \"%s\"", fname); |
124 |
|
error(SYSTEM, errmsg); |
125 |
|
} |
126 |
+ |
#ifdef MSDOS |
127 |
+ |
if (inform != 'a') |
128 |
+ |
setmode(fileno(fp), O_BINARY); |
129 |
+ |
#endif |
130 |
|
/* set up output */ |
131 |
|
setoutput(outvals); |
132 |
|
switch (outform) { |
140 |
|
default: |
141 |
|
error(CONSISTENCY, "botched output format"); |
142 |
|
} |
143 |
< |
if (hresolu > 0 && vresolu > 0) |
144 |
< |
fprtresolu(hresolu, vresolu, stdout); |
143 |
> |
if (hresolu > 0) { |
144 |
> |
if (vresolu > 0) |
145 |
> |
fprtresolu(hresolu, vresolu, stdout); |
146 |
> |
fflush(stdout); |
147 |
> |
} |
148 |
|
/* process file */ |
149 |
|
while (getvec(orig, inform, fp) == 0 && |
150 |
|
getvec(direc, inform, fp) == 0) { |
169 |
|
if (--vcount == 0) /* check for end */ |
170 |
|
break; |
171 |
|
} |
172 |
+ |
fflush(stdout); |
173 |
|
if (vcount > 0) |
174 |
|
error(USER, "read error"); |
175 |
< |
fclose(fp); |
175 |
> |
if (fname != NULL) |
176 |
> |
fclose(fp); |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
|
setoutput(vs) /* set up output tables */ |
181 |
|
register char *vs; |
182 |
|
{ |
183 |
< |
extern int ourtrace(), (*trace)(); |
183 |
> |
extern int (*trace)(); |
184 |
|
register int (**table)() = ray_out; |
185 |
|
|
186 |
|
castonly = 1; |
212 |
|
case 'p': /* point */ |
213 |
|
*table++ = oputp; |
214 |
|
break; |
215 |
< |
case 'n': /* normal */ |
215 |
> |
case 'n': /* perturbed normal */ |
216 |
|
*table++ = oputn; |
217 |
+ |
castonly = 0; |
218 |
|
break; |
219 |
+ |
case 'N': /* unperturbed normal */ |
220 |
+ |
*table++ = oputN; |
221 |
+ |
break; |
222 |
|
case 's': /* surface */ |
223 |
|
*table++ = oputs; |
224 |
|
break; |
414 |
|
|
415 |
|
|
416 |
|
static |
417 |
< |
oputn(r) /* print normal */ |
417 |
> |
oputN(r) /* print unperturbed normal */ |
418 |
|
register RAY *r; |
419 |
|
{ |
420 |
|
if (r->rot < FHUGE) { |
426 |
|
(*putreal)(0.0); |
427 |
|
(*putreal)(0.0); |
428 |
|
} |
429 |
+ |
} |
430 |
+ |
|
431 |
+ |
|
432 |
+ |
static |
433 |
+ |
oputn(r) /* print perturbed normal */ |
434 |
+ |
RAY *r; |
435 |
+ |
{ |
436 |
+ |
FVECT pnorm; |
437 |
+ |
|
438 |
+ |
if (r->rot >= FHUGE) { |
439 |
+ |
(*putreal)(0.0); |
440 |
+ |
(*putreal)(0.0); |
441 |
+ |
(*putreal)(0.0); |
442 |
+ |
return; |
443 |
+ |
} |
444 |
+ |
raynormal(pnorm, r); |
445 |
+ |
(*putreal)(pnorm[0]); |
446 |
+ |
(*putreal)(pnorm[1]); |
447 |
+ |
(*putreal)(pnorm[2]); |
448 |
|
} |
449 |
|
|
450 |
|
|