ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rtrace.c
Revision: 2.56
Committed: Fri Jul 17 06:21:29 2009 UTC (14 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.55: +15 -18 lines
Log Message:
Fixed -oo output of rtrace -I

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2 greg 2.56 static const char RCSid[] = "$Id: rtrace.c,v 2.55 2007/11/17 06:21:58 greg Exp $";
3 greg 1.1 #endif
4     /*
5     * rtrace.c - program and variables for individual ray tracing.
6 greg 2.27 */
7    
8 greg 2.28 #include "copyright.h"
9 greg 1.1
10     /*
11     * Input is in the form:
12     *
13     * xorg yorg zorg xdir ydir zdir
14     *
15     * The direction need not be normalized. Output is flexible.
16 greg 1.7 * If the direction vector is (0,0,0), then the output is flushed.
17 greg 1.1 * All values default to ascii representation of real
18     * numbers. Binary representations can be selected
19     * with '-ff' for float or '-fd' for double. By default,
20 greg 1.13 * radiance is computed. The '-i' or '-I' options indicate that
21 greg 1.1 * irradiance values are desired.
22     */
23 greg 2.32
24     #include <time.h>
25 greg 1.1
26 schorsch 2.30 #include "platform.h"
27 greg 1.1 #include "ray.h"
28 schorsch 2.37 #include "ambient.h"
29     #include "source.h"
30 greg 1.1 #include "otypes.h"
31 greg 2.6 #include "resolu.h"
32 schorsch 2.49 #include "random.h"
33 greg 2.6
34 greg 2.27 CUBE thescene; /* our scene */
35     OBJECT nsceneobjs; /* number of objects in our scene */
36    
37 greg 1.14 int dimlist[MAXDIM]; /* sampling dimensions */
38     int ndims = 0; /* number of sampling dimensions */
39     int samplendx = 0; /* index for this sample */
40    
41 greg 1.13 int imm_irrad = 0; /* compute immediate irradiance? */
42 gregl 2.25 int lim_dist = 0; /* limit distance? */
43 greg 1.13
44 greg 1.1 int inform = 'a'; /* input format */
45     int outform = 'a'; /* output format */
46     char *outvals = "v"; /* output specification */
47    
48 greg 2.27 int do_irrad = 0; /* compute irradiance? */
49    
50 greg 2.54 int rand_samp = 1; /* pure Monte Carlo sampling? */
51 greg 2.47
52 greg 2.27 void (*trace)() = NULL; /* trace call */
53    
54 greg 2.55 #ifndef MAXMODLIST
55     #define MAXMODLIST 1024 /* maximum modifiers we'll track */
56     #endif
57    
58     char *tralist[MAXMODLIST]; /* list of modifers to trace (or no) */
59 greg 2.15 int traincl = -1; /* include == 1, exclude == 0 */
60 greg 2.46 #ifndef MAXTSET
61 greg 2.55 #define MAXTSET 8191 /* maximum number in trace set */
62 greg 2.46 #endif
63 greg 2.15 OBJECT traset[MAXTSET+1]={0}; /* trace include/exclude set */
64    
65 greg 1.1 int hresolu = 0; /* horizontal (scan) size */
66     int vresolu = 0; /* vertical resolution */
67    
68     double dstrsrc = 0.0; /* square source distribution */
69 greg 2.35 double shadthresh = .03; /* shadow threshold */
70     double shadcert = .75; /* shadow certainty */
71 greg 2.19 int directrelay = 2; /* number of source relays */
72 greg 1.17 int vspretest = 512; /* virtual source pretest density */
73 greg 2.10 int directvis = 1; /* sources visible? */
74 greg 2.19 double srcsizerat = .2; /* maximum ratio source size/dist. */
75 greg 2.20
76     COLOR cextinction = BLKCOLOR; /* global extinction coefficient */
77 greg 2.22 COLOR salbedo = BLKCOLOR; /* global scattering albedo */
78 greg 2.20 double seccg = 0.; /* global scattering eccentricity */
79     double ssampdist = 0.; /* scatter sampling distance */
80 greg 1.1
81 greg 2.4 double specthresh = .15; /* specular sampling threshold */
82 greg 2.3 double specjitter = 1.; /* specular sampling jitter */
83    
84 greg 2.18 int backvis = 1; /* back face visibility */
85    
86 greg 2.44 int maxdepth = -10; /* maximum recursion depth */
87 greg 2.34 double minweight = 2e-3; /* minimum ray weight */
88 greg 1.1
89 greg 2.27 char *ambfile = NULL; /* ambient file name */
90 greg 1.1 COLOR ambval = BLKCOLOR; /* ambient value */
91 greg 2.21 int ambvwt = 0; /* initial weight for ambient value */
92 greg 2.36 double ambacc = 0.15; /* ambient accuracy */
93 greg 2.34 int ambres = 256; /* ambient resolution */
94     int ambdiv = 1024; /* ambient divisions */
95     int ambssamp = 512; /* ambient super-samples */
96 greg 1.1 int ambounce = 0; /* ambient bounces */
97 greg 2.38 char *amblist[AMBLLEN]; /* ambient include/exclude list */
98 greg 1.1 int ambincl = -1; /* include == 1, exclude == 0 */
99    
100 schorsch 2.37 static int castonly = 0;
101 gregl 2.25
102 greg 1.1 static RAY thisray; /* for our convenience */
103    
104 schorsch 2.37 typedef void putf_t(double v);
105     static putf_t puta, putd, putf;
106 greg 1.1
107 schorsch 2.37 typedef void oputf_t(RAY *r);
108 greg 2.51 static oputf_t oputo, oputd, oputv, oputV, oputl, oputL, oputc, oputp,
109 greg 2.42 oputn, oputN, oputs, oputw, oputW, oputm, oputM, oputtilde;
110 schorsch 2.37
111     static void setoutput(char *vs);
112     static void tranotify(OBJECT obj);
113     static void bogusray(void);
114     static void rad(FVECT org, FVECT dir, double dmax);
115     static void irrad(FVECT org, FVECT dir);
116     static void printvals(RAY *r);
117     static int getvec(FVECT vec, int fmt, FILE *fp);
118     static void tabin(RAY *r);
119     static void ourtrace(RAY *r);
120 greg 1.1
121 schorsch 2.37 static oputf_t *ray_out[16], *every_out[16];
122     static putf_t *putreal;
123 greg 2.27
124 schorsch 2.37 void (*addobjnotify[])() = {ambnotify, tranotify, NULL};
125 greg 1.1
126    
127 greg 2.27 void
128 schorsch 2.37 quit( /* quit program */
129     int code
130     )
131 greg 1.1 {
132 schorsch 2.31 #ifndef NON_POSIX /* XXX we don't clean up elsewhere? */
133 greg 2.11 headclean(); /* delete header file */
134     pfclean(); /* clean up persist files */
135     #endif
136 greg 1.1 exit(code);
137     }
138    
139    
140 schorsch 2.37 extern char *
141     formstr( /* return format identifier */
142     int f
143     )
144 greg 2.6 {
145     switch (f) {
146     case 'a': return("ascii");
147     case 'f': return("float");
148     case 'd': return("double");
149     case 'c': return(COLRFMT);
150     }
151     return("unknown");
152     }
153    
154    
155 schorsch 2.37 extern void
156     rtrace( /* trace rays from file */
157     char *fname
158     )
159 greg 1.1 {
160 greg 2.45 unsigned long vcount = (hresolu > 1) ? (unsigned long)hresolu*vresolu
161     : vresolu;
162 greg 1.1 long nextflush = hresolu;
163     FILE *fp;
164 gregl 2.25 double d;
165 greg 1.2 FVECT orig, direc;
166 greg 1.1 /* set up input */
167     if (fname == NULL)
168     fp = stdin;
169     else if ((fp = fopen(fname, "r")) == NULL) {
170     sprintf(errmsg, "cannot open input file \"%s\"", fname);
171     error(SYSTEM, errmsg);
172     }
173 greg 2.8 if (inform != 'a')
174 schorsch 2.30 SET_FILE_BINARY(fp);
175 greg 1.1 /* set up output */
176 greg 2.16 setoutput(outvals);
177 greg 1.1 switch (outform) {
178     case 'a': putreal = puta; break;
179     case 'f': putreal = putf; break;
180     case 'd': putreal = putd; break;
181 greg 2.6 case 'c':
182     if (strcmp(outvals, "v"))
183     error(USER, "color format with value output only");
184     break;
185     default:
186     error(CONSISTENCY, "botched output format");
187 greg 1.1 }
188 greg 2.12 if (hresolu > 0) {
189     if (vresolu > 0)
190     fprtresolu(hresolu, vresolu, stdout);
191     fflush(stdout);
192     }
193 greg 1.1 /* process file */
194     while (getvec(orig, inform, fp) == 0 &&
195     getvec(direc, inform, fp) == 0) {
196    
197 gregl 2.25 d = normalize(direc);
198     if (d == 0.0) { /* zero ==> flush */
199 gregl 2.24 bogusray();
200 greg 2.45 if (--nextflush <= 0 || !vcount) {
201 gregl 2.24 fflush(stdout);
202     nextflush = hresolu;
203     }
204     } else {
205 greg 2.53 samplendx++;
206 greg 1.1 /* compute and print */
207 gregl 2.24 if (imm_irrad)
208     irrad(orig, direc);
209     else
210 gregl 2.25 rad(orig, direc, lim_dist ? d : 0.0);
211 greg 1.7 /* flush if time */
212 greg 2.45 if (!--nextflush) {
213 gregl 2.24 fflush(stdout);
214     nextflush = hresolu;
215     }
216 greg 1.1 }
217     if (ferror(stdout))
218     error(SYSTEM, "write error");
219 greg 2.45 if (vcount && !--vcount) /* check for end */
220 greg 1.1 break;
221     }
222 greg 2.50 if (fflush(stdout) < 0)
223     error(SYSTEM, "write error");
224 greg 2.45 if (vcount)
225 greg 2.42 error(USER, "unexpected EOF on input");
226 greg 2.12 if (fname != NULL)
227     fclose(fp);
228 greg 1.1 }
229    
230    
231 schorsch 2.37 static void
232 greg 2.40 trace_sources(void) /* trace rays to light sources, also */
233     {
234     int sn;
235    
236     for (sn = 0; sn < nsources; sn++)
237     source[sn].sflags |= SFOLLOW;
238     }
239    
240    
241     static void
242 schorsch 2.37 setoutput( /* set up output tables */
243 greg 2.56 char *vs
244 schorsch 2.37 )
245 greg 1.1 {
246 greg 2.56 oputf_t **table = ray_out;
247 greg 1.1
248 greg 1.11 castonly = 1;
249 greg 1.1 while (*vs)
250     switch (*vs++) {
251 greg 2.40 case 'T': /* trace sources */
252 greg 2.42 if (!*vs) break;
253 greg 2.40 trace_sources();
254     /* fall through */
255 greg 1.1 case 't': /* trace */
256 greg 2.42 if (!*vs) break;
257 greg 1.1 *table = NULL;
258     table = every_out;
259     trace = ourtrace;
260 greg 1.11 castonly = 0;
261 greg 1.1 break;
262     case 'o': /* origin */
263     *table++ = oputo;
264     break;
265     case 'd': /* direction */
266     *table++ = oputd;
267     break;
268     case 'v': /* value */
269     *table++ = oputv;
270 greg 1.11 castonly = 0;
271 greg 1.1 break;
272 greg 2.51 case 'V': /* contribution */
273     *table++ = oputV;
274     if (ambounce > 0 && (ambacc > FTINY || ambssamp > 0))
275     error(WARNING,
276     "-otV accuracy depends on -aa 0 -as 0");
277     break;
278 greg 2.5 case 'l': /* effective distance */
279 greg 1.1 *table++ = oputl;
280 greg 1.11 castonly = 0;
281 greg 1.1 break;
282 greg 2.29 case 'c': /* local coordinates */
283     *table++ = oputc;
284     break;
285 greg 2.5 case 'L': /* single ray length */
286     *table++ = oputL;
287     break;
288 greg 1.1 case 'p': /* point */
289     *table++ = oputp;
290     break;
291 greg 2.9 case 'n': /* perturbed normal */
292 greg 1.1 *table++ = oputn;
293 greg 2.9 castonly = 0;
294 greg 1.1 break;
295 greg 2.9 case 'N': /* unperturbed normal */
296     *table++ = oputN;
297     break;
298 greg 1.1 case 's': /* surface */
299     *table++ = oputs;
300     break;
301     case 'w': /* weight */
302     *table++ = oputw;
303     break;
304 greg 2.40 case 'W': /* coefficient */
305     *table++ = oputW;
306     if (ambounce > 0 && (ambacc > FTINY || ambssamp > 0))
307     error(WARNING,
308 greg 2.41 "-otW accuracy depends on -aa 0 -as 0");
309 greg 2.40 break;
310 greg 1.1 case 'm': /* modifier */
311     *table++ = oputm;
312     break;
313 greg 2.39 case 'M': /* material */
314     *table++ = oputM;
315     break;
316 greg 2.42 case '~': /* tilde */
317     *table++ = oputtilde;
318 greg 2.41 break;
319 greg 1.1 }
320     *table = NULL;
321 gregl 2.24 }
322    
323    
324 schorsch 2.37 static void
325     bogusray(void) /* print out empty record */
326 gregl 2.24 {
327     thisray.rorg[0] = thisray.rorg[1] = thisray.rorg[2] =
328     thisray.rdir[0] = thisray.rdir[1] = thisray.rdir[2] = 0.0;
329 greg 2.40 thisray.rmax = 0.0;
330     rayorigin(&thisray, PRIMARY, NULL, NULL);
331 gregl 2.24 printvals(&thisray);
332 greg 1.1 }
333    
334    
335 schorsch 2.37 static void
336     rad( /* compute and print ray value(s) */
337     FVECT org,
338     FVECT dir,
339     double dmax
340     )
341 greg 1.1 {
342     VCOPY(thisray.rorg, org);
343     VCOPY(thisray.rdir, dir);
344 gregl 2.25 thisray.rmax = dmax;
345 greg 2.40 rayorigin(&thisray, PRIMARY, NULL, NULL);
346 gregl 2.25 if (castonly) {
347 schorsch 2.33 if (!localhit(&thisray, &thescene)) {
348 gregl 2.25 if (thisray.ro == &Aftplane) { /* clipped */
349     thisray.ro = NULL;
350     thisray.rot = FHUGE;
351     } else
352     sourcehit(&thisray);
353 schorsch 2.33 }
354 gregl 2.25 } else
355 greg 1.11 rayvalue(&thisray);
356 greg 2.16 printvals(&thisray);
357 greg 1.1 }
358    
359    
360 schorsch 2.37 static void
361     irrad( /* compute immediate irradiance value */
362     FVECT org,
363     FVECT dir
364     )
365 greg 1.1 {
366 greg 2.56 VSUM(thisray.rorg, org, dir, 1.1e-4);
367     thisray.rdir[0] = -dir[0];
368     thisray.rdir[1] = -dir[1];
369     thisray.rdir[2] = -dir[2];
370 greg 2.40 thisray.rmax = 0.0;
371     rayorigin(&thisray, PRIMARY, NULL, NULL);
372 greg 1.1 /* pretend we hit surface */
373 greg 2.56 thisray.rot = 1e-5;
374 greg 1.1 thisray.rod = 1.0;
375     VCOPY(thisray.ron, dir);
376 greg 2.56 VSUM(thisray.rop, org, dir, 1e-4);
377 greg 1.1 /* compute and print */
378     (*ofun[Lamb.otype].funp)(&Lamb, &thisray);
379 greg 2.16 printvals(&thisray);
380     }
381    
382    
383 schorsch 2.37 static void
384     printvals( /* print requested ray values */
385     RAY *r
386     )
387 greg 2.16 {
388 greg 2.56 oputf_t **tp;
389 greg 2.16
390     if (ray_out[0] == NULL)
391     return;
392     for (tp = ray_out; *tp != NULL; tp++)
393     (**tp)(r);
394 greg 1.1 if (outform == 'a')
395     putchar('\n');
396     }
397    
398    
399 schorsch 2.37 static int
400     getvec( /* get a vector from fp */
401 greg 2.56 FVECT vec,
402 schorsch 2.37 int fmt,
403     FILE *fp
404     )
405 greg 1.1 {
406     static float vf[3];
407 greg 2.5 static double vd[3];
408 greg 1.19 char buf[32];
409 greg 2.56 int i;
410 greg 1.1
411     switch (fmt) {
412     case 'a': /* ascii */
413 greg 1.19 for (i = 0; i < 3; i++) {
414     if (fgetword(buf, sizeof(buf), fp) == NULL ||
415     !isflt(buf))
416     return(-1);
417     vec[i] = atof(buf);
418     }
419 greg 1.1 break;
420     case 'f': /* binary float */
421 greg 1.8 if (fread((char *)vf, sizeof(float), 3, fp) != 3)
422 greg 1.1 return(-1);
423     vec[0] = vf[0]; vec[1] = vf[1]; vec[2] = vf[2];
424     break;
425     case 'd': /* binary double */
426 greg 2.5 if (fread((char *)vd, sizeof(double), 3, fp) != 3)
427 greg 1.1 return(-1);
428 greg 2.5 vec[0] = vd[0]; vec[1] = vd[1]; vec[2] = vd[2];
429 greg 1.1 break;
430 greg 2.6 default:
431     error(CONSISTENCY, "botched input format");
432 greg 1.1 }
433     return(0);
434     }
435    
436    
437 schorsch 2.37 static void
438     tranotify( /* record new modifier */
439     OBJECT obj
440     )
441 greg 2.15 {
442     static int hitlimit = 0;
443 greg 2.56 OBJREC *o = objptr(obj);
444     char **tralp;
445 greg 2.15
446 greg 2.27 if (obj == OVOID) { /* starting over */
447     traset[0] = 0;
448     hitlimit = 0;
449     return;
450     }
451 greg 2.15 if (hitlimit || !ismodifier(o->otype))
452     return;
453     for (tralp = tralist; *tralp != NULL; tralp++)
454     if (!strcmp(o->oname, *tralp)) {
455     if (traset[0] >= MAXTSET) {
456     error(WARNING, "too many modifiers in trace list");
457     hitlimit++;
458     return; /* should this be fatal? */
459     }
460     insertelem(traset, obj);
461     return;
462     }
463     }
464    
465    
466 greg 2.27 static void
467 schorsch 2.37 ourtrace( /* print ray values */
468     RAY *r
469     )
470 greg 1.1 {
471 greg 2.56 oputf_t **tp;
472 greg 1.1
473     if (every_out[0] == NULL)
474 greg 2.15 return;
475 greg 2.16 if (r->ro == NULL) {
476     if (traincl == 1)
477     return;
478     } else if (traincl != -1 && traincl != inset(traset, r->ro->omod))
479 greg 1.1 return;
480     tabin(r);
481     for (tp = every_out; *tp != NULL; tp++)
482     (**tp)(r);
483 greg 2.41 if (outform == 'a')
484     putchar('\n');
485 greg 1.1 }
486    
487    
488 greg 2.27 static void
489 schorsch 2.37 tabin( /* tab in appropriate amount */
490     RAY *r
491     )
492 greg 1.1 {
493 greg 2.40 const RAY *rp;
494 greg 1.1
495     for (rp = r->parent; rp != NULL; rp = rp->parent)
496     putchar('\t');
497     }
498    
499    
500 greg 2.27 static void
501 schorsch 2.37 oputo( /* print origin */
502     RAY *r
503     )
504 greg 1.1 {
505     (*putreal)(r->rorg[0]);
506     (*putreal)(r->rorg[1]);
507     (*putreal)(r->rorg[2]);
508     }
509    
510    
511 greg 2.27 static void
512 schorsch 2.37 oputd( /* print direction */
513     RAY *r
514     )
515 greg 1.1 {
516     (*putreal)(r->rdir[0]);
517     (*putreal)(r->rdir[1]);
518     (*putreal)(r->rdir[2]);
519     }
520    
521    
522 greg 2.27 static void
523 schorsch 2.37 oputv( /* print value */
524     RAY *r
525     )
526 greg 1.1 {
527 greg 2.6 if (outform == 'c') {
528 greg 2.41 COLR cout;
529 greg 2.6 setcolr(cout, colval(r->rcol,RED),
530     colval(r->rcol,GRN),
531     colval(r->rcol,BLU));
532     fwrite((char *)cout, sizeof(cout), 1, stdout);
533     return;
534     }
535 greg 1.1 (*putreal)(colval(r->rcol,RED));
536     (*putreal)(colval(r->rcol,GRN));
537     (*putreal)(colval(r->rcol,BLU));
538     }
539    
540    
541 greg 2.27 static void
542 greg 2.51 oputV( /* print value contribution */
543     RAY *r
544     )
545     {
546     double contr[3];
547    
548     raycontrib(contr, r, PRIMARY);
549     multcolor(contr, r->rcol);
550     (*putreal)(contr[RED]);
551     (*putreal)(contr[GRN]);
552     (*putreal)(contr[BLU]);
553     }
554    
555    
556     static void
557 schorsch 2.37 oputl( /* print effective distance */
558     RAY *r
559     )
560 greg 1.1 {
561 greg 1.9 (*putreal)(r->rt);
562 greg 2.5 }
563    
564    
565 greg 2.27 static void
566 schorsch 2.37 oputL( /* print single ray length */
567     RAY *r
568     )
569 greg 2.5 {
570     (*putreal)(r->rot);
571 greg 1.1 }
572    
573    
574 greg 2.27 static void
575 schorsch 2.37 oputc( /* print local coordinates */
576     RAY *r
577     )
578 greg 2.29 {
579     (*putreal)(r->uv[0]);
580     (*putreal)(r->uv[1]);
581     }
582    
583    
584     static void
585 schorsch 2.37 oputp( /* print point */
586     RAY *r
587     )
588 greg 1.1 {
589     if (r->rot < FHUGE) {
590     (*putreal)(r->rop[0]);
591     (*putreal)(r->rop[1]);
592     (*putreal)(r->rop[2]);
593     } else {
594     (*putreal)(0.0);
595     (*putreal)(0.0);
596     (*putreal)(0.0);
597     }
598     }
599    
600    
601 greg 2.27 static void
602 schorsch 2.37 oputN( /* print unperturbed normal */
603     RAY *r
604     )
605 greg 1.1 {
606     if (r->rot < FHUGE) {
607     (*putreal)(r->ron[0]);
608     (*putreal)(r->ron[1]);
609     (*putreal)(r->ron[2]);
610     } else {
611     (*putreal)(0.0);
612     (*putreal)(0.0);
613     (*putreal)(0.0);
614     }
615 greg 2.9 }
616    
617    
618 greg 2.27 static void
619 schorsch 2.37 oputn( /* print perturbed normal */
620     RAY *r
621     )
622 greg 2.9 {
623     FVECT pnorm;
624    
625     if (r->rot >= FHUGE) {
626     (*putreal)(0.0);
627     (*putreal)(0.0);
628     (*putreal)(0.0);
629     return;
630     }
631     raynormal(pnorm, r);
632     (*putreal)(pnorm[0]);
633     (*putreal)(pnorm[1]);
634     (*putreal)(pnorm[2]);
635 greg 1.1 }
636    
637    
638 greg 2.27 static void
639 schorsch 2.37 oputs( /* print name */
640     RAY *r
641     )
642 greg 1.1 {
643     if (r->ro != NULL)
644     fputs(r->ro->oname, stdout);
645     else
646     putchar('*');
647     putchar('\t');
648     }
649    
650    
651 greg 2.27 static void
652 schorsch 2.37 oputw( /* print weight */
653     RAY *r
654     )
655 greg 1.1 {
656     (*putreal)(r->rweight);
657     }
658    
659    
660 greg 2.27 static void
661 greg 2.51 oputW( /* print coefficient */
662 greg 2.40 RAY *r
663     )
664     {
665 greg 2.48 double contr[3];
666 greg 2.40
667     raycontrib(contr, r, PRIMARY);
668 greg 2.48 (*putreal)(contr[RED]);
669     (*putreal)(contr[GRN]);
670     (*putreal)(contr[BLU]);
671 greg 2.40 }
672    
673    
674     static void
675 schorsch 2.37 oputm( /* print modifier */
676     RAY *r
677     )
678 greg 1.1 {
679     if (r->ro != NULL)
680 greg 2.23 if (r->ro->omod != OVOID)
681     fputs(objptr(r->ro->omod)->oname, stdout);
682     else
683     fputs(VOIDID, stdout);
684 greg 1.1 else
685     putchar('*');
686     putchar('\t');
687     }
688    
689    
690 greg 2.27 static void
691 greg 2.39 oputM( /* print material */
692     RAY *r
693     )
694     {
695     OBJREC *mat;
696    
697     if (r->ro != NULL) {
698     if ((mat = findmaterial(r->ro)) != NULL)
699     fputs(mat->oname, stdout);
700     else
701     fputs(VOIDID, stdout);
702     } else
703     putchar('*');
704     putchar('\t');
705     }
706    
707    
708     static void
709 greg 2.42 oputtilde( /* output tilde (spacer) */
710 greg 2.41 RAY *r
711     )
712     {
713 greg 2.42 fputs("~\t", stdout);
714 greg 2.41 }
715    
716    
717     static void
718 schorsch 2.37 puta( /* print ascii value */
719     double v
720     )
721 greg 1.1 {
722     printf("%e\t", v);
723     }
724    
725    
726 greg 2.27 static void
727 greg 1.1 putd(v) /* print binary double */
728     double v;
729     {
730 greg 1.8 fwrite((char *)&v, sizeof(v), 1, stdout);
731 greg 1.1 }
732    
733    
734 greg 2.27 static void
735 greg 1.1 putf(v) /* print binary float */
736     double v;
737     {
738     float f = v;
739    
740 greg 1.8 fwrite((char *)&f, sizeof(f), 1, stdout);
741 greg 1.1 }