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 |
|
|
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 */ |
54 |
+ |
OBJECT traset[MAXTSET+1]={0}; /* trace include/exclude set */ |
55 |
+ |
|
56 |
|
int hresolu = 0; /* horizontal (scan) size */ |
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 */ |
62 |
< |
int directrelay = 1; /* number of source relays */ |
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 directinvis = 0; /* sources invisible? */ |
65 |
< |
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
64 |
> |
int directvis = 1; /* sources visible? */ |
65 |
> |
double srcsizerat = .2; /* maximum ratio source size/dist. */ |
66 |
|
|
67 |
+ |
COLOR cextinction = BLKCOLOR; /* global extinction coefficient */ |
68 |
+ |
COLOR salbedo = BLKCOLOR; /* global scattering albedo */ |
69 |
+ |
double seccg = 0.; /* global scattering eccentricity */ |
70 |
+ |
double ssampdist = 0.; /* scatter sampling distance */ |
71 |
+ |
|
72 |
|
double specthresh = .15; /* specular sampling threshold */ |
73 |
|
double specjitter = 1.; /* specular sampling jitter */ |
74 |
|
|
75 |
< |
int maxdepth = 6; /* maximum recursion depth */ |
60 |
< |
double minweight = 4e-3; /* minimum ray weight */ |
75 |
> |
int backvis = 1; /* back face visibility */ |
76 |
|
|
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 |
< |
double ambacc = 0.2; /* ambient accuracy */ |
83 |
< |
int ambres = 32; /* ambient resolution */ |
84 |
< |
int ambdiv = 128; /* ambient divisions */ |
85 |
< |
int ambssamp = 0; /* ambient super-samples */ |
82 |
> |
int ambvwt = 0; /* initial weight for ambient value */ |
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(), oputs(), oputw(), oputm(); |
95 |
> |
typedef void putf_t(double v); |
96 |
> |
static putf_t puta, putd, putf; |
97 |
|
|
98 |
< |
static int (*ray_out[10])(), (*every_out[10])(); |
99 |
< |
static int castonly; |
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 NON_POSIX /* XXX we don't clean up elsewhere? */ |
124 |
+ |
headclean(); /* delete header file */ |
125 |
+ |
pfclean(); /* clean up persist files */ |
126 |
+ |
#endif |
127 |
|
exit(code); |
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; |
151 |
> |
unsigned long vcount = (hresolu > 1) ? (unsigned long)hresolu*vresolu |
152 |
> |
: vresolu; |
153 |
|
long nextflush = hresolu; |
154 |
|
FILE *fp; |
155 |
+ |
double d; |
156 |
|
FVECT orig, direc; |
157 |
|
/* set up input */ |
158 |
|
if (fname == NULL) |
161 |
|
sprintf(errmsg, "cannot open input file \"%s\"", fname); |
162 |
|
error(SYSTEM, errmsg); |
163 |
|
} |
164 |
+ |
if (inform != 'a') |
165 |
+ |
SET_FILE_BINARY(fp); |
166 |
|
/* set up output */ |
167 |
|
setoutput(outvals); |
168 |
|
switch (outform) { |
176 |
|
default: |
177 |
|
error(CONSISTENCY, "botched output format"); |
178 |
|
} |
179 |
< |
fputformat(formstr(outform), stdout); |
180 |
< |
putchar('\n'); |
181 |
< |
if (hresolu > 0 && vresolu > 0) |
182 |
< |
fprtresolu(hresolu, vresolu, stdout); |
179 |
> |
if (hresolu > 0) { |
180 |
> |
if (vresolu > 0) |
181 |
> |
fprtresolu(hresolu, vresolu, stdout); |
182 |
> |
fflush(stdout); |
183 |
> |
} |
184 |
|
/* process file */ |
185 |
|
while (getvec(orig, inform, fp) == 0 && |
186 |
|
getvec(direc, inform, fp) == 0) { |
187 |
|
|
188 |
< |
if (normalize(direc) == 0.0) { /* zero ==> flush */ |
189 |
< |
fflush(stdout); |
190 |
< |
continue; |
191 |
< |
} |
192 |
< |
samplendx++; |
188 |
> |
d = normalize(direc); |
189 |
> |
if (d == 0.0) { /* zero ==> flush */ |
190 |
> |
bogusray(); |
191 |
> |
if (--nextflush <= 0 || !vcount) { |
192 |
> |
fflush(stdout); |
193 |
> |
nextflush = hresolu; |
194 |
> |
} |
195 |
> |
} else { |
196 |
> |
samplendx++; |
197 |
|
/* compute and print */ |
198 |
< |
if (imm_irrad) |
199 |
< |
irrad(orig, direc); |
200 |
< |
else |
201 |
< |
traceray(orig, direc); |
198 |
> |
if (imm_irrad) |
199 |
> |
irrad(orig, direc); |
200 |
> |
else |
201 |
> |
rad(orig, direc, lim_dist ? d : 0.0); |
202 |
|
/* flush if time */ |
203 |
< |
if (--nextflush == 0) { |
204 |
< |
fflush(stdout); |
205 |
< |
nextflush = hresolu; |
203 |
> |
if (!--nextflush) { |
204 |
> |
fflush(stdout); |
205 |
> |
nextflush = hresolu; |
206 |
> |
} |
207 |
|
} |
208 |
|
if (ferror(stdout)) |
209 |
|
error(SYSTEM, "write error"); |
210 |
< |
if (--vcount == 0) /* check for end */ |
210 |
> |
if (vcount && !--vcount) /* check for end */ |
211 |
|
break; |
212 |
|
} |
213 |
< |
if (vcount > 0) |
214 |
< |
error(USER, "read error"); |
215 |
< |
fclose(fp); |
213 |
> |
fflush(stdout); |
214 |
> |
if (vcount) |
215 |
> |
error(USER, "unexpected EOF on input"); |
216 |
> |
if (fname != NULL) |
217 |
> |
fclose(fp); |
218 |
|
} |
219 |
|
|
220 |
|
|
221 |
< |
setoutput(vs) /* set up output tables */ |
222 |
< |
register char *vs; |
221 |
> |
static void |
222 |
> |
trace_sources(void) /* trace rays to light sources, also */ |
223 |
|
{ |
224 |
< |
extern int ourtrace(), (*trace)(); |
225 |
< |
register int (**table)() = ray_out; |
224 |
> |
int sn; |
225 |
> |
|
226 |
> |
for (sn = 0; sn < nsources; sn++) |
227 |
> |
source[sn].sflags |= SFOLLOW; |
228 |
> |
} |
229 |
|
|
230 |
+ |
|
231 |
+ |
static void |
232 |
+ |
setoutput( /* set up output tables */ |
233 |
+ |
register char *vs |
234 |
+ |
) |
235 |
+ |
{ |
236 |
+ |
register oputf_t **table = ray_out; |
237 |
+ |
|
238 |
|
castonly = 1; |
239 |
|
while (*vs) |
240 |
|
switch (*vs++) { |
241 |
+ |
case 'T': /* trace sources */ |
242 |
+ |
if (!*vs) break; |
243 |
+ |
trace_sources(); |
244 |
+ |
/* fall through */ |
245 |
|
case 't': /* trace */ |
246 |
+ |
if (!*vs) break; |
247 |
|
*table = NULL; |
248 |
|
table = every_out; |
249 |
|
trace = ourtrace; |
263 |
|
*table++ = oputl; |
264 |
|
castonly = 0; |
265 |
|
break; |
266 |
+ |
case 'c': /* local coordinates */ |
267 |
+ |
*table++ = oputc; |
268 |
+ |
break; |
269 |
|
case 'L': /* single ray length */ |
270 |
|
*table++ = oputL; |
271 |
|
break; |
272 |
|
case 'p': /* point */ |
273 |
|
*table++ = oputp; |
274 |
|
break; |
275 |
< |
case 'n': /* normal */ |
275 |
> |
case 'n': /* perturbed normal */ |
276 |
|
*table++ = oputn; |
277 |
+ |
castonly = 0; |
278 |
|
break; |
279 |
+ |
case 'N': /* unperturbed normal */ |
280 |
+ |
*table++ = oputN; |
281 |
+ |
break; |
282 |
|
case 's': /* surface */ |
283 |
|
*table++ = oputs; |
284 |
|
break; |
285 |
|
case 'w': /* weight */ |
286 |
|
*table++ = oputw; |
287 |
|
break; |
288 |
+ |
case 'W': /* coefficient */ |
289 |
+ |
*table++ = oputW; |
290 |
+ |
if (ambounce > 0 && (ambacc > FTINY || ambssamp > 0)) |
291 |
+ |
error(WARNING, |
292 |
+ |
"-otW accuracy depends on -aa 0 -as 0"); |
293 |
+ |
break; |
294 |
|
case 'm': /* modifier */ |
295 |
|
*table++ = oputm; |
296 |
|
break; |
297 |
+ |
case 'M': /* material */ |
298 |
+ |
*table++ = oputM; |
299 |
+ |
break; |
300 |
+ |
case '~': /* tilde */ |
301 |
+ |
*table++ = oputtilde; |
302 |
+ |
break; |
303 |
|
} |
304 |
|
*table = NULL; |
305 |
|
} |
306 |
|
|
307 |
|
|
308 |
< |
traceray(org, dir) /* compute and print ray value(s) */ |
309 |
< |
FVECT org, dir; |
308 |
> |
static void |
309 |
> |
bogusray(void) /* print out empty record */ |
310 |
|
{ |
311 |
< |
register int (**tp)(); |
311 |
> |
thisray.rorg[0] = thisray.rorg[1] = thisray.rorg[2] = |
312 |
> |
thisray.rdir[0] = thisray.rdir[1] = thisray.rdir[2] = 0.0; |
313 |
> |
thisray.rmax = 0.0; |
314 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
315 |
> |
printvals(&thisray); |
316 |
> |
} |
317 |
|
|
318 |
+ |
|
319 |
+ |
static void |
320 |
+ |
rad( /* compute and print ray value(s) */ |
321 |
+ |
FVECT org, |
322 |
+ |
FVECT dir, |
323 |
+ |
double dmax |
324 |
+ |
) |
325 |
+ |
{ |
326 |
|
VCOPY(thisray.rorg, org); |
327 |
|
VCOPY(thisray.rdir, dir); |
328 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
329 |
< |
if (castonly) |
330 |
< |
localhit(&thisray, &thescene) || sourcehit(&thisray); |
331 |
< |
else |
328 |
> |
thisray.rmax = dmax; |
329 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
330 |
> |
if (castonly) { |
331 |
> |
if (!localhit(&thisray, &thescene)) { |
332 |
> |
if (thisray.ro == &Aftplane) { /* clipped */ |
333 |
> |
thisray.ro = NULL; |
334 |
> |
thisray.rot = FHUGE; |
335 |
> |
} else |
336 |
> |
sourcehit(&thisray); |
337 |
> |
} |
338 |
> |
} else |
339 |
|
rayvalue(&thisray); |
340 |
< |
|
233 |
< |
if (ray_out[0] == NULL) |
234 |
< |
return; |
235 |
< |
for (tp = ray_out; *tp != NULL; tp++) |
236 |
< |
(**tp)(&thisray); |
237 |
< |
if (outform == 'a') |
238 |
< |
putchar('\n'); |
340 |
> |
printvals(&thisray); |
341 |
|
} |
342 |
|
|
343 |
|
|
344 |
< |
irrad(org, dir) /* compute immediate irradiance value */ |
345 |
< |
FVECT org, dir; |
344 |
> |
static void |
345 |
> |
irrad( /* compute immediate irradiance value */ |
346 |
> |
FVECT org, |
347 |
> |
FVECT dir |
348 |
> |
) |
349 |
|
{ |
350 |
|
register int i; |
351 |
|
|
353 |
|
thisray.rorg[i] = org[i] + dir[i]; |
354 |
|
thisray.rdir[i] = -dir[i]; |
355 |
|
} |
356 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
356 |
> |
thisray.rmax = 0.0; |
357 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
358 |
|
/* pretend we hit surface */ |
359 |
< |
thisray.rot = 1.0; |
359 |
> |
thisray.rot = 1.0-1e-4; |
360 |
|
thisray.rod = 1.0; |
361 |
|
VCOPY(thisray.ron, dir); |
362 |
|
for (i = 0; i < 3; i++) /* fudge factor */ |
363 |
|
thisray.rop[i] = org[i] + 1e-4*dir[i]; |
364 |
|
/* compute and print */ |
365 |
|
(*ofun[Lamb.otype].funp)(&Lamb, &thisray); |
366 |
< |
oputv(&thisray); |
366 |
> |
printvals(&thisray); |
367 |
> |
} |
368 |
> |
|
369 |
> |
|
370 |
> |
static void |
371 |
> |
printvals( /* print requested ray values */ |
372 |
> |
RAY *r |
373 |
> |
) |
374 |
> |
{ |
375 |
> |
register oputf_t **tp; |
376 |
> |
|
377 |
> |
if (ray_out[0] == NULL) |
378 |
> |
return; |
379 |
> |
for (tp = ray_out; *tp != NULL; tp++) |
380 |
> |
(**tp)(r); |
381 |
|
if (outform == 'a') |
382 |
|
putchar('\n'); |
383 |
|
} |
384 |
|
|
385 |
|
|
386 |
< |
getvec(vec, fmt, fp) /* get a vector from fp */ |
387 |
< |
register FVECT vec; |
388 |
< |
int fmt; |
389 |
< |
FILE *fp; |
386 |
> |
static int |
387 |
> |
getvec( /* get a vector from fp */ |
388 |
> |
register FVECT vec, |
389 |
> |
int fmt, |
390 |
> |
FILE *fp |
391 |
> |
) |
392 |
|
{ |
271 |
– |
extern char *fgetword(); |
393 |
|
static float vf[3]; |
394 |
|
static double vd[3]; |
395 |
|
char buf[32]; |
421 |
|
} |
422 |
|
|
423 |
|
|
424 |
< |
static |
425 |
< |
ourtrace(r) /* print ray values */ |
426 |
< |
RAY *r; |
424 |
> |
static void |
425 |
> |
tranotify( /* record new modifier */ |
426 |
> |
OBJECT obj |
427 |
> |
) |
428 |
|
{ |
429 |
< |
register int (**tp)(); |
429 |
> |
static int hitlimit = 0; |
430 |
> |
register OBJREC *o = objptr(obj); |
431 |
> |
register char **tralp; |
432 |
|
|
433 |
+ |
if (obj == OVOID) { /* starting over */ |
434 |
+ |
traset[0] = 0; |
435 |
+ |
hitlimit = 0; |
436 |
+ |
return; |
437 |
+ |
} |
438 |
+ |
if (hitlimit || !ismodifier(o->otype)) |
439 |
+ |
return; |
440 |
+ |
for (tralp = tralist; *tralp != NULL; tralp++) |
441 |
+ |
if (!strcmp(o->oname, *tralp)) { |
442 |
+ |
if (traset[0] >= MAXTSET) { |
443 |
+ |
error(WARNING, "too many modifiers in trace list"); |
444 |
+ |
hitlimit++; |
445 |
+ |
return; /* should this be fatal? */ |
446 |
+ |
} |
447 |
+ |
insertelem(traset, obj); |
448 |
+ |
return; |
449 |
+ |
} |
450 |
+ |
} |
451 |
+ |
|
452 |
+ |
|
453 |
+ |
static void |
454 |
+ |
ourtrace( /* print ray values */ |
455 |
+ |
RAY *r |
456 |
+ |
) |
457 |
+ |
{ |
458 |
+ |
register oputf_t **tp; |
459 |
+ |
|
460 |
|
if (every_out[0] == NULL) |
461 |
|
return; |
462 |
+ |
if (r->ro == NULL) { |
463 |
+ |
if (traincl == 1) |
464 |
+ |
return; |
465 |
+ |
} else if (traincl != -1 && traincl != inset(traset, r->ro->omod)) |
466 |
+ |
return; |
467 |
|
tabin(r); |
468 |
|
for (tp = every_out; *tp != NULL; tp++) |
469 |
|
(**tp)(r); |
470 |
< |
putchar('\n'); |
470 |
> |
if (outform == 'a') |
471 |
> |
putchar('\n'); |
472 |
|
} |
473 |
|
|
474 |
|
|
475 |
< |
static |
476 |
< |
tabin(r) /* tab in appropriate amount */ |
477 |
< |
RAY *r; |
475 |
> |
static void |
476 |
> |
tabin( /* tab in appropriate amount */ |
477 |
> |
RAY *r |
478 |
> |
) |
479 |
|
{ |
480 |
< |
register RAY *rp; |
480 |
> |
const RAY *rp; |
481 |
|
|
482 |
|
for (rp = r->parent; rp != NULL; rp = rp->parent) |
483 |
|
putchar('\t'); |
484 |
|
} |
485 |
|
|
486 |
|
|
487 |
< |
static |
488 |
< |
oputo(r) /* print origin */ |
489 |
< |
register RAY *r; |
487 |
> |
static void |
488 |
> |
oputo( /* print origin */ |
489 |
> |
RAY *r |
490 |
> |
) |
491 |
|
{ |
492 |
|
(*putreal)(r->rorg[0]); |
493 |
|
(*putreal)(r->rorg[1]); |
495 |
|
} |
496 |
|
|
497 |
|
|
498 |
< |
static |
499 |
< |
oputd(r) /* print direction */ |
500 |
< |
register RAY *r; |
498 |
> |
static void |
499 |
> |
oputd( /* print direction */ |
500 |
> |
RAY *r |
501 |
> |
) |
502 |
|
{ |
503 |
|
(*putreal)(r->rdir[0]); |
504 |
|
(*putreal)(r->rdir[1]); |
506 |
|
} |
507 |
|
|
508 |
|
|
509 |
< |
static |
510 |
< |
oputv(r) /* print value */ |
511 |
< |
register RAY *r; |
509 |
> |
static void |
510 |
> |
oputv( /* print value */ |
511 |
> |
RAY *r |
512 |
> |
) |
513 |
|
{ |
353 |
– |
COLR cout; |
354 |
– |
|
514 |
|
if (outform == 'c') { |
515 |
+ |
COLR cout; |
516 |
|
setcolr(cout, colval(r->rcol,RED), |
517 |
|
colval(r->rcol,GRN), |
518 |
|
colval(r->rcol,BLU)); |
525 |
|
} |
526 |
|
|
527 |
|
|
528 |
< |
static |
529 |
< |
oputl(r) /* print effective distance */ |
530 |
< |
register RAY *r; |
528 |
> |
static void |
529 |
> |
oputl( /* print effective distance */ |
530 |
> |
RAY *r |
531 |
> |
) |
532 |
|
{ |
533 |
|
(*putreal)(r->rt); |
534 |
|
} |
535 |
|
|
536 |
|
|
537 |
< |
static |
538 |
< |
oputL(r) /* print single ray length */ |
539 |
< |
register RAY *r; |
537 |
> |
static void |
538 |
> |
oputL( /* print single ray length */ |
539 |
> |
RAY *r |
540 |
> |
) |
541 |
|
{ |
542 |
|
(*putreal)(r->rot); |
543 |
|
} |
544 |
|
|
545 |
|
|
546 |
< |
static |
547 |
< |
oputp(r) /* print point */ |
548 |
< |
register RAY *r; |
546 |
> |
static void |
547 |
> |
oputc( /* print local coordinates */ |
548 |
> |
RAY *r |
549 |
> |
) |
550 |
|
{ |
551 |
+ |
(*putreal)(r->uv[0]); |
552 |
+ |
(*putreal)(r->uv[1]); |
553 |
+ |
} |
554 |
+ |
|
555 |
+ |
|
556 |
+ |
static void |
557 |
+ |
oputp( /* print point */ |
558 |
+ |
RAY *r |
559 |
+ |
) |
560 |
+ |
{ |
561 |
|
if (r->rot < FHUGE) { |
562 |
|
(*putreal)(r->rop[0]); |
563 |
|
(*putreal)(r->rop[1]); |
570 |
|
} |
571 |
|
|
572 |
|
|
573 |
< |
static |
574 |
< |
oputn(r) /* print normal */ |
575 |
< |
register RAY *r; |
573 |
> |
static void |
574 |
> |
oputN( /* print unperturbed normal */ |
575 |
> |
RAY *r |
576 |
> |
) |
577 |
|
{ |
578 |
|
if (r->rot < FHUGE) { |
579 |
|
(*putreal)(r->ron[0]); |
587 |
|
} |
588 |
|
|
589 |
|
|
590 |
< |
static |
591 |
< |
oputs(r) /* print name */ |
592 |
< |
register RAY *r; |
590 |
> |
static void |
591 |
> |
oputn( /* print perturbed normal */ |
592 |
> |
RAY *r |
593 |
> |
) |
594 |
|
{ |
595 |
+ |
FVECT pnorm; |
596 |
+ |
|
597 |
+ |
if (r->rot >= FHUGE) { |
598 |
+ |
(*putreal)(0.0); |
599 |
+ |
(*putreal)(0.0); |
600 |
+ |
(*putreal)(0.0); |
601 |
+ |
return; |
602 |
+ |
} |
603 |
+ |
raynormal(pnorm, r); |
604 |
+ |
(*putreal)(pnorm[0]); |
605 |
+ |
(*putreal)(pnorm[1]); |
606 |
+ |
(*putreal)(pnorm[2]); |
607 |
+ |
} |
608 |
+ |
|
609 |
+ |
|
610 |
+ |
static void |
611 |
+ |
oputs( /* print name */ |
612 |
+ |
RAY *r |
613 |
+ |
) |
614 |
+ |
{ |
615 |
|
if (r->ro != NULL) |
616 |
|
fputs(r->ro->oname, stdout); |
617 |
|
else |
620 |
|
} |
621 |
|
|
622 |
|
|
623 |
< |
static |
624 |
< |
oputw(r) /* print weight */ |
625 |
< |
register RAY *r; |
623 |
> |
static void |
624 |
> |
oputw( /* print weight */ |
625 |
> |
RAY *r |
626 |
> |
) |
627 |
|
{ |
628 |
|
(*putreal)(r->rweight); |
629 |
|
} |
630 |
|
|
631 |
|
|
632 |
< |
static |
633 |
< |
oputm(r) /* print modifier */ |
634 |
< |
register RAY *r; |
632 |
> |
static void |
633 |
> |
oputW( /* print contribution */ |
634 |
> |
RAY *r |
635 |
> |
) |
636 |
|
{ |
637 |
+ |
COLOR contr; |
638 |
+ |
|
639 |
+ |
raycontrib(contr, r, PRIMARY); |
640 |
+ |
(*putreal)(colval(contr,RED)); |
641 |
+ |
(*putreal)(colval(contr,GRN)); |
642 |
+ |
(*putreal)(colval(contr,BLU)); |
643 |
+ |
} |
644 |
+ |
|
645 |
+ |
|
646 |
+ |
static void |
647 |
+ |
oputm( /* print modifier */ |
648 |
+ |
RAY *r |
649 |
+ |
) |
650 |
+ |
{ |
651 |
|
if (r->ro != NULL) |
652 |
< |
fputs(objptr(r->ro->omod)->oname, stdout); |
652 |
> |
if (r->ro->omod != OVOID) |
653 |
> |
fputs(objptr(r->ro->omod)->oname, stdout); |
654 |
> |
else |
655 |
> |
fputs(VOIDID, stdout); |
656 |
|
else |
657 |
|
putchar('*'); |
658 |
|
putchar('\t'); |
659 |
|
} |
660 |
|
|
661 |
|
|
662 |
< |
static |
663 |
< |
puta(v) /* print ascii value */ |
664 |
< |
double v; |
662 |
> |
static void |
663 |
> |
oputM( /* print material */ |
664 |
> |
RAY *r |
665 |
> |
) |
666 |
|
{ |
667 |
+ |
OBJREC *mat; |
668 |
+ |
|
669 |
+ |
if (r->ro != NULL) { |
670 |
+ |
if ((mat = findmaterial(r->ro)) != NULL) |
671 |
+ |
fputs(mat->oname, stdout); |
672 |
+ |
else |
673 |
+ |
fputs(VOIDID, stdout); |
674 |
+ |
} else |
675 |
+ |
putchar('*'); |
676 |
+ |
putchar('\t'); |
677 |
+ |
} |
678 |
+ |
|
679 |
+ |
|
680 |
+ |
static void |
681 |
+ |
oputtilde( /* output tilde (spacer) */ |
682 |
+ |
RAY *r |
683 |
+ |
) |
684 |
+ |
{ |
685 |
+ |
fputs("~\t", stdout); |
686 |
+ |
} |
687 |
+ |
|
688 |
+ |
|
689 |
+ |
static void |
690 |
+ |
puta( /* print ascii value */ |
691 |
+ |
double v |
692 |
+ |
) |
693 |
+ |
{ |
694 |
|
printf("%e\t", v); |
695 |
|
} |
696 |
|
|
697 |
|
|
698 |
< |
static |
698 |
> |
static void |
699 |
|
putd(v) /* print binary double */ |
700 |
|
double v; |
701 |
|
{ |
703 |
|
} |
704 |
|
|
705 |
|
|
706 |
< |
static |
706 |
> |
static void |
707 |
|
putf(v) /* print binary float */ |
708 |
|
double v; |
709 |
|
{ |