1 |
< |
/* Copyright (c) 1992 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
42 |
|
int outform = 'a'; /* output format */ |
43 |
|
char *outvals = "v"; /* output specification */ |
44 |
|
|
45 |
+ |
char *tralist[128]; /* list of modifers to trace (or no) */ |
46 |
+ |
int traincl = -1; /* include == 1, exclude == 0 */ |
47 |
+ |
#define MAXTSET 511 /* maximum number in trace set */ |
48 |
+ |
OBJECT traset[MAXTSET+1]={0}; /* trace include/exclude set */ |
49 |
+ |
|
50 |
|
int hresolu = 0; /* horizontal (scan) size */ |
51 |
|
int vresolu = 0; /* vertical resolution */ |
52 |
|
|
53 |
|
double dstrsrc = 0.0; /* square source distribution */ |
54 |
|
double shadthresh = .05; /* shadow threshold */ |
55 |
|
double shadcert = .5; /* shadow certainty */ |
56 |
< |
int directrelay = 1; /* number of source relays */ |
56 |
> |
int directrelay = 2; /* number of source relays */ |
57 |
|
int vspretest = 512; /* virtual source pretest density */ |
58 |
|
int directvis = 1; /* sources visible? */ |
59 |
< |
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
59 |
> |
double srcsizerat = .2; /* maximum ratio source size/dist. */ |
60 |
|
|
61 |
+ |
COLOR cextinction = BLKCOLOR; /* global extinction coefficient */ |
62 |
+ |
double salbedo = 0.; /* global scattering albedo */ |
63 |
+ |
double seccg = 0.; /* global scattering eccentricity */ |
64 |
+ |
double ssampdist = 0.; /* scatter sampling distance */ |
65 |
+ |
|
66 |
|
double specthresh = .15; /* specular sampling threshold */ |
67 |
|
double specjitter = 1.; /* specular sampling jitter */ |
68 |
|
|
69 |
+ |
int backvis = 1; /* back face visibility */ |
70 |
+ |
|
71 |
|
int maxdepth = 6; /* maximum recursion depth */ |
72 |
|
double minweight = 4e-3; /* minimum ray weight */ |
73 |
|
|
74 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
75 |
+ |
int ambvwt = 0; /* initial weight for ambient value */ |
76 |
|
double ambacc = 0.2; /* ambient accuracy */ |
77 |
< |
int ambres = 32; /* ambient resolution */ |
78 |
< |
int ambdiv = 128; /* ambient divisions */ |
77 |
> |
int ambres = 128; /* ambient resolution */ |
78 |
> |
int ambdiv = 512; /* ambient divisions */ |
79 |
|
int ambssamp = 0; /* ambient super-samples */ |
80 |
|
int ambounce = 0; /* ambient bounces */ |
81 |
|
char *amblist[128]; /* ambient include/exclude list */ |
88 |
|
static int oputo(), oputd(), oputv(), oputl(), oputL(), |
89 |
|
oputp(), oputn(), oputN(), oputs(), oputw(), oputm(); |
90 |
|
|
91 |
< |
static int (*ray_out[10])(), (*every_out[10])(); |
92 |
< |
static int castonly; |
91 |
> |
static int ourtrace(), tabin(); |
92 |
> |
static int (*ray_out[16])(), (*every_out[16])(); |
93 |
> |
static int castonly = 0; |
94 |
|
|
95 |
|
static int puta(), putf(), putd(); |
96 |
|
|
153 |
|
default: |
154 |
|
error(CONSISTENCY, "botched output format"); |
155 |
|
} |
156 |
< |
if (hresolu > 0 && vresolu > 0) |
157 |
< |
fprtresolu(hresolu, vresolu, stdout); |
156 |
> |
if (hresolu > 0) { |
157 |
> |
if (vresolu > 0) |
158 |
> |
fprtresolu(hresolu, vresolu, stdout); |
159 |
> |
fflush(stdout); |
160 |
> |
} |
161 |
|
/* process file */ |
162 |
|
while (getvec(orig, inform, fp) == 0 && |
163 |
|
getvec(direc, inform, fp) == 0) { |
171 |
|
if (imm_irrad) |
172 |
|
irrad(orig, direc); |
173 |
|
else |
174 |
< |
traceray(orig, direc); |
174 |
> |
rad(orig, direc); |
175 |
|
/* flush if time */ |
176 |
|
if (--nextflush == 0) { |
177 |
|
fflush(stdout); |
182 |
|
if (--vcount == 0) /* check for end */ |
183 |
|
break; |
184 |
|
} |
185 |
+ |
fflush(stdout); |
186 |
|
if (vcount > 0) |
187 |
|
error(USER, "read error"); |
188 |
< |
fclose(fp); |
188 |
> |
if (fname != NULL) |
189 |
> |
fclose(fp); |
190 |
|
} |
191 |
|
|
192 |
|
|
193 |
|
setoutput(vs) /* set up output tables */ |
194 |
|
register char *vs; |
195 |
|
{ |
196 |
< |
extern int ourtrace(), (*trace)(); |
196 |
> |
extern int (*trace)(); |
197 |
|
register int (**table)() = ray_out; |
198 |
|
|
199 |
|
castonly = 1; |
246 |
|
} |
247 |
|
|
248 |
|
|
249 |
< |
traceray(org, dir) /* compute and print ray value(s) */ |
249 |
> |
rad(org, dir) /* compute and print ray value(s) */ |
250 |
|
FVECT org, dir; |
251 |
|
{ |
233 |
– |
register int (**tp)(); |
234 |
– |
|
252 |
|
VCOPY(thisray.rorg, org); |
253 |
|
VCOPY(thisray.rdir, dir); |
254 |
+ |
thisray.rmax = 0.0; |
255 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
256 |
|
if (castonly) |
257 |
|
localhit(&thisray, &thescene) || sourcehit(&thisray); |
258 |
|
else |
259 |
|
rayvalue(&thisray); |
260 |
< |
|
243 |
< |
if (ray_out[0] == NULL) |
244 |
< |
return; |
245 |
< |
for (tp = ray_out; *tp != NULL; tp++) |
246 |
< |
(**tp)(&thisray); |
247 |
< |
if (outform == 'a') |
248 |
< |
putchar('\n'); |
260 |
> |
printvals(&thisray); |
261 |
|
} |
262 |
|
|
263 |
|
|
272 |
|
} |
273 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
274 |
|
/* pretend we hit surface */ |
275 |
< |
thisray.rot = 1.0; |
275 |
> |
thisray.rot = 1.0-1e-4; |
276 |
|
thisray.rod = 1.0; |
277 |
|
VCOPY(thisray.ron, dir); |
278 |
|
for (i = 0; i < 3; i++) /* fudge factor */ |
279 |
|
thisray.rop[i] = org[i] + 1e-4*dir[i]; |
280 |
|
/* compute and print */ |
281 |
|
(*ofun[Lamb.otype].funp)(&Lamb, &thisray); |
282 |
< |
oputv(&thisray); |
282 |
> |
printvals(&thisray); |
283 |
> |
} |
284 |
> |
|
285 |
> |
|
286 |
> |
printvals(r) /* print requested ray values */ |
287 |
> |
RAY *r; |
288 |
> |
{ |
289 |
> |
register int (**tp)(); |
290 |
> |
|
291 |
> |
if (ray_out[0] == NULL) |
292 |
> |
return; |
293 |
> |
for (tp = ray_out; *tp != NULL; tp++) |
294 |
> |
(**tp)(r); |
295 |
|
if (outform == 'a') |
296 |
|
putchar('\n'); |
297 |
|
} |
334 |
|
} |
335 |
|
|
336 |
|
|
337 |
+ |
tranotify(obj) /* record new modifier */ |
338 |
+ |
OBJECT obj; |
339 |
+ |
{ |
340 |
+ |
static int hitlimit = 0; |
341 |
+ |
register OBJREC *o = objptr(obj); |
342 |
+ |
register char **tralp; |
343 |
+ |
|
344 |
+ |
if (hitlimit || !ismodifier(o->otype)) |
345 |
+ |
return; |
346 |
+ |
for (tralp = tralist; *tralp != NULL; tralp++) |
347 |
+ |
if (!strcmp(o->oname, *tralp)) { |
348 |
+ |
if (traset[0] >= MAXTSET) { |
349 |
+ |
error(WARNING, "too many modifiers in trace list"); |
350 |
+ |
hitlimit++; |
351 |
+ |
return; /* should this be fatal? */ |
352 |
+ |
} |
353 |
+ |
insertelem(traset, obj); |
354 |
+ |
return; |
355 |
+ |
} |
356 |
+ |
} |
357 |
+ |
|
358 |
+ |
|
359 |
|
static |
360 |
|
ourtrace(r) /* print ray values */ |
361 |
|
RAY *r; |
363 |
|
register int (**tp)(); |
364 |
|
|
365 |
|
if (every_out[0] == NULL) |
366 |
+ |
return; |
367 |
+ |
if (r->ro == NULL) { |
368 |
+ |
if (traincl == 1) |
369 |
+ |
return; |
370 |
+ |
} else if (traincl != -1 && traincl != inset(traset, r->ro->omod)) |
371 |
|
return; |
372 |
|
tabin(r); |
373 |
|
for (tp = every_out; *tp != NULL; tp++) |