| 1 |
< |
/* Copyright (c) 1992 Regents of the University of California */ |
| 1 |
> |
/* Copyright (c) 1994 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 |
|
|
| 61 |
|
double specthresh = .15; /* specular sampling threshold */ |
| 62 |
|
double specjitter = 1.; /* specular sampling jitter */ |
| 63 |
|
|
| 64 |
+ |
int backvis = 1; /* back face visibility */ |
| 65 |
+ |
|
| 66 |
|
int maxdepth = 6; /* maximum recursion depth */ |
| 67 |
|
double minweight = 4e-3; /* minimum ray weight */ |
| 68 |
|
|
| 82 |
|
static int oputo(), oputd(), oputv(), oputl(), oputL(), |
| 83 |
|
oputp(), oputn(), oputN(), oputs(), oputw(), oputm(); |
| 84 |
|
|
| 85 |
< |
static int (*ray_out[10])(), (*every_out[10])(); |
| 86 |
< |
static int castonly; |
| 85 |
> |
static int ourtrace(), tabin(); |
| 86 |
> |
static int (*ray_out[16])(), (*every_out[16])(); |
| 87 |
> |
static int castonly = 0; |
| 88 |
|
|
| 89 |
|
static int puta(), putf(), putd(); |
| 90 |
|
|
| 147 |
|
default: |
| 148 |
|
error(CONSISTENCY, "botched output format"); |
| 149 |
|
} |
| 150 |
< |
if (hresolu > 0 && vresolu > 0) |
| 151 |
< |
fprtresolu(hresolu, vresolu, stdout); |
| 150 |
> |
if (hresolu > 0) { |
| 151 |
> |
if (vresolu > 0) |
| 152 |
> |
fprtresolu(hresolu, vresolu, stdout); |
| 153 |
> |
fflush(stdout); |
| 154 |
> |
} |
| 155 |
|
/* process file */ |
| 156 |
|
while (getvec(orig, inform, fp) == 0 && |
| 157 |
|
getvec(direc, inform, fp) == 0) { |
| 165 |
|
if (imm_irrad) |
| 166 |
|
irrad(orig, direc); |
| 167 |
|
else |
| 168 |
< |
traceray(orig, direc); |
| 168 |
> |
rad(orig, direc); |
| 169 |
|
/* flush if time */ |
| 170 |
|
if (--nextflush == 0) { |
| 171 |
|
fflush(stdout); |
| 176 |
|
if (--vcount == 0) /* check for end */ |
| 177 |
|
break; |
| 178 |
|
} |
| 179 |
+ |
fflush(stdout); |
| 180 |
|
if (vcount > 0) |
| 181 |
|
error(USER, "read error"); |
| 182 |
< |
fclose(fp); |
| 182 |
> |
if (fname != NULL) |
| 183 |
> |
fclose(fp); |
| 184 |
|
} |
| 185 |
|
|
| 186 |
|
|
| 187 |
|
setoutput(vs) /* set up output tables */ |
| 188 |
|
register char *vs; |
| 189 |
|
{ |
| 190 |
< |
extern int ourtrace(), (*trace)(); |
| 190 |
> |
extern int (*trace)(); |
| 191 |
|
register int (**table)() = ray_out; |
| 192 |
|
|
| 193 |
|
castonly = 1; |
| 240 |
|
} |
| 241 |
|
|
| 242 |
|
|
| 243 |
< |
traceray(org, dir) /* compute and print ray value(s) */ |
| 243 |
> |
rad(org, dir) /* compute and print ray value(s) */ |
| 244 |
|
FVECT org, dir; |
| 245 |
|
{ |
| 233 |
– |
register int (**tp)(); |
| 234 |
– |
|
| 246 |
|
VCOPY(thisray.rorg, org); |
| 247 |
|
VCOPY(thisray.rdir, dir); |
| 248 |
+ |
thisray.rmax = 0.0; |
| 249 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
| 250 |
|
if (castonly) |
| 251 |
|
localhit(&thisray, &thescene) || sourcehit(&thisray); |
| 252 |
|
else |
| 253 |
|
rayvalue(&thisray); |
| 254 |
< |
|
| 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'); |
| 254 |
> |
printvals(&thisray); |
| 255 |
|
} |
| 256 |
|
|
| 257 |
|
|
| 266 |
|
} |
| 267 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
| 268 |
|
/* pretend we hit surface */ |
| 269 |
< |
thisray.rot = 1.0; |
| 269 |
> |
thisray.rot = 1.0-1e-4; |
| 270 |
|
thisray.rod = 1.0; |
| 271 |
|
VCOPY(thisray.ron, dir); |
| 272 |
|
for (i = 0; i < 3; i++) /* fudge factor */ |
| 273 |
|
thisray.rop[i] = org[i] + 1e-4*dir[i]; |
| 274 |
|
/* compute and print */ |
| 275 |
|
(*ofun[Lamb.otype].funp)(&Lamb, &thisray); |
| 276 |
< |
oputv(&thisray); |
| 276 |
> |
printvals(&thisray); |
| 277 |
> |
} |
| 278 |
> |
|
| 279 |
> |
|
| 280 |
> |
printvals(r) /* print requested ray values */ |
| 281 |
> |
RAY *r; |
| 282 |
> |
{ |
| 283 |
> |
register int (**tp)(); |
| 284 |
> |
|
| 285 |
> |
if (ray_out[0] == NULL) |
| 286 |
> |
return; |
| 287 |
> |
for (tp = ray_out; *tp != NULL; tp++) |
| 288 |
> |
(**tp)(r); |
| 289 |
|
if (outform == 'a') |
| 290 |
|
putchar('\n'); |
| 291 |
|
} |
| 328 |
|
} |
| 329 |
|
|
| 330 |
|
|
| 331 |
+ |
tranotify(obj) /* record new modifier */ |
| 332 |
+ |
OBJECT obj; |
| 333 |
+ |
{ |
| 334 |
+ |
static int hitlimit = 0; |
| 335 |
+ |
register OBJREC *o = objptr(obj); |
| 336 |
+ |
register char **tralp; |
| 337 |
+ |
|
| 338 |
+ |
if (hitlimit || !ismodifier(o->otype)) |
| 339 |
+ |
return; |
| 340 |
+ |
for (tralp = tralist; *tralp != NULL; tralp++) |
| 341 |
+ |
if (!strcmp(o->oname, *tralp)) { |
| 342 |
+ |
if (traset[0] >= MAXTSET) { |
| 343 |
+ |
error(WARNING, "too many modifiers in trace list"); |
| 344 |
+ |
hitlimit++; |
| 345 |
+ |
return; /* should this be fatal? */ |
| 346 |
+ |
} |
| 347 |
+ |
insertelem(traset, obj); |
| 348 |
+ |
return; |
| 349 |
+ |
} |
| 350 |
+ |
} |
| 351 |
+ |
|
| 352 |
+ |
|
| 353 |
|
static |
| 354 |
|
ourtrace(r) /* print ray values */ |
| 355 |
|
RAY *r; |
| 357 |
|
register int (**tp)(); |
| 358 |
|
|
| 359 |
|
if (every_out[0] == NULL) |
| 360 |
+ |
return; |
| 361 |
+ |
if (r->ro == NULL) { |
| 362 |
+ |
if (traincl == 1) |
| 363 |
+ |
return; |
| 364 |
+ |
} else if (traincl != -1 && traincl != inset(traset, r->ro->omod)) |
| 365 |
|
return; |
| 366 |
|
tabin(r); |
| 367 |
|
for (tp = every_out; *tp != NULL; tp++) |