1 |
– |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* rtrace.c - program and variables for individual ray tracing. |
9 |
– |
* |
10 |
– |
* 6/11/86 |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include "copyright.h" |
9 |
+ |
|
10 |
|
/* |
11 |
|
* Input is in the form: |
12 |
|
* |
21 |
|
* irradiance values are desired. |
22 |
|
*/ |
23 |
|
|
24 |
< |
#include "ray.h" |
24 |
> |
#include <time.h> |
25 |
|
|
26 |
< |
#include "octree.h" |
27 |
< |
|
26 |
> |
#include "platform.h" |
27 |
> |
#include "ray.h" |
28 |
> |
#include "ambient.h" |
29 |
> |
#include "source.h" |
30 |
|
#include "otypes.h" |
32 |
– |
|
31 |
|
#include "resolu.h" |
32 |
|
|
33 |
+ |
CUBE thescene; /* our scene */ |
34 |
+ |
OBJECT nsceneobjs; /* number of objects in our scene */ |
35 |
+ |
|
36 |
|
int dimlist[MAXDIM]; /* sampling dimensions */ |
37 |
|
int ndims = 0; /* number of sampling dimensions */ |
38 |
|
int samplendx = 0; /* index for this sample */ |
39 |
|
|
40 |
|
int imm_irrad = 0; /* compute immediate irradiance? */ |
41 |
+ |
int lim_dist = 0; /* limit distance? */ |
42 |
|
|
43 |
|
int inform = 'a'; /* input format */ |
44 |
|
int outform = 'a'; /* output format */ |
45 |
|
char *outvals = "v"; /* output specification */ |
46 |
|
|
47 |
+ |
int do_irrad = 0; /* compute irradiance? */ |
48 |
+ |
|
49 |
+ |
void (*trace)() = NULL; /* trace call */ |
50 |
+ |
|
51 |
|
char *tralist[128]; /* list of modifers to trace (or no) */ |
52 |
|
int traincl = -1; /* include == 1, exclude == 0 */ |
53 |
|
#define MAXTSET 511 /* maximum number in trace set */ |
57 |
|
int vresolu = 0; /* vertical resolution */ |
58 |
|
|
59 |
|
double dstrsrc = 0.0; /* square source distribution */ |
60 |
< |
double shadthresh = .05; /* shadow threshold */ |
61 |
< |
double shadcert = .5; /* shadow certainty */ |
60 |
> |
double shadthresh = .03; /* shadow threshold */ |
61 |
> |
double shadcert = .75; /* shadow certainty */ |
62 |
|
int directrelay = 2; /* number of source relays */ |
63 |
|
int vspretest = 512; /* virtual source pretest density */ |
64 |
|
int directvis = 1; /* sources visible? */ |
74 |
|
|
75 |
|
int backvis = 1; /* back face visibility */ |
76 |
|
|
77 |
< |
int maxdepth = 6; /* maximum recursion depth */ |
78 |
< |
double minweight = 4e-3; /* minimum ray weight */ |
77 |
> |
int maxdepth = -10; /* maximum recursion depth */ |
78 |
> |
double minweight = 2e-3; /* minimum ray weight */ |
79 |
|
|
80 |
+ |
char *ambfile = NULL; /* ambient file name */ |
81 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
82 |
|
int ambvwt = 0; /* initial weight for ambient value */ |
83 |
< |
double ambacc = 0.2; /* ambient accuracy */ |
84 |
< |
int ambres = 128; /* ambient resolution */ |
85 |
< |
int ambdiv = 512; /* ambient divisions */ |
86 |
< |
int ambssamp = 0; /* ambient super-samples */ |
83 |
> |
double ambacc = 0.15; /* ambient accuracy */ |
84 |
> |
int ambres = 256; /* ambient resolution */ |
85 |
> |
int ambdiv = 1024; /* ambient divisions */ |
86 |
> |
int ambssamp = 512; /* ambient super-samples */ |
87 |
|
int ambounce = 0; /* ambient bounces */ |
88 |
< |
char *amblist[128]; /* ambient include/exclude list */ |
88 |
> |
char *amblist[AMBLLEN]; /* ambient include/exclude list */ |
89 |
|
int ambincl = -1; /* include == 1, exclude == 0 */ |
90 |
|
|
91 |
< |
extern OBJREC Lamb; /* a Lambertian surface */ |
91 |
> |
static int castonly = 0; |
92 |
|
|
93 |
|
static RAY thisray; /* for our convenience */ |
94 |
|
|
95 |
< |
static int oputo(), oputd(), oputv(), oputl(), oputL(), |
96 |
< |
oputp(), oputn(), oputN(), oputs(), oputw(), oputm(); |
95 |
> |
typedef void putf_t(double v); |
96 |
> |
static putf_t puta, putd, putf; |
97 |
|
|
98 |
< |
static int ourtrace(), tabin(); |
99 |
< |
static int (*ray_out[16])(), (*every_out[16])(); |
100 |
< |
static int castonly = 0; |
98 |
> |
typedef void oputf_t(RAY *r); |
99 |
> |
static oputf_t oputo, oputd, oputv, oputl, oputL, oputc, oputp, |
100 |
> |
oputn, oputN, oputs, oputw, oputW, oputm, oputM, oputtilde; |
101 |
|
|
102 |
< |
static int puta(), putf(), putd(); |
102 |
> |
static void setoutput(char *vs); |
103 |
> |
static void tranotify(OBJECT obj); |
104 |
> |
static void bogusray(void); |
105 |
> |
static void rad(FVECT org, FVECT dir, double dmax); |
106 |
> |
static void irrad(FVECT org, FVECT dir); |
107 |
> |
static void printvals(RAY *r); |
108 |
> |
static int getvec(FVECT vec, int fmt, FILE *fp); |
109 |
> |
static void tabin(RAY *r); |
110 |
> |
static void ourtrace(RAY *r); |
111 |
|
|
112 |
< |
static int (*putreal)(); |
112 |
> |
static oputf_t *ray_out[16], *every_out[16]; |
113 |
> |
static putf_t *putreal; |
114 |
|
|
115 |
+ |
void (*addobjnotify[])() = {ambnotify, tranotify, NULL}; |
116 |
|
|
117 |
< |
quit(code) /* quit program */ |
118 |
< |
int code; |
117 |
> |
|
118 |
> |
void |
119 |
> |
quit( /* quit program */ |
120 |
> |
int code |
121 |
> |
) |
122 |
|
{ |
123 |
< |
#ifndef NIX |
123 |
> |
#ifndef NON_POSIX /* XXX we don't clean up elsewhere? */ |
124 |
|
headclean(); /* delete header file */ |
125 |
|
pfclean(); /* clean up persist files */ |
126 |
|
#endif |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
< |
char * |
132 |
< |
formstr(f) /* return format identifier */ |
133 |
< |
int f; |
131 |
> |
extern char * |
132 |
> |
formstr( /* return format identifier */ |
133 |
> |
int f |
134 |
> |
) |
135 |
|
{ |
136 |
|
switch (f) { |
137 |
|
case 'a': return("ascii"); |
143 |
|
} |
144 |
|
|
145 |
|
|
146 |
< |
rtrace(fname) /* trace rays from file */ |
147 |
< |
char *fname; |
146 |
> |
extern void |
147 |
> |
rtrace( /* trace rays from file */ |
148 |
> |
char *fname |
149 |
> |
) |
150 |
|
{ |
151 |
|
long vcount = hresolu>1 ? hresolu*vresolu : vresolu; |
152 |
|
long nextflush = hresolu; |
153 |
|
FILE *fp; |
154 |
+ |
double d; |
155 |
|
FVECT orig, direc; |
156 |
|
/* set up input */ |
157 |
|
if (fname == NULL) |
160 |
|
sprintf(errmsg, "cannot open input file \"%s\"", fname); |
161 |
|
error(SYSTEM, errmsg); |
162 |
|
} |
139 |
– |
#ifdef MSDOS |
163 |
|
if (inform != 'a') |
164 |
< |
setmode(fileno(fp), O_BINARY); |
142 |
< |
#endif |
164 |
> |
SET_FILE_BINARY(fp); |
165 |
|
/* set up output */ |
166 |
|
setoutput(outvals); |
167 |
|
switch (outform) { |
184 |
|
while (getvec(orig, inform, fp) == 0 && |
185 |
|
getvec(direc, inform, fp) == 0) { |
186 |
|
|
187 |
< |
if (normalize(direc) == 0.0) { /* zero ==> flush */ |
188 |
< |
fflush(stdout); |
189 |
< |
continue; |
190 |
< |
} |
191 |
< |
samplendx++; |
187 |
> |
d = normalize(direc); |
188 |
> |
if (d == 0.0) { /* zero ==> flush */ |
189 |
> |
bogusray(); |
190 |
> |
if (--nextflush <= 0 || vcount <= 0) { |
191 |
> |
fflush(stdout); |
192 |
> |
nextflush = hresolu; |
193 |
> |
} |
194 |
> |
} else { |
195 |
> |
samplendx++; |
196 |
|
/* compute and print */ |
197 |
< |
if (imm_irrad) |
198 |
< |
irrad(orig, direc); |
199 |
< |
else |
200 |
< |
rad(orig, direc); |
197 |
> |
if (imm_irrad) |
198 |
> |
irrad(orig, direc); |
199 |
> |
else |
200 |
> |
rad(orig, direc, lim_dist ? d : 0.0); |
201 |
|
/* flush if time */ |
202 |
< |
if (--nextflush == 0) { |
203 |
< |
fflush(stdout); |
204 |
< |
nextflush = hresolu; |
202 |
> |
if (--nextflush == 0) { |
203 |
> |
fflush(stdout); |
204 |
> |
nextflush = hresolu; |
205 |
> |
} |
206 |
|
} |
207 |
|
if (ferror(stdout)) |
208 |
|
error(SYSTEM, "write error"); |
211 |
|
} |
212 |
|
fflush(stdout); |
213 |
|
if (vcount > 0) |
214 |
< |
error(USER, "read error"); |
214 |
> |
error(USER, "unexpected EOF on input"); |
215 |
|
if (fname != NULL) |
216 |
|
fclose(fp); |
217 |
|
} |
218 |
|
|
219 |
|
|
220 |
< |
setoutput(vs) /* set up output tables */ |
221 |
< |
register char *vs; |
220 |
> |
static void |
221 |
> |
trace_sources(void) /* trace rays to light sources, also */ |
222 |
|
{ |
223 |
< |
extern int (*trace)(); |
224 |
< |
register int (**table)() = ray_out; |
223 |
> |
int sn; |
224 |
> |
|
225 |
> |
for (sn = 0; sn < nsources; sn++) |
226 |
> |
source[sn].sflags |= SFOLLOW; |
227 |
> |
} |
228 |
|
|
229 |
+ |
|
230 |
+ |
static void |
231 |
+ |
setoutput( /* set up output tables */ |
232 |
+ |
register char *vs |
233 |
+ |
) |
234 |
+ |
{ |
235 |
+ |
register oputf_t **table = ray_out; |
236 |
+ |
|
237 |
|
castonly = 1; |
238 |
|
while (*vs) |
239 |
|
switch (*vs++) { |
240 |
+ |
case 'T': /* trace sources */ |
241 |
+ |
if (!*vs) break; |
242 |
+ |
trace_sources(); |
243 |
+ |
/* fall through */ |
244 |
|
case 't': /* trace */ |
245 |
+ |
if (!*vs) break; |
246 |
|
*table = NULL; |
247 |
|
table = every_out; |
248 |
|
trace = ourtrace; |
262 |
|
*table++ = oputl; |
263 |
|
castonly = 0; |
264 |
|
break; |
265 |
+ |
case 'c': /* local coordinates */ |
266 |
+ |
*table++ = oputc; |
267 |
+ |
break; |
268 |
|
case 'L': /* single ray length */ |
269 |
|
*table++ = oputL; |
270 |
|
break; |
284 |
|
case 'w': /* weight */ |
285 |
|
*table++ = oputw; |
286 |
|
break; |
287 |
+ |
case 'W': /* coefficient */ |
288 |
+ |
*table++ = oputW; |
289 |
+ |
if (ambounce > 0 && (ambacc > FTINY || ambssamp > 0)) |
290 |
+ |
error(WARNING, |
291 |
+ |
"-otW accuracy depends on -aa 0 -as 0"); |
292 |
+ |
break; |
293 |
|
case 'm': /* modifier */ |
294 |
|
*table++ = oputm; |
295 |
|
break; |
296 |
+ |
case 'M': /* material */ |
297 |
+ |
*table++ = oputM; |
298 |
+ |
break; |
299 |
+ |
case '~': /* tilde */ |
300 |
+ |
*table++ = oputtilde; |
301 |
+ |
break; |
302 |
|
} |
303 |
|
*table = NULL; |
304 |
|
} |
305 |
|
|
306 |
|
|
307 |
< |
rad(org, dir) /* compute and print ray value(s) */ |
308 |
< |
FVECT org, dir; |
307 |
> |
static void |
308 |
> |
bogusray(void) /* print out empty record */ |
309 |
|
{ |
310 |
+ |
thisray.rorg[0] = thisray.rorg[1] = thisray.rorg[2] = |
311 |
+ |
thisray.rdir[0] = thisray.rdir[1] = thisray.rdir[2] = 0.0; |
312 |
+ |
thisray.rmax = 0.0; |
313 |
+ |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
314 |
+ |
printvals(&thisray); |
315 |
+ |
} |
316 |
+ |
|
317 |
+ |
|
318 |
+ |
static void |
319 |
+ |
rad( /* compute and print ray value(s) */ |
320 |
+ |
FVECT org, |
321 |
+ |
FVECT dir, |
322 |
+ |
double dmax |
323 |
+ |
) |
324 |
+ |
{ |
325 |
|
VCOPY(thisray.rorg, org); |
326 |
|
VCOPY(thisray.rdir, dir); |
327 |
< |
thisray.rmax = 0.0; |
328 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
329 |
< |
if (castonly) |
330 |
< |
localhit(&thisray, &thescene) || sourcehit(&thisray); |
331 |
< |
else |
327 |
> |
thisray.rmax = dmax; |
328 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
329 |
> |
if (castonly) { |
330 |
> |
if (!localhit(&thisray, &thescene)) { |
331 |
> |
if (thisray.ro == &Aftplane) { /* clipped */ |
332 |
> |
thisray.ro = NULL; |
333 |
> |
thisray.rot = FHUGE; |
334 |
> |
} else |
335 |
> |
sourcehit(&thisray); |
336 |
> |
} |
337 |
> |
} else |
338 |
|
rayvalue(&thisray); |
339 |
|
printvals(&thisray); |
340 |
|
} |
341 |
|
|
342 |
|
|
343 |
< |
irrad(org, dir) /* compute immediate irradiance value */ |
344 |
< |
FVECT org, dir; |
343 |
> |
static void |
344 |
> |
irrad( /* compute immediate irradiance value */ |
345 |
> |
FVECT org, |
346 |
> |
FVECT dir |
347 |
> |
) |
348 |
|
{ |
349 |
|
register int i; |
350 |
|
|
352 |
|
thisray.rorg[i] = org[i] + dir[i]; |
353 |
|
thisray.rdir[i] = -dir[i]; |
354 |
|
} |
355 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
355 |
> |
thisray.rmax = 0.0; |
356 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
357 |
|
/* pretend we hit surface */ |
358 |
|
thisray.rot = 1.0-1e-4; |
359 |
|
thisray.rod = 1.0; |
366 |
|
} |
367 |
|
|
368 |
|
|
369 |
< |
printvals(r) /* print requested ray values */ |
370 |
< |
RAY *r; |
369 |
> |
static void |
370 |
> |
printvals( /* print requested ray values */ |
371 |
> |
RAY *r |
372 |
> |
) |
373 |
|
{ |
374 |
< |
register int (**tp)(); |
374 |
> |
register oputf_t **tp; |
375 |
|
|
376 |
|
if (ray_out[0] == NULL) |
377 |
|
return; |
382 |
|
} |
383 |
|
|
384 |
|
|
385 |
< |
getvec(vec, fmt, fp) /* get a vector from fp */ |
386 |
< |
register FVECT vec; |
387 |
< |
int fmt; |
388 |
< |
FILE *fp; |
385 |
> |
static int |
386 |
> |
getvec( /* get a vector from fp */ |
387 |
> |
register FVECT vec, |
388 |
> |
int fmt, |
389 |
> |
FILE *fp |
390 |
> |
) |
391 |
|
{ |
305 |
– |
extern char *fgetword(); |
392 |
|
static float vf[3]; |
393 |
|
static double vd[3]; |
394 |
|
char buf[32]; |
420 |
|
} |
421 |
|
|
422 |
|
|
423 |
< |
tranotify(obj) /* record new modifier */ |
424 |
< |
OBJECT obj; |
423 |
> |
static void |
424 |
> |
tranotify( /* record new modifier */ |
425 |
> |
OBJECT obj |
426 |
> |
) |
427 |
|
{ |
428 |
|
static int hitlimit = 0; |
429 |
|
register OBJREC *o = objptr(obj); |
430 |
|
register char **tralp; |
431 |
|
|
432 |
+ |
if (obj == OVOID) { /* starting over */ |
433 |
+ |
traset[0] = 0; |
434 |
+ |
hitlimit = 0; |
435 |
+ |
return; |
436 |
+ |
} |
437 |
|
if (hitlimit || !ismodifier(o->otype)) |
438 |
|
return; |
439 |
|
for (tralp = tralist; *tralp != NULL; tralp++) |
449 |
|
} |
450 |
|
|
451 |
|
|
452 |
< |
static |
453 |
< |
ourtrace(r) /* print ray values */ |
454 |
< |
RAY *r; |
452 |
> |
static void |
453 |
> |
ourtrace( /* print ray values */ |
454 |
> |
RAY *r |
455 |
> |
) |
456 |
|
{ |
457 |
< |
register int (**tp)(); |
457 |
> |
register oputf_t **tp; |
458 |
|
|
459 |
|
if (every_out[0] == NULL) |
460 |
|
return; |
466 |
|
tabin(r); |
467 |
|
for (tp = every_out; *tp != NULL; tp++) |
468 |
|
(**tp)(r); |
469 |
< |
putchar('\n'); |
469 |
> |
if (outform == 'a') |
470 |
> |
putchar('\n'); |
471 |
|
} |
472 |
|
|
473 |
|
|
474 |
< |
static |
475 |
< |
tabin(r) /* tab in appropriate amount */ |
476 |
< |
RAY *r; |
474 |
> |
static void |
475 |
> |
tabin( /* tab in appropriate amount */ |
476 |
> |
RAY *r |
477 |
> |
) |
478 |
|
{ |
479 |
< |
register RAY *rp; |
479 |
> |
const RAY *rp; |
480 |
|
|
481 |
|
for (rp = r->parent; rp != NULL; rp = rp->parent) |
482 |
|
putchar('\t'); |
483 |
|
} |
484 |
|
|
485 |
|
|
486 |
< |
static |
487 |
< |
oputo(r) /* print origin */ |
488 |
< |
register RAY *r; |
486 |
> |
static void |
487 |
> |
oputo( /* print origin */ |
488 |
> |
RAY *r |
489 |
> |
) |
490 |
|
{ |
491 |
|
(*putreal)(r->rorg[0]); |
492 |
|
(*putreal)(r->rorg[1]); |
494 |
|
} |
495 |
|
|
496 |
|
|
497 |
< |
static |
498 |
< |
oputd(r) /* print direction */ |
499 |
< |
register RAY *r; |
497 |
> |
static void |
498 |
> |
oputd( /* print direction */ |
499 |
> |
RAY *r |
500 |
> |
) |
501 |
|
{ |
502 |
|
(*putreal)(r->rdir[0]); |
503 |
|
(*putreal)(r->rdir[1]); |
505 |
|
} |
506 |
|
|
507 |
|
|
508 |
< |
static |
509 |
< |
oputv(r) /* print value */ |
510 |
< |
register RAY *r; |
508 |
> |
static void |
509 |
> |
oputv( /* print value */ |
510 |
> |
RAY *r |
511 |
> |
) |
512 |
|
{ |
414 |
– |
COLR cout; |
415 |
– |
|
513 |
|
if (outform == 'c') { |
514 |
+ |
COLR cout; |
515 |
|
setcolr(cout, colval(r->rcol,RED), |
516 |
|
colval(r->rcol,GRN), |
517 |
|
colval(r->rcol,BLU)); |
524 |
|
} |
525 |
|
|
526 |
|
|
527 |
< |
static |
528 |
< |
oputl(r) /* print effective distance */ |
529 |
< |
register RAY *r; |
527 |
> |
static void |
528 |
> |
oputl( /* print effective distance */ |
529 |
> |
RAY *r |
530 |
> |
) |
531 |
|
{ |
532 |
|
(*putreal)(r->rt); |
533 |
|
} |
534 |
|
|
535 |
|
|
536 |
< |
static |
537 |
< |
oputL(r) /* print single ray length */ |
538 |
< |
register RAY *r; |
536 |
> |
static void |
537 |
> |
oputL( /* print single ray length */ |
538 |
> |
RAY *r |
539 |
> |
) |
540 |
|
{ |
541 |
|
(*putreal)(r->rot); |
542 |
|
} |
543 |
|
|
544 |
|
|
545 |
< |
static |
546 |
< |
oputp(r) /* print point */ |
547 |
< |
register RAY *r; |
545 |
> |
static void |
546 |
> |
oputc( /* print local coordinates */ |
547 |
> |
RAY *r |
548 |
> |
) |
549 |
|
{ |
550 |
+ |
(*putreal)(r->uv[0]); |
551 |
+ |
(*putreal)(r->uv[1]); |
552 |
+ |
} |
553 |
+ |
|
554 |
+ |
|
555 |
+ |
static void |
556 |
+ |
oputp( /* print point */ |
557 |
+ |
RAY *r |
558 |
+ |
) |
559 |
+ |
{ |
560 |
|
if (r->rot < FHUGE) { |
561 |
|
(*putreal)(r->rop[0]); |
562 |
|
(*putreal)(r->rop[1]); |
569 |
|
} |
570 |
|
|
571 |
|
|
572 |
< |
static |
573 |
< |
oputN(r) /* print unperturbed normal */ |
574 |
< |
register RAY *r; |
572 |
> |
static void |
573 |
> |
oputN( /* print unperturbed normal */ |
574 |
> |
RAY *r |
575 |
> |
) |
576 |
|
{ |
577 |
|
if (r->rot < FHUGE) { |
578 |
|
(*putreal)(r->ron[0]); |
586 |
|
} |
587 |
|
|
588 |
|
|
589 |
< |
static |
590 |
< |
oputn(r) /* print perturbed normal */ |
591 |
< |
RAY *r; |
589 |
> |
static void |
590 |
> |
oputn( /* print perturbed normal */ |
591 |
> |
RAY *r |
592 |
> |
) |
593 |
|
{ |
594 |
|
FVECT pnorm; |
595 |
|
|
606 |
|
} |
607 |
|
|
608 |
|
|
609 |
< |
static |
610 |
< |
oputs(r) /* print name */ |
611 |
< |
register RAY *r; |
609 |
> |
static void |
610 |
> |
oputs( /* print name */ |
611 |
> |
RAY *r |
612 |
> |
) |
613 |
|
{ |
614 |
|
if (r->ro != NULL) |
615 |
|
fputs(r->ro->oname, stdout); |
619 |
|
} |
620 |
|
|
621 |
|
|
622 |
< |
static |
623 |
< |
oputw(r) /* print weight */ |
624 |
< |
register RAY *r; |
622 |
> |
static void |
623 |
> |
oputw( /* print weight */ |
624 |
> |
RAY *r |
625 |
> |
) |
626 |
|
{ |
627 |
|
(*putreal)(r->rweight); |
628 |
|
} |
629 |
|
|
630 |
|
|
631 |
< |
static |
632 |
< |
oputm(r) /* print modifier */ |
633 |
< |
register RAY *r; |
631 |
> |
static void |
632 |
> |
oputW( /* print contribution */ |
633 |
> |
RAY *r |
634 |
> |
) |
635 |
|
{ |
636 |
+ |
COLOR contr; |
637 |
+ |
|
638 |
+ |
raycontrib(contr, r, PRIMARY); |
639 |
+ |
(*putreal)(colval(contr,RED)); |
640 |
+ |
(*putreal)(colval(contr,GRN)); |
641 |
+ |
(*putreal)(colval(contr,BLU)); |
642 |
+ |
} |
643 |
+ |
|
644 |
+ |
|
645 |
+ |
static void |
646 |
+ |
oputm( /* print modifier */ |
647 |
+ |
RAY *r |
648 |
+ |
) |
649 |
+ |
{ |
650 |
|
if (r->ro != NULL) |
651 |
< |
fputs(objptr(r->ro->omod)->oname, stdout); |
651 |
> |
if (r->ro->omod != OVOID) |
652 |
> |
fputs(objptr(r->ro->omod)->oname, stdout); |
653 |
> |
else |
654 |
> |
fputs(VOIDID, stdout); |
655 |
|
else |
656 |
|
putchar('*'); |
657 |
|
putchar('\t'); |
658 |
|
} |
659 |
|
|
660 |
|
|
661 |
< |
static |
662 |
< |
puta(v) /* print ascii value */ |
663 |
< |
double v; |
661 |
> |
static void |
662 |
> |
oputM( /* print material */ |
663 |
> |
RAY *r |
664 |
> |
) |
665 |
|
{ |
666 |
+ |
OBJREC *mat; |
667 |
+ |
|
668 |
+ |
if (r->ro != NULL) { |
669 |
+ |
if ((mat = findmaterial(r->ro)) != NULL) |
670 |
+ |
fputs(mat->oname, stdout); |
671 |
+ |
else |
672 |
+ |
fputs(VOIDID, stdout); |
673 |
+ |
} else |
674 |
+ |
putchar('*'); |
675 |
+ |
putchar('\t'); |
676 |
+ |
} |
677 |
+ |
|
678 |
+ |
|
679 |
+ |
static void |
680 |
+ |
oputtilde( /* output tilde (spacer) */ |
681 |
+ |
RAY *r |
682 |
+ |
) |
683 |
+ |
{ |
684 |
+ |
fputs("~\t", stdout); |
685 |
+ |
} |
686 |
+ |
|
687 |
+ |
|
688 |
+ |
static void |
689 |
+ |
puta( /* print ascii value */ |
690 |
+ |
double v |
691 |
+ |
) |
692 |
+ |
{ |
693 |
|
printf("%e\t", v); |
694 |
|
} |
695 |
|
|
696 |
|
|
697 |
< |
static |
697 |
> |
static void |
698 |
|
putd(v) /* print binary double */ |
699 |
|
double v; |
700 |
|
{ |
702 |
|
} |
703 |
|
|
704 |
|
|
705 |
< |
static |
705 |
> |
static void |
706 |
|
putf(v) /* print binary float */ |
707 |
|
double v; |
708 |
|
{ |