| 1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
| 1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
| 30 |
|
|
| 31 |
|
#include "otypes.h" |
| 32 |
|
|
| 33 |
+ |
#include "resolu.h" |
| 34 |
+ |
|
| 35 |
|
int dimlist[MAXDIM]; /* sampling dimensions */ |
| 36 |
|
int ndims = 0; /* number of sampling dimensions */ |
| 37 |
|
int samplendx = 0; /* index for this sample */ |
| 53 |
|
int directinvis = 0; /* sources invisible? */ |
| 54 |
|
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
| 55 |
|
|
| 56 |
+ |
double specthresh = .15; /* specular sampling threshold */ |
| 57 |
+ |
double specjitter = 1.; /* specular sampling jitter */ |
| 58 |
+ |
|
| 59 |
|
int maxdepth = 6; /* maximum recursion depth */ |
| 60 |
|
double minweight = 4e-3; /* minimum ray weight */ |
| 61 |
|
|
| 72 |
|
|
| 73 |
|
static RAY thisray; /* for our convenience */ |
| 74 |
|
|
| 75 |
< |
static int oputo(), oputd(), oputv(), oputl(), |
| 76 |
< |
oputp(), oputn(), oputs(), oputw(), oputm(); |
| 75 |
> |
static int oputo(), oputd(), oputv(), oputl(), oputL(), |
| 76 |
> |
oputp(), oputn(), oputN(), oputs(), oputw(), oputm(); |
| 77 |
|
|
| 78 |
|
static int (*ray_out[10])(), (*every_out[10])(); |
| 79 |
|
static int castonly; |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
|
| 93 |
+ |
char * |
| 94 |
+ |
formstr(f) /* return format identifier */ |
| 95 |
+ |
int f; |
| 96 |
+ |
{ |
| 97 |
+ |
switch (f) { |
| 98 |
+ |
case 'a': return("ascii"); |
| 99 |
+ |
case 'f': return("float"); |
| 100 |
+ |
case 'd': return("double"); |
| 101 |
+ |
case 'c': return(COLRFMT); |
| 102 |
+ |
} |
| 103 |
+ |
return("unknown"); |
| 104 |
+ |
} |
| 105 |
+ |
|
| 106 |
+ |
|
| 107 |
|
rtrace(fname) /* trace rays from file */ |
| 108 |
|
char *fname; |
| 109 |
|
{ |
| 118 |
|
sprintf(errmsg, "cannot open input file \"%s\"", fname); |
| 119 |
|
error(SYSTEM, errmsg); |
| 120 |
|
} |
| 121 |
+ |
#ifdef MSDOS |
| 122 |
+ |
if (inform != 'a') |
| 123 |
+ |
setmode(fileno(fp), O_BINARY); |
| 124 |
+ |
#endif |
| 125 |
|
/* set up output */ |
| 126 |
|
setoutput(outvals); |
| 127 |
|
switch (outform) { |
| 128 |
|
case 'a': putreal = puta; break; |
| 129 |
|
case 'f': putreal = putf; break; |
| 130 |
|
case 'd': putreal = putd; break; |
| 131 |
+ |
case 'c': |
| 132 |
+ |
if (strcmp(outvals, "v")) |
| 133 |
+ |
error(USER, "color format with value output only"); |
| 134 |
+ |
break; |
| 135 |
+ |
default: |
| 136 |
+ |
error(CONSISTENCY, "botched output format"); |
| 137 |
|
} |
| 138 |
+ |
if (hresolu > 0 && vresolu > 0) |
| 139 |
+ |
fprtresolu(hresolu, vresolu, stdout); |
| 140 |
|
/* process file */ |
| 141 |
|
while (getvec(orig, inform, fp) == 0 && |
| 142 |
|
getvec(direc, inform, fp) == 0) { |
| 192 |
|
*table++ = oputv; |
| 193 |
|
castonly = 0; |
| 194 |
|
break; |
| 195 |
< |
case 'l': /* length */ |
| 195 |
> |
case 'l': /* effective distance */ |
| 196 |
|
*table++ = oputl; |
| 197 |
|
castonly = 0; |
| 198 |
|
break; |
| 199 |
+ |
case 'L': /* single ray length */ |
| 200 |
+ |
*table++ = oputL; |
| 201 |
+ |
break; |
| 202 |
|
case 'p': /* point */ |
| 203 |
|
*table++ = oputp; |
| 204 |
|
break; |
| 205 |
< |
case 'n': /* normal */ |
| 205 |
> |
case 'n': /* perturbed normal */ |
| 206 |
|
*table++ = oputn; |
| 207 |
+ |
castonly = 0; |
| 208 |
|
break; |
| 209 |
+ |
case 'N': /* unperturbed normal */ |
| 210 |
+ |
*table++ = oputN; |
| 211 |
+ |
break; |
| 212 |
|
case 's': /* surface */ |
| 213 |
|
*table++ = oputs; |
| 214 |
|
break; |
| 275 |
|
FILE *fp; |
| 276 |
|
{ |
| 277 |
|
extern char *fgetword(); |
| 240 |
– |
extern double atof(); |
| 278 |
|
static float vf[3]; |
| 279 |
+ |
static double vd[3]; |
| 280 |
|
char buf[32]; |
| 281 |
|
register int i; |
| 282 |
|
|
| 295 |
|
vec[0] = vf[0]; vec[1] = vf[1]; vec[2] = vf[2]; |
| 296 |
|
break; |
| 297 |
|
case 'd': /* binary double */ |
| 298 |
< |
if (fread((char *)vec, sizeof(double), 3, fp) != 3) |
| 298 |
> |
if (fread((char *)vd, sizeof(double), 3, fp) != 3) |
| 299 |
|
return(-1); |
| 300 |
+ |
vec[0] = vd[0]; vec[1] = vd[1]; vec[2] = vd[2]; |
| 301 |
|
break; |
| 302 |
+ |
default: |
| 303 |
+ |
error(CONSISTENCY, "botched input format"); |
| 304 |
|
} |
| 305 |
|
return(0); |
| 306 |
|
} |
| 356 |
|
oputv(r) /* print value */ |
| 357 |
|
register RAY *r; |
| 358 |
|
{ |
| 359 |
+ |
COLR cout; |
| 360 |
+ |
|
| 361 |
+ |
if (outform == 'c') { |
| 362 |
+ |
setcolr(cout, colval(r->rcol,RED), |
| 363 |
+ |
colval(r->rcol,GRN), |
| 364 |
+ |
colval(r->rcol,BLU)); |
| 365 |
+ |
fwrite((char *)cout, sizeof(cout), 1, stdout); |
| 366 |
+ |
return; |
| 367 |
+ |
} |
| 368 |
|
(*putreal)(colval(r->rcol,RED)); |
| 369 |
|
(*putreal)(colval(r->rcol,GRN)); |
| 370 |
|
(*putreal)(colval(r->rcol,BLU)); |
| 372 |
|
|
| 373 |
|
|
| 374 |
|
static |
| 375 |
< |
oputl(r) /* print length */ |
| 375 |
> |
oputl(r) /* print effective distance */ |
| 376 |
|
register RAY *r; |
| 377 |
|
{ |
| 378 |
|
(*putreal)(r->rt); |
| 380 |
|
|
| 381 |
|
|
| 382 |
|
static |
| 383 |
+ |
oputL(r) /* print single ray length */ |
| 384 |
+ |
register RAY *r; |
| 385 |
+ |
{ |
| 386 |
+ |
(*putreal)(r->rot); |
| 387 |
+ |
} |
| 388 |
+ |
|
| 389 |
+ |
|
| 390 |
+ |
static |
| 391 |
|
oputp(r) /* print point */ |
| 392 |
|
register RAY *r; |
| 393 |
|
{ |
| 404 |
|
|
| 405 |
|
|
| 406 |
|
static |
| 407 |
< |
oputn(r) /* print normal */ |
| 407 |
> |
oputN(r) /* print unperturbed normal */ |
| 408 |
|
register RAY *r; |
| 409 |
|
{ |
| 410 |
|
if (r->rot < FHUGE) { |
| 416 |
|
(*putreal)(0.0); |
| 417 |
|
(*putreal)(0.0); |
| 418 |
|
} |
| 419 |
+ |
} |
| 420 |
+ |
|
| 421 |
+ |
|
| 422 |
+ |
static |
| 423 |
+ |
oputn(r) /* print perturbed normal */ |
| 424 |
+ |
RAY *r; |
| 425 |
+ |
{ |
| 426 |
+ |
FVECT pnorm; |
| 427 |
+ |
|
| 428 |
+ |
if (r->rot >= FHUGE) { |
| 429 |
+ |
(*putreal)(0.0); |
| 430 |
+ |
(*putreal)(0.0); |
| 431 |
+ |
(*putreal)(0.0); |
| 432 |
+ |
return; |
| 433 |
+ |
} |
| 434 |
+ |
raynormal(pnorm, r); |
| 435 |
+ |
(*putreal)(pnorm[0]); |
| 436 |
+ |
(*putreal)(pnorm[1]); |
| 437 |
+ |
(*putreal)(pnorm[2]); |
| 438 |
|
} |
| 439 |
|
|
| 440 |
|
|