96 |
|
static putf_t puta, putd, putf; |
97 |
|
|
98 |
|
typedef void oputf_t(RAY *r); |
99 |
< |
static oputf_t oputo, oputd, oputv, oputl, oputL, oputc, |
100 |
< |
oputp, oputn, oputN, oputs, oputw, oputm; |
99 |
> |
static oputf_t oputo, oputd, oputv, oputl, oputL, oputc, oputp, |
100 |
> |
oputn, oputN, oputs, oputw, oputW, oputm, oputM, oputtilde; |
101 |
|
|
102 |
|
static void setoutput(char *vs); |
103 |
|
static void tranotify(OBJECT obj); |
213 |
|
} |
214 |
|
fflush(stdout); |
215 |
|
if (vcount > 0) |
216 |
< |
error(USER, "read error"); |
216 |
> |
error(USER, "unexpected EOF on input"); |
217 |
|
if (fname != NULL) |
218 |
|
fclose(fp); |
219 |
|
} |
220 |
|
|
221 |
|
|
222 |
|
static void |
223 |
+ |
trace_sources(void) /* trace rays to light sources, also */ |
224 |
+ |
{ |
225 |
+ |
int sn; |
226 |
+ |
|
227 |
+ |
for (sn = 0; sn < nsources; sn++) |
228 |
+ |
source[sn].sflags |= SFOLLOW; |
229 |
+ |
} |
230 |
+ |
|
231 |
+ |
|
232 |
+ |
static void |
233 |
|
setoutput( /* set up output tables */ |
234 |
|
register char *vs |
235 |
|
) |
239 |
|
castonly = 1; |
240 |
|
while (*vs) |
241 |
|
switch (*vs++) { |
242 |
+ |
case 'T': /* trace sources */ |
243 |
+ |
if (!*vs) break; |
244 |
+ |
trace_sources(); |
245 |
+ |
/* fall through */ |
246 |
|
case 't': /* trace */ |
247 |
+ |
if (!*vs) break; |
248 |
|
*table = NULL; |
249 |
|
table = every_out; |
250 |
|
trace = ourtrace; |
286 |
|
case 'w': /* weight */ |
287 |
|
*table++ = oputw; |
288 |
|
break; |
289 |
+ |
case 'W': /* coefficient */ |
290 |
+ |
*table++ = oputW; |
291 |
+ |
if (ambounce > 0 && (ambacc > FTINY || ambssamp > 0)) |
292 |
+ |
error(WARNING, |
293 |
+ |
"-otW accuracy depends on -aa 0 -as 0"); |
294 |
+ |
break; |
295 |
|
case 'm': /* modifier */ |
296 |
|
*table++ = oputm; |
297 |
|
break; |
298 |
+ |
case 'M': /* material */ |
299 |
+ |
*table++ = oputM; |
300 |
+ |
break; |
301 |
+ |
case '~': /* tilde */ |
302 |
+ |
*table++ = oputtilde; |
303 |
+ |
break; |
304 |
|
} |
305 |
|
*table = NULL; |
306 |
|
} |
311 |
|
{ |
312 |
|
thisray.rorg[0] = thisray.rorg[1] = thisray.rorg[2] = |
313 |
|
thisray.rdir[0] = thisray.rdir[1] = thisray.rdir[2] = 0.0; |
314 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
314 |
> |
thisray.rmax = 0.0; |
315 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
316 |
|
printvals(&thisray); |
317 |
|
} |
318 |
|
|
327 |
|
VCOPY(thisray.rorg, org); |
328 |
|
VCOPY(thisray.rdir, dir); |
329 |
|
thisray.rmax = dmax; |
330 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
330 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
331 |
|
if (castonly) { |
332 |
|
if (!localhit(&thisray, &thescene)) { |
333 |
|
if (thisray.ro == &Aftplane) { /* clipped */ |
354 |
|
thisray.rorg[i] = org[i] + dir[i]; |
355 |
|
thisray.rdir[i] = -dir[i]; |
356 |
|
} |
357 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
357 |
> |
thisray.rmax = 0.0; |
358 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
359 |
|
/* pretend we hit surface */ |
360 |
|
thisray.rot = 1.0-1e-4; |
361 |
|
thisray.rod = 1.0; |
468 |
|
tabin(r); |
469 |
|
for (tp = every_out; *tp != NULL; tp++) |
470 |
|
(**tp)(r); |
471 |
< |
putchar('\n'); |
471 |
> |
if (outform == 'a') |
472 |
> |
putchar('\n'); |
473 |
|
} |
474 |
|
|
475 |
|
|
478 |
|
RAY *r |
479 |
|
) |
480 |
|
{ |
481 |
< |
register RAY *rp; |
481 |
> |
const RAY *rp; |
482 |
|
|
483 |
|
for (rp = r->parent; rp != NULL; rp = rp->parent) |
484 |
|
putchar('\t'); |
512 |
|
RAY *r |
513 |
|
) |
514 |
|
{ |
485 |
– |
COLR cout; |
486 |
– |
|
515 |
|
if (outform == 'c') { |
516 |
+ |
COLR cout; |
517 |
|
setcolr(cout, colval(r->rcol,RED), |
518 |
|
colval(r->rcol,GRN), |
519 |
|
colval(r->rcol,BLU)); |
631 |
|
|
632 |
|
|
633 |
|
static void |
634 |
+ |
oputW( /* print contribution */ |
635 |
+ |
RAY *r |
636 |
+ |
) |
637 |
+ |
{ |
638 |
+ |
COLOR contr; |
639 |
+ |
|
640 |
+ |
raycontrib(contr, r, PRIMARY); |
641 |
+ |
(*putreal)(colval(contr,RED)); |
642 |
+ |
(*putreal)(colval(contr,GRN)); |
643 |
+ |
(*putreal)(colval(contr,BLU)); |
644 |
+ |
} |
645 |
+ |
|
646 |
+ |
|
647 |
+ |
static void |
648 |
|
oputm( /* print modifier */ |
649 |
|
RAY *r |
650 |
|
) |
657 |
|
else |
658 |
|
putchar('*'); |
659 |
|
putchar('\t'); |
660 |
+ |
} |
661 |
+ |
|
662 |
+ |
|
663 |
+ |
static void |
664 |
+ |
oputM( /* print material */ |
665 |
+ |
RAY *r |
666 |
+ |
) |
667 |
+ |
{ |
668 |
+ |
OBJREC *mat; |
669 |
+ |
|
670 |
+ |
if (r->ro != NULL) { |
671 |
+ |
if ((mat = findmaterial(r->ro)) != NULL) |
672 |
+ |
fputs(mat->oname, stdout); |
673 |
+ |
else |
674 |
+ |
fputs(VOIDID, stdout); |
675 |
+ |
} else |
676 |
+ |
putchar('*'); |
677 |
+ |
putchar('\t'); |
678 |
+ |
} |
679 |
+ |
|
680 |
+ |
|
681 |
+ |
static void |
682 |
+ |
oputtilde( /* output tilde (spacer) */ |
683 |
+ |
RAY *r |
684 |
+ |
) |
685 |
+ |
{ |
686 |
+ |
fputs("~\t", stdout); |
687 |
|
} |
688 |
|
|
689 |
|
|