1 |
– |
/* Copyright (c) 1992 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 |
+ |
#include "random.h" |
33 |
|
|
34 |
+ |
CUBE thescene; /* our scene */ |
35 |
+ |
OBJECT nsceneobjs; /* number of objects in our scene */ |
36 |
+ |
|
37 |
|
int dimlist[MAXDIM]; /* sampling dimensions */ |
38 |
|
int ndims = 0; /* number of sampling dimensions */ |
39 |
|
int samplendx = 0; /* index for this sample */ |
40 |
|
|
41 |
|
int imm_irrad = 0; /* compute immediate irradiance? */ |
42 |
+ |
int lim_dist = 0; /* limit distance? */ |
43 |
|
|
44 |
|
int inform = 'a'; /* input format */ |
45 |
|
int outform = 'a'; /* output format */ |
46 |
|
char *outvals = "v"; /* output specification */ |
47 |
|
|
48 |
< |
char *tralist[128]; /* list of modifers to trace (or no) */ |
48 |
> |
int do_irrad = 0; /* compute irradiance? */ |
49 |
> |
|
50 |
> |
int rand_samp = 1; /* pure Monte Carlo sampling? */ |
51 |
> |
|
52 |
> |
void (*trace)() = NULL; /* trace call */ |
53 |
> |
|
54 |
> |
#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 |
|
int traincl = -1; /* include == 1, exclude == 0 */ |
60 |
< |
#define MAXTSET 511 /* maximum number in trace set */ |
60 |
> |
#ifndef MAXTSET |
61 |
> |
#define MAXTSET 8191 /* maximum number in trace set */ |
62 |
> |
#endif |
63 |
|
OBJECT traset[MAXTSET+1]={0}; /* trace include/exclude set */ |
64 |
|
|
65 |
|
int hresolu = 0; /* horizontal (scan) size */ |
66 |
|
int vresolu = 0; /* vertical resolution */ |
67 |
|
|
68 |
|
double dstrsrc = 0.0; /* square source distribution */ |
69 |
< |
double shadthresh = .05; /* shadow threshold */ |
70 |
< |
double shadcert = .5; /* shadow certainty */ |
71 |
< |
int directrelay = 1; /* number of source relays */ |
69 |
> |
double shadthresh = .03; /* shadow threshold */ |
70 |
> |
double shadcert = .75; /* shadow certainty */ |
71 |
> |
int directrelay = 2; /* number of source relays */ |
72 |
|
int vspretest = 512; /* virtual source pretest density */ |
73 |
|
int directvis = 1; /* sources visible? */ |
74 |
< |
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
74 |
> |
double srcsizerat = .2; /* maximum ratio source size/dist. */ |
75 |
|
|
76 |
+ |
COLOR cextinction = BLKCOLOR; /* global extinction coefficient */ |
77 |
+ |
COLOR salbedo = BLKCOLOR; /* global scattering albedo */ |
78 |
+ |
double seccg = 0.; /* global scattering eccentricity */ |
79 |
+ |
double ssampdist = 0.; /* scatter sampling distance */ |
80 |
+ |
|
81 |
|
double specthresh = .15; /* specular sampling threshold */ |
82 |
|
double specjitter = 1.; /* specular sampling jitter */ |
83 |
|
|
84 |
< |
int maxdepth = 6; /* maximum recursion depth */ |
65 |
< |
double minweight = 4e-3; /* minimum ray weight */ |
84 |
> |
int backvis = 1; /* back face visibility */ |
85 |
|
|
86 |
+ |
int maxdepth = -10; /* maximum recursion depth */ |
87 |
+ |
double minweight = 2e-3; /* minimum ray weight */ |
88 |
+ |
|
89 |
+ |
char *ambfile = NULL; /* ambient file name */ |
90 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
91 |
< |
double ambacc = 0.2; /* ambient accuracy */ |
92 |
< |
int ambres = 32; /* ambient resolution */ |
93 |
< |
int ambdiv = 128; /* ambient divisions */ |
94 |
< |
int ambssamp = 0; /* ambient super-samples */ |
91 |
> |
int ambvwt = 0; /* initial weight for ambient value */ |
92 |
> |
double ambacc = 0.15; /* ambient accuracy */ |
93 |
> |
int ambres = 256; /* ambient resolution */ |
94 |
> |
int ambdiv = 1024; /* ambient divisions */ |
95 |
> |
int ambssamp = 512; /* ambient super-samples */ |
96 |
|
int ambounce = 0; /* ambient bounces */ |
97 |
< |
char *amblist[128]; /* ambient include/exclude list */ |
97 |
> |
char *amblist[AMBLLEN]; /* ambient include/exclude list */ |
98 |
|
int ambincl = -1; /* include == 1, exclude == 0 */ |
99 |
|
|
100 |
< |
extern OBJREC Lamb; /* a Lambertian surface */ |
100 |
> |
static int castonly = 0; |
101 |
|
|
102 |
|
static RAY thisray; /* for our convenience */ |
103 |
|
|
104 |
< |
static int oputo(), oputd(), oputv(), oputl(), oputL(), |
105 |
< |
oputp(), oputn(), oputN(), oputs(), oputw(), oputm(); |
104 |
> |
typedef void putf_t(double v); |
105 |
> |
static putf_t puta, putd, putf; |
106 |
|
|
107 |
< |
static int ourtrace(), tabin(); |
108 |
< |
static int (*ray_out[16])(), (*every_out[16])(); |
109 |
< |
static int castonly = 0; |
107 |
> |
typedef void oputf_t(RAY *r); |
108 |
> |
static oputf_t oputo, oputd, oputv, oputV, oputl, oputL, oputc, oputp, |
109 |
> |
oputn, oputN, oputs, oputw, oputW, oputm, oputM, oputtilde; |
110 |
|
|
111 |
< |
static int puta(), putf(), putd(); |
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 |
|
|
121 |
< |
static int (*putreal)(); |
121 |
> |
static oputf_t *ray_out[16], *every_out[16]; |
122 |
> |
static putf_t *putreal; |
123 |
|
|
124 |
+ |
void (*addobjnotify[])() = {ambnotify, tranotify, NULL}; |
125 |
|
|
126 |
< |
quit(code) /* quit program */ |
127 |
< |
int code; |
126 |
> |
|
127 |
> |
void |
128 |
> |
quit( /* quit program */ |
129 |
> |
int code |
130 |
> |
) |
131 |
|
{ |
132 |
< |
#ifndef NIX |
132 |
> |
#ifndef NON_POSIX /* XXX we don't clean up elsewhere? */ |
133 |
|
headclean(); /* delete header file */ |
134 |
|
pfclean(); /* clean up persist files */ |
135 |
|
#endif |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
< |
char * |
141 |
< |
formstr(f) /* return format identifier */ |
142 |
< |
int f; |
140 |
> |
extern char * |
141 |
> |
formstr( /* return format identifier */ |
142 |
> |
int f |
143 |
> |
) |
144 |
|
{ |
145 |
|
switch (f) { |
146 |
|
case 'a': return("ascii"); |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
< |
rtrace(fname) /* trace rays from file */ |
156 |
< |
char *fname; |
155 |
> |
extern void |
156 |
> |
rtrace( /* trace rays from file */ |
157 |
> |
char *fname |
158 |
> |
) |
159 |
|
{ |
160 |
< |
long vcount = hresolu>1 ? hresolu*vresolu : vresolu; |
160 |
> |
unsigned long vcount = (hresolu > 1) ? (unsigned long)hresolu*vresolu |
161 |
> |
: vresolu; |
162 |
|
long nextflush = hresolu; |
163 |
|
FILE *fp; |
164 |
+ |
double d; |
165 |
|
FVECT orig, direc; |
166 |
|
/* set up input */ |
167 |
|
if (fname == NULL) |
170 |
|
sprintf(errmsg, "cannot open input file \"%s\"", fname); |
171 |
|
error(SYSTEM, errmsg); |
172 |
|
} |
131 |
– |
#ifdef MSDOS |
173 |
|
if (inform != 'a') |
174 |
< |
setmode(fileno(fp), O_BINARY); |
134 |
< |
#endif |
174 |
> |
SET_FILE_BINARY(fp); |
175 |
|
/* set up output */ |
176 |
|
setoutput(outvals); |
177 |
|
switch (outform) { |
194 |
|
while (getvec(orig, inform, fp) == 0 && |
195 |
|
getvec(direc, inform, fp) == 0) { |
196 |
|
|
197 |
< |
if (normalize(direc) == 0.0) { /* zero ==> flush */ |
198 |
< |
fflush(stdout); |
199 |
< |
continue; |
200 |
< |
} |
201 |
< |
samplendx++; |
197 |
> |
d = normalize(direc); |
198 |
> |
if (d == 0.0) { /* zero ==> flush */ |
199 |
> |
bogusray(); |
200 |
> |
if (--nextflush <= 0 || !vcount) { |
201 |
> |
fflush(stdout); |
202 |
> |
nextflush = hresolu; |
203 |
> |
} |
204 |
> |
} else { |
205 |
> |
samplendx++; |
206 |
|
/* compute and print */ |
207 |
< |
if (imm_irrad) |
208 |
< |
irrad(orig, direc); |
209 |
< |
else |
210 |
< |
rad(orig, direc); |
207 |
> |
if (imm_irrad) |
208 |
> |
irrad(orig, direc); |
209 |
> |
else |
210 |
> |
rad(orig, direc, lim_dist ? d : 0.0); |
211 |
|
/* flush if time */ |
212 |
< |
if (--nextflush == 0) { |
213 |
< |
fflush(stdout); |
214 |
< |
nextflush = hresolu; |
212 |
> |
if (!--nextflush) { |
213 |
> |
fflush(stdout); |
214 |
> |
nextflush = hresolu; |
215 |
> |
} |
216 |
|
} |
217 |
|
if (ferror(stdout)) |
218 |
|
error(SYSTEM, "write error"); |
219 |
< |
if (--vcount == 0) /* check for end */ |
219 |
> |
if (vcount && !--vcount) /* check for end */ |
220 |
|
break; |
221 |
|
} |
222 |
< |
fflush(stdout); |
223 |
< |
if (vcount > 0) |
224 |
< |
error(USER, "read error"); |
222 |
> |
if (fflush(stdout) < 0) |
223 |
> |
error(SYSTEM, "write error"); |
224 |
> |
if (vcount) |
225 |
> |
error(USER, "unexpected EOF on input"); |
226 |
|
if (fname != NULL) |
227 |
|
fclose(fp); |
228 |
|
} |
229 |
|
|
230 |
|
|
231 |
< |
setoutput(vs) /* set up output tables */ |
232 |
< |
register char *vs; |
231 |
> |
static void |
232 |
> |
trace_sources(void) /* trace rays to light sources, also */ |
233 |
|
{ |
234 |
< |
extern int (*trace)(); |
235 |
< |
register int (**table)() = ray_out; |
234 |
> |
int sn; |
235 |
> |
|
236 |
> |
for (sn = 0; sn < nsources; sn++) |
237 |
> |
source[sn].sflags |= SFOLLOW; |
238 |
> |
} |
239 |
|
|
240 |
+ |
|
241 |
+ |
static void |
242 |
+ |
setoutput( /* set up output tables */ |
243 |
+ |
char *vs |
244 |
+ |
) |
245 |
+ |
{ |
246 |
+ |
oputf_t **table = ray_out; |
247 |
+ |
|
248 |
|
castonly = 1; |
249 |
|
while (*vs) |
250 |
|
switch (*vs++) { |
251 |
+ |
case 'T': /* trace sources */ |
252 |
+ |
if (!*vs) break; |
253 |
+ |
trace_sources(); |
254 |
+ |
/* fall through */ |
255 |
|
case 't': /* trace */ |
256 |
+ |
if (!*vs) break; |
257 |
|
*table = NULL; |
258 |
|
table = every_out; |
259 |
|
trace = ourtrace; |
269 |
|
*table++ = oputv; |
270 |
|
castonly = 0; |
271 |
|
break; |
272 |
+ |
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 |
|
case 'l': /* effective distance */ |
279 |
|
*table++ = oputl; |
280 |
|
castonly = 0; |
281 |
|
break; |
282 |
+ |
case 'c': /* local coordinates */ |
283 |
+ |
*table++ = oputc; |
284 |
+ |
break; |
285 |
|
case 'L': /* single ray length */ |
286 |
|
*table++ = oputL; |
287 |
|
break; |
301 |
|
case 'w': /* weight */ |
302 |
|
*table++ = oputw; |
303 |
|
break; |
304 |
+ |
case 'W': /* coefficient */ |
305 |
+ |
*table++ = oputW; |
306 |
+ |
if (ambounce > 0 && (ambacc > FTINY || ambssamp > 0)) |
307 |
+ |
error(WARNING, |
308 |
+ |
"-otW accuracy depends on -aa 0 -as 0"); |
309 |
+ |
break; |
310 |
|
case 'm': /* modifier */ |
311 |
|
*table++ = oputm; |
312 |
|
break; |
313 |
+ |
case 'M': /* material */ |
314 |
+ |
*table++ = oputM; |
315 |
+ |
break; |
316 |
+ |
case '~': /* tilde */ |
317 |
+ |
*table++ = oputtilde; |
318 |
+ |
break; |
319 |
|
} |
320 |
|
*table = NULL; |
321 |
|
} |
322 |
|
|
323 |
|
|
324 |
< |
rad(org, dir) /* compute and print ray value(s) */ |
325 |
< |
FVECT org, dir; |
324 |
> |
static void |
325 |
> |
bogusray(void) /* print out empty record */ |
326 |
|
{ |
327 |
+ |
thisray.rorg[0] = thisray.rorg[1] = thisray.rorg[2] = |
328 |
+ |
thisray.rdir[0] = thisray.rdir[1] = thisray.rdir[2] = 0.0; |
329 |
+ |
thisray.rmax = 0.0; |
330 |
+ |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
331 |
+ |
printvals(&thisray); |
332 |
+ |
} |
333 |
+ |
|
334 |
+ |
|
335 |
+ |
static void |
336 |
+ |
rad( /* compute and print ray value(s) */ |
337 |
+ |
FVECT org, |
338 |
+ |
FVECT dir, |
339 |
+ |
double dmax |
340 |
+ |
) |
341 |
+ |
{ |
342 |
|
VCOPY(thisray.rorg, org); |
343 |
|
VCOPY(thisray.rdir, dir); |
344 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
345 |
< |
if (castonly) |
346 |
< |
localhit(&thisray, &thescene) || sourcehit(&thisray); |
347 |
< |
else |
344 |
> |
thisray.rmax = dmax; |
345 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
346 |
> |
if (castonly) { |
347 |
> |
if (!localhit(&thisray, &thescene)) { |
348 |
> |
if (thisray.ro == &Aftplane) { /* clipped */ |
349 |
> |
thisray.ro = NULL; |
350 |
> |
thisray.rot = FHUGE; |
351 |
> |
} else |
352 |
> |
sourcehit(&thisray); |
353 |
> |
} |
354 |
> |
} else |
355 |
|
rayvalue(&thisray); |
356 |
|
printvals(&thisray); |
357 |
|
} |
358 |
|
|
359 |
|
|
360 |
< |
irrad(org, dir) /* compute immediate irradiance value */ |
361 |
< |
FVECT org, dir; |
360 |
> |
static void |
361 |
> |
irrad( /* compute immediate irradiance value */ |
362 |
> |
FVECT org, |
363 |
> |
FVECT dir |
364 |
> |
) |
365 |
|
{ |
366 |
< |
register int i; |
367 |
< |
|
368 |
< |
for (i = 0; i < 3; i++) { |
369 |
< |
thisray.rorg[i] = org[i] + dir[i]; |
370 |
< |
thisray.rdir[i] = -dir[i]; |
371 |
< |
} |
264 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
366 |
> |
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 |
> |
thisray.rmax = 0.0; |
371 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
372 |
|
/* pretend we hit surface */ |
373 |
< |
thisray.rot = 1.0-1e-4; |
373 |
> |
thisray.rot = 1e-5; |
374 |
|
thisray.rod = 1.0; |
375 |
|
VCOPY(thisray.ron, dir); |
376 |
< |
for (i = 0; i < 3; i++) /* fudge factor */ |
270 |
< |
thisray.rop[i] = org[i] + 1e-4*dir[i]; |
376 |
> |
VSUM(thisray.rop, org, dir, 1e-4); |
377 |
|
/* compute and print */ |
378 |
|
(*ofun[Lamb.otype].funp)(&Lamb, &thisray); |
379 |
|
printvals(&thisray); |
380 |
|
} |
381 |
|
|
382 |
|
|
383 |
< |
printvals(r) /* print requested ray values */ |
384 |
< |
RAY *r; |
383 |
> |
static void |
384 |
> |
printvals( /* print requested ray values */ |
385 |
> |
RAY *r |
386 |
> |
) |
387 |
|
{ |
388 |
< |
register int (**tp)(); |
388 |
> |
oputf_t **tp; |
389 |
|
|
390 |
|
if (ray_out[0] == NULL) |
391 |
|
return; |
396 |
|
} |
397 |
|
|
398 |
|
|
399 |
< |
getvec(vec, fmt, fp) /* get a vector from fp */ |
400 |
< |
register FVECT vec; |
401 |
< |
int fmt; |
402 |
< |
FILE *fp; |
399 |
> |
static int |
400 |
> |
getvec( /* get a vector from fp */ |
401 |
> |
FVECT vec, |
402 |
> |
int fmt, |
403 |
> |
FILE *fp |
404 |
> |
) |
405 |
|
{ |
296 |
– |
extern char *fgetword(); |
406 |
|
static float vf[3]; |
407 |
|
static double vd[3]; |
408 |
|
char buf[32]; |
409 |
< |
register int i; |
409 |
> |
int i; |
410 |
|
|
411 |
|
switch (fmt) { |
412 |
|
case 'a': /* ascii */ |
434 |
|
} |
435 |
|
|
436 |
|
|
437 |
< |
tranotify(obj) /* record new modifier */ |
438 |
< |
OBJECT obj; |
437 |
> |
static void |
438 |
> |
tranotify( /* record new modifier */ |
439 |
> |
OBJECT obj |
440 |
> |
) |
441 |
|
{ |
442 |
|
static int hitlimit = 0; |
443 |
< |
register OBJREC *o = objptr(obj); |
444 |
< |
register char **tralp; |
443 |
> |
OBJREC *o = objptr(obj); |
444 |
> |
char **tralp; |
445 |
|
|
446 |
+ |
if (obj == OVOID) { /* starting over */ |
447 |
+ |
traset[0] = 0; |
448 |
+ |
hitlimit = 0; |
449 |
+ |
return; |
450 |
+ |
} |
451 |
|
if (hitlimit || !ismodifier(o->otype)) |
452 |
|
return; |
453 |
|
for (tralp = tralist; *tralp != NULL; tralp++) |
463 |
|
} |
464 |
|
|
465 |
|
|
466 |
< |
static |
467 |
< |
ourtrace(r) /* print ray values */ |
468 |
< |
RAY *r; |
466 |
> |
static void |
467 |
> |
ourtrace( /* print ray values */ |
468 |
> |
RAY *r |
469 |
> |
) |
470 |
|
{ |
471 |
< |
register int (**tp)(); |
471 |
> |
oputf_t **tp; |
472 |
|
|
473 |
|
if (every_out[0] == NULL) |
474 |
|
return; |
480 |
|
tabin(r); |
481 |
|
for (tp = every_out; *tp != NULL; tp++) |
482 |
|
(**tp)(r); |
483 |
< |
putchar('\n'); |
483 |
> |
if (outform == 'a') |
484 |
> |
putchar('\n'); |
485 |
|
} |
486 |
|
|
487 |
|
|
488 |
< |
static |
489 |
< |
tabin(r) /* tab in appropriate amount */ |
490 |
< |
RAY *r; |
488 |
> |
static void |
489 |
> |
tabin( /* tab in appropriate amount */ |
490 |
> |
RAY *r |
491 |
> |
) |
492 |
|
{ |
493 |
< |
register RAY *rp; |
493 |
> |
const RAY *rp; |
494 |
|
|
495 |
|
for (rp = r->parent; rp != NULL; rp = rp->parent) |
496 |
|
putchar('\t'); |
497 |
|
} |
498 |
|
|
499 |
|
|
500 |
< |
static |
501 |
< |
oputo(r) /* print origin */ |
502 |
< |
register RAY *r; |
500 |
> |
static void |
501 |
> |
oputo( /* print origin */ |
502 |
> |
RAY *r |
503 |
> |
) |
504 |
|
{ |
505 |
|
(*putreal)(r->rorg[0]); |
506 |
|
(*putreal)(r->rorg[1]); |
508 |
|
} |
509 |
|
|
510 |
|
|
511 |
< |
static |
512 |
< |
oputd(r) /* print direction */ |
513 |
< |
register RAY *r; |
511 |
> |
static void |
512 |
> |
oputd( /* print direction */ |
513 |
> |
RAY *r |
514 |
> |
) |
515 |
|
{ |
516 |
|
(*putreal)(r->rdir[0]); |
517 |
|
(*putreal)(r->rdir[1]); |
519 |
|
} |
520 |
|
|
521 |
|
|
522 |
< |
static |
523 |
< |
oputv(r) /* print value */ |
524 |
< |
register RAY *r; |
522 |
> |
static void |
523 |
> |
oputv( /* print value */ |
524 |
> |
RAY *r |
525 |
> |
) |
526 |
|
{ |
405 |
– |
COLR cout; |
406 |
– |
|
527 |
|
if (outform == 'c') { |
528 |
+ |
COLR cout; |
529 |
|
setcolr(cout, colval(r->rcol,RED), |
530 |
|
colval(r->rcol,GRN), |
531 |
|
colval(r->rcol,BLU)); |
538 |
|
} |
539 |
|
|
540 |
|
|
541 |
< |
static |
542 |
< |
oputl(r) /* print effective distance */ |
543 |
< |
register RAY *r; |
541 |
> |
static void |
542 |
> |
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 |
+ |
oputl( /* print effective distance */ |
558 |
+ |
RAY *r |
559 |
+ |
) |
560 |
+ |
{ |
561 |
|
(*putreal)(r->rt); |
562 |
|
} |
563 |
|
|
564 |
|
|
565 |
< |
static |
566 |
< |
oputL(r) /* print single ray length */ |
567 |
< |
register RAY *r; |
565 |
> |
static void |
566 |
> |
oputL( /* print single ray length */ |
567 |
> |
RAY *r |
568 |
> |
) |
569 |
|
{ |
570 |
|
(*putreal)(r->rot); |
571 |
|
} |
572 |
|
|
573 |
|
|
574 |
< |
static |
575 |
< |
oputp(r) /* print point */ |
576 |
< |
register RAY *r; |
574 |
> |
static void |
575 |
> |
oputc( /* print local coordinates */ |
576 |
> |
RAY *r |
577 |
> |
) |
578 |
|
{ |
579 |
+ |
(*putreal)(r->uv[0]); |
580 |
+ |
(*putreal)(r->uv[1]); |
581 |
+ |
} |
582 |
+ |
|
583 |
+ |
|
584 |
+ |
static void |
585 |
+ |
oputp( /* print point */ |
586 |
+ |
RAY *r |
587 |
+ |
) |
588 |
+ |
{ |
589 |
|
if (r->rot < FHUGE) { |
590 |
|
(*putreal)(r->rop[0]); |
591 |
|
(*putreal)(r->rop[1]); |
598 |
|
} |
599 |
|
|
600 |
|
|
601 |
< |
static |
602 |
< |
oputN(r) /* print unperturbed normal */ |
603 |
< |
register RAY *r; |
601 |
> |
static void |
602 |
> |
oputN( /* print unperturbed normal */ |
603 |
> |
RAY *r |
604 |
> |
) |
605 |
|
{ |
606 |
|
if (r->rot < FHUGE) { |
607 |
|
(*putreal)(r->ron[0]); |
615 |
|
} |
616 |
|
|
617 |
|
|
618 |
< |
static |
619 |
< |
oputn(r) /* print perturbed normal */ |
620 |
< |
RAY *r; |
618 |
> |
static void |
619 |
> |
oputn( /* print perturbed normal */ |
620 |
> |
RAY *r |
621 |
> |
) |
622 |
|
{ |
623 |
|
FVECT pnorm; |
624 |
|
|
635 |
|
} |
636 |
|
|
637 |
|
|
638 |
< |
static |
639 |
< |
oputs(r) /* print name */ |
640 |
< |
register RAY *r; |
638 |
> |
static void |
639 |
> |
oputs( /* print name */ |
640 |
> |
RAY *r |
641 |
> |
) |
642 |
|
{ |
643 |
|
if (r->ro != NULL) |
644 |
|
fputs(r->ro->oname, stdout); |
648 |
|
} |
649 |
|
|
650 |
|
|
651 |
< |
static |
652 |
< |
oputw(r) /* print weight */ |
653 |
< |
register RAY *r; |
651 |
> |
static void |
652 |
> |
oputw( /* print weight */ |
653 |
> |
RAY *r |
654 |
> |
) |
655 |
|
{ |
656 |
|
(*putreal)(r->rweight); |
657 |
|
} |
658 |
|
|
659 |
|
|
660 |
< |
static |
661 |
< |
oputm(r) /* print modifier */ |
662 |
< |
register RAY *r; |
660 |
> |
static void |
661 |
> |
oputW( /* print coefficient */ |
662 |
> |
RAY *r |
663 |
> |
) |
664 |
|
{ |
665 |
+ |
double contr[3]; |
666 |
+ |
|
667 |
+ |
raycontrib(contr, r, PRIMARY); |
668 |
+ |
(*putreal)(contr[RED]); |
669 |
+ |
(*putreal)(contr[GRN]); |
670 |
+ |
(*putreal)(contr[BLU]); |
671 |
+ |
} |
672 |
+ |
|
673 |
+ |
|
674 |
+ |
static void |
675 |
+ |
oputm( /* print modifier */ |
676 |
+ |
RAY *r |
677 |
+ |
) |
678 |
+ |
{ |
679 |
|
if (r->ro != NULL) |
680 |
< |
fputs(objptr(r->ro->omod)->oname, stdout); |
680 |
> |
if (r->ro->omod != OVOID) |
681 |
> |
fputs(objptr(r->ro->omod)->oname, stdout); |
682 |
> |
else |
683 |
> |
fputs(VOIDID, stdout); |
684 |
|
else |
685 |
|
putchar('*'); |
686 |
|
putchar('\t'); |
687 |
|
} |
688 |
|
|
689 |
|
|
690 |
< |
static |
691 |
< |
puta(v) /* print ascii value */ |
692 |
< |
double v; |
690 |
> |
static void |
691 |
> |
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 |
+ |
oputtilde( /* output tilde (spacer) */ |
710 |
+ |
RAY *r |
711 |
+ |
) |
712 |
+ |
{ |
713 |
+ |
fputs("~\t", stdout); |
714 |
+ |
} |
715 |
+ |
|
716 |
+ |
|
717 |
+ |
static void |
718 |
+ |
puta( /* print ascii value */ |
719 |
+ |
double v |
720 |
+ |
) |
721 |
+ |
{ |
722 |
|
printf("%e\t", v); |
723 |
|
} |
724 |
|
|
725 |
|
|
726 |
< |
static |
726 |
> |
static void |
727 |
|
putd(v) /* print binary double */ |
728 |
|
double v; |
729 |
|
{ |
731 |
|
} |
732 |
|
|
733 |
|
|
734 |
< |
static |
734 |
> |
static void |
735 |
|
putf(v) /* print binary float */ |
736 |
|
double v; |
737 |
|
{ |