| 1 |
– |
/* Copyright (c) 1986 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 |
|
* |
| 17 |
|
* All values default to ascii representation of real |
| 18 |
|
* numbers. Binary representations can be selected |
| 19 |
|
* with '-ff' for float or '-fd' for double. By default, |
| 20 |
< |
* radiance is computed. The '-i' option indicates that |
| 20 |
> |
* radiance is computed. The '-i' or '-I' options indicate that |
| 21 |
|
* irradiance values are desired. |
| 22 |
|
*/ |
| 23 |
|
|
| 24 |
< |
#include "ray.h" |
| 24 |
> |
#include <time.h> |
| 25 |
|
|
| 26 |
+ |
#include "platform.h" |
| 27 |
+ |
#include "ray.h" |
| 28 |
+ |
#include "ambient.h" |
| 29 |
+ |
#include "source.h" |
| 30 |
|
#include "otypes.h" |
| 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 */ |
| 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 directvis = 1; /* sources visible? */ |
| 65 |
> |
double srcsizerat = .2; /* maximum ratio source size/dist. */ |
| 66 |
|
|
| 67 |
< |
int maxdepth = 6; /* maximum recursion depth */ |
| 68 |
< |
double minweight = 4e-3; /* minimum ray weight */ |
| 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 backvis = 1; /* back face visibility */ |
| 76 |
+ |
|
| 77 |
+ |
int maxdepth = 8; /* 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 */ |
| 89 |
|
int ambincl = -1; /* include == 1, exclude == 0 */ |
| 90 |
|
|
| 91 |
+ |
static int castonly = 0; |
| 92 |
+ |
|
| 93 |
|
static RAY thisray; /* for our convenience */ |
| 94 |
|
|
| 95 |
< |
static int oputo(), oputd(), oputv(), 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])(); |
| 98 |
> |
typedef void oputf_t(RAY *r); |
| 99 |
> |
static oputf_t oputo, oputd, oputv, oputl, oputL, oputc, |
| 100 |
> |
oputp, oputn, oputN, oputs, oputw, oputm; |
| 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 |
< |
rtrace(fname) /* trace rays from file */ |
| 132 |
< |
char *fname; |
| 131 |
> |
extern char * |
| 132 |
> |
formstr( /* return format identifier */ |
| 133 |
> |
int f |
| 134 |
> |
) |
| 135 |
|
{ |
| 136 |
+ |
switch (f) { |
| 137 |
+ |
case 'a': return("ascii"); |
| 138 |
+ |
case 'f': return("float"); |
| 139 |
+ |
case 'd': return("double"); |
| 140 |
+ |
case 'c': return(COLRFMT); |
| 141 |
+ |
} |
| 142 |
+ |
return("unknown"); |
| 143 |
+ |
} |
| 144 |
+ |
|
| 145 |
+ |
|
| 146 |
+ |
extern void |
| 147 |
+ |
rtrace( /* trace rays from file */ |
| 148 |
+ |
char *fname |
| 149 |
+ |
) |
| 150 |
+ |
{ |
| 151 |
|
long vcount = hresolu>1 ? hresolu*vresolu : vresolu; |
| 152 |
|
long nextflush = hresolu; |
| 153 |
|
FILE *fp; |
| 154 |
+ |
double d; |
| 155 |
|
FVECT orig, direc; |
| 156 |
|
/* set up input */ |
| 157 |
|
if (fname == NULL) |
| 160 |
|
sprintf(errmsg, "cannot open input file \"%s\"", fname); |
| 161 |
|
error(SYSTEM, errmsg); |
| 162 |
|
} |
| 163 |
+ |
#ifdef _WIN32 |
| 164 |
+ |
if (inform != 'a') |
| 165 |
+ |
SET_FILE_BINARY(fp); |
| 166 |
+ |
#endif |
| 167 |
|
/* set up output */ |
| 168 |
|
setoutput(outvals); |
| 169 |
|
switch (outform) { |
| 170 |
|
case 'a': putreal = puta; break; |
| 171 |
|
case 'f': putreal = putf; break; |
| 172 |
|
case 'd': putreal = putd; break; |
| 173 |
+ |
case 'c': |
| 174 |
+ |
if (strcmp(outvals, "v")) |
| 175 |
+ |
error(USER, "color format with value output only"); |
| 176 |
+ |
break; |
| 177 |
+ |
default: |
| 178 |
+ |
error(CONSISTENCY, "botched output format"); |
| 179 |
|
} |
| 180 |
+ |
if (hresolu > 0) { |
| 181 |
+ |
if (vresolu > 0) |
| 182 |
+ |
fprtresolu(hresolu, vresolu, stdout); |
| 183 |
+ |
fflush(stdout); |
| 184 |
+ |
} |
| 185 |
|
/* process file */ |
| 186 |
|
while (getvec(orig, inform, fp) == 0 && |
| 187 |
|
getvec(direc, inform, fp) == 0) { |
| 188 |
|
|
| 189 |
< |
if (normalize(direc) == 0.0) { /* zero ==> flush */ |
| 190 |
< |
fflush(stdout); |
| 191 |
< |
continue; |
| 192 |
< |
} |
| 189 |
> |
d = normalize(direc); |
| 190 |
> |
if (d == 0.0) { /* zero ==> flush */ |
| 191 |
> |
bogusray(); |
| 192 |
> |
if (--nextflush <= 0 || vcount <= 0) { |
| 193 |
> |
fflush(stdout); |
| 194 |
> |
nextflush = hresolu; |
| 195 |
> |
} |
| 196 |
> |
} else { |
| 197 |
> |
samplendx++; |
| 198 |
|
/* compute and print */ |
| 199 |
< |
if (outvals[0] == 'i') |
| 200 |
< |
irrad(orig, direc); |
| 201 |
< |
else |
| 202 |
< |
radiance(orig, direc); |
| 199 |
> |
if (imm_irrad) |
| 200 |
> |
irrad(orig, direc); |
| 201 |
> |
else |
| 202 |
> |
rad(orig, direc, lim_dist ? d : 0.0); |
| 203 |
|
/* flush if time */ |
| 204 |
< |
if (--nextflush == 0) { |
| 205 |
< |
fflush(stdout); |
| 206 |
< |
nextflush = hresolu; |
| 204 |
> |
if (--nextflush == 0) { |
| 205 |
> |
fflush(stdout); |
| 206 |
> |
nextflush = hresolu; |
| 207 |
> |
} |
| 208 |
|
} |
| 209 |
|
if (ferror(stdout)) |
| 210 |
|
error(SYSTEM, "write error"); |
| 211 |
|
if (--vcount == 0) /* check for end */ |
| 212 |
|
break; |
| 213 |
|
} |
| 214 |
+ |
fflush(stdout); |
| 215 |
|
if (vcount > 0) |
| 216 |
|
error(USER, "read error"); |
| 217 |
< |
fclose(fp); |
| 217 |
> |
if (fname != NULL) |
| 218 |
> |
fclose(fp); |
| 219 |
|
} |
| 220 |
|
|
| 221 |
|
|
| 222 |
< |
setoutput(vs) /* set up output tables */ |
| 223 |
< |
register char *vs; |
| 222 |
> |
static void |
| 223 |
> |
setoutput( /* set up output tables */ |
| 224 |
> |
register char *vs |
| 225 |
> |
) |
| 226 |
|
{ |
| 227 |
< |
extern int ourtrace(), (*trace)(); |
| 127 |
< |
register int (**table)() = ray_out; |
| 227 |
> |
register oputf_t **table = ray_out; |
| 228 |
|
|
| 229 |
+ |
castonly = 1; |
| 230 |
|
while (*vs) |
| 231 |
|
switch (*vs++) { |
| 232 |
|
case 't': /* trace */ |
| 233 |
|
*table = NULL; |
| 234 |
|
table = every_out; |
| 235 |
|
trace = ourtrace; |
| 236 |
+ |
castonly = 0; |
| 237 |
|
break; |
| 238 |
|
case 'o': /* origin */ |
| 239 |
|
*table++ = oputo; |
| 243 |
|
break; |
| 244 |
|
case 'v': /* value */ |
| 245 |
|
*table++ = oputv; |
| 246 |
+ |
castonly = 0; |
| 247 |
|
break; |
| 248 |
< |
case 'l': /* length */ |
| 248 |
> |
case 'l': /* effective distance */ |
| 249 |
|
*table++ = oputl; |
| 250 |
+ |
castonly = 0; |
| 251 |
|
break; |
| 252 |
+ |
case 'c': /* local coordinates */ |
| 253 |
+ |
*table++ = oputc; |
| 254 |
+ |
break; |
| 255 |
+ |
case 'L': /* single ray length */ |
| 256 |
+ |
*table++ = oputL; |
| 257 |
+ |
break; |
| 258 |
|
case 'p': /* point */ |
| 259 |
|
*table++ = oputp; |
| 260 |
|
break; |
| 261 |
< |
case 'n': /* normal */ |
| 261 |
> |
case 'n': /* perturbed normal */ |
| 262 |
|
*table++ = oputn; |
| 263 |
+ |
castonly = 0; |
| 264 |
|
break; |
| 265 |
+ |
case 'N': /* unperturbed normal */ |
| 266 |
+ |
*table++ = oputN; |
| 267 |
+ |
break; |
| 268 |
|
case 's': /* surface */ |
| 269 |
|
*table++ = oputs; |
| 270 |
|
break; |
| 279 |
|
} |
| 280 |
|
|
| 281 |
|
|
| 282 |
< |
radiance(org, dir) /* compute radiance value */ |
| 283 |
< |
FVECT org, dir; |
| 282 |
> |
static void |
| 283 |
> |
bogusray(void) /* print out empty record */ |
| 284 |
|
{ |
| 285 |
< |
register int (**tp)(); |
| 285 |
> |
thisray.rorg[0] = thisray.rorg[1] = thisray.rorg[2] = |
| 286 |
> |
thisray.rdir[0] = thisray.rdir[1] = thisray.rdir[2] = 0.0; |
| 287 |
> |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
| 288 |
> |
printvals(&thisray); |
| 289 |
> |
} |
| 290 |
|
|
| 291 |
+ |
|
| 292 |
+ |
static void |
| 293 |
+ |
rad( /* compute and print ray value(s) */ |
| 294 |
+ |
FVECT org, |
| 295 |
+ |
FVECT dir, |
| 296 |
+ |
double dmax |
| 297 |
+ |
) |
| 298 |
+ |
{ |
| 299 |
|
VCOPY(thisray.rorg, org); |
| 300 |
|
VCOPY(thisray.rdir, dir); |
| 301 |
+ |
thisray.rmax = dmax; |
| 302 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
| 303 |
< |
rayvalue(&thisray); |
| 304 |
< |
|
| 305 |
< |
if (ray_out[0] == NULL) |
| 306 |
< |
return; |
| 307 |
< |
for (tp = ray_out; *tp != NULL; tp++) |
| 308 |
< |
(**tp)(&thisray); |
| 309 |
< |
if (outform == 'a') |
| 310 |
< |
putchar('\n'); |
| 303 |
> |
if (castonly) { |
| 304 |
> |
if (!localhit(&thisray, &thescene)) { |
| 305 |
> |
if (thisray.ro == &Aftplane) { /* clipped */ |
| 306 |
> |
thisray.ro = NULL; |
| 307 |
> |
thisray.rot = FHUGE; |
| 308 |
> |
} else |
| 309 |
> |
sourcehit(&thisray); |
| 310 |
> |
} |
| 311 |
> |
} else |
| 312 |
> |
rayvalue(&thisray); |
| 313 |
> |
printvals(&thisray); |
| 314 |
|
} |
| 315 |
|
|
| 316 |
|
|
| 317 |
< |
irrad(org, dir) /* compute irradiance value */ |
| 318 |
< |
FVECT org, dir; |
| 317 |
> |
static void |
| 318 |
> |
irrad( /* compute immediate irradiance value */ |
| 319 |
> |
FVECT org, |
| 320 |
> |
FVECT dir |
| 321 |
> |
) |
| 322 |
|
{ |
| 190 |
– |
static double Lambfa[5] = {PI, PI, PI, 0.0, 0.0}; |
| 191 |
– |
static OBJREC Lamb = { |
| 192 |
– |
OVOID, MAT_PLASTIC, "Lambertian", |
| 193 |
– |
{0, 5, NULL, Lambfa}, NULL, -1, |
| 194 |
– |
}; |
| 323 |
|
register int i; |
| 324 |
|
|
| 325 |
|
for (i = 0; i < 3; i++) { |
| 328 |
|
} |
| 329 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
| 330 |
|
/* pretend we hit surface */ |
| 331 |
< |
thisray.rot = 1.0; |
| 331 |
> |
thisray.rot = 1.0-1e-4; |
| 332 |
|
thisray.rod = 1.0; |
| 333 |
|
VCOPY(thisray.ron, dir); |
| 334 |
|
for (i = 0; i < 3; i++) /* fudge factor */ |
| 335 |
|
thisray.rop[i] = org[i] + 1e-4*dir[i]; |
| 336 |
|
/* compute and print */ |
| 337 |
|
(*ofun[Lamb.otype].funp)(&Lamb, &thisray); |
| 338 |
< |
oputv(&thisray); |
| 338 |
> |
printvals(&thisray); |
| 339 |
> |
} |
| 340 |
> |
|
| 341 |
> |
|
| 342 |
> |
static void |
| 343 |
> |
printvals( /* print requested ray values */ |
| 344 |
> |
RAY *r |
| 345 |
> |
) |
| 346 |
> |
{ |
| 347 |
> |
register oputf_t **tp; |
| 348 |
> |
|
| 349 |
> |
if (ray_out[0] == NULL) |
| 350 |
> |
return; |
| 351 |
> |
for (tp = ray_out; *tp != NULL; tp++) |
| 352 |
> |
(**tp)(r); |
| 353 |
|
if (outform == 'a') |
| 354 |
|
putchar('\n'); |
| 355 |
|
} |
| 356 |
|
|
| 357 |
|
|
| 358 |
< |
getvec(vec, fmt, fp) /* get a vector from fp */ |
| 359 |
< |
register FVECT vec; |
| 360 |
< |
int fmt; |
| 361 |
< |
FILE *fp; |
| 358 |
> |
static int |
| 359 |
> |
getvec( /* get a vector from fp */ |
| 360 |
> |
register FVECT vec, |
| 361 |
> |
int fmt, |
| 362 |
> |
FILE *fp |
| 363 |
> |
) |
| 364 |
|
{ |
| 365 |
|
static float vf[3]; |
| 366 |
+ |
static double vd[3]; |
| 367 |
+ |
char buf[32]; |
| 368 |
+ |
register int i; |
| 369 |
|
|
| 370 |
|
switch (fmt) { |
| 371 |
|
case 'a': /* ascii */ |
| 372 |
< |
if (fscanf(fp, "%lf %lf %lf", vec, vec+1, vec+2) != 3) |
| 373 |
< |
return(-1); |
| 372 |
> |
for (i = 0; i < 3; i++) { |
| 373 |
> |
if (fgetword(buf, sizeof(buf), fp) == NULL || |
| 374 |
> |
!isflt(buf)) |
| 375 |
> |
return(-1); |
| 376 |
> |
vec[i] = atof(buf); |
| 377 |
> |
} |
| 378 |
|
break; |
| 379 |
|
case 'f': /* binary float */ |
| 380 |
|
if (fread((char *)vf, sizeof(float), 3, fp) != 3) |
| 382 |
|
vec[0] = vf[0]; vec[1] = vf[1]; vec[2] = vf[2]; |
| 383 |
|
break; |
| 384 |
|
case 'd': /* binary double */ |
| 385 |
< |
if (fread((char *)vec, sizeof(double), 3, fp) != 3) |
| 385 |
> |
if (fread((char *)vd, sizeof(double), 3, fp) != 3) |
| 386 |
|
return(-1); |
| 387 |
+ |
vec[0] = vd[0]; vec[1] = vd[1]; vec[2] = vd[2]; |
| 388 |
|
break; |
| 389 |
+ |
default: |
| 390 |
+ |
error(CONSISTENCY, "botched input format"); |
| 391 |
|
} |
| 392 |
|
return(0); |
| 393 |
|
} |
| 394 |
|
|
| 395 |
|
|
| 396 |
< |
static |
| 397 |
< |
ourtrace(r) /* print ray values */ |
| 398 |
< |
RAY *r; |
| 396 |
> |
static void |
| 397 |
> |
tranotify( /* record new modifier */ |
| 398 |
> |
OBJECT obj |
| 399 |
> |
) |
| 400 |
|
{ |
| 401 |
< |
register int (**tp)(); |
| 401 |
> |
static int hitlimit = 0; |
| 402 |
> |
register OBJREC *o = objptr(obj); |
| 403 |
> |
register char **tralp; |
| 404 |
|
|
| 405 |
+ |
if (obj == OVOID) { /* starting over */ |
| 406 |
+ |
traset[0] = 0; |
| 407 |
+ |
hitlimit = 0; |
| 408 |
+ |
return; |
| 409 |
+ |
} |
| 410 |
+ |
if (hitlimit || !ismodifier(o->otype)) |
| 411 |
+ |
return; |
| 412 |
+ |
for (tralp = tralist; *tralp != NULL; tralp++) |
| 413 |
+ |
if (!strcmp(o->oname, *tralp)) { |
| 414 |
+ |
if (traset[0] >= MAXTSET) { |
| 415 |
+ |
error(WARNING, "too many modifiers in trace list"); |
| 416 |
+ |
hitlimit++; |
| 417 |
+ |
return; /* should this be fatal? */ |
| 418 |
+ |
} |
| 419 |
+ |
insertelem(traset, obj); |
| 420 |
+ |
return; |
| 421 |
+ |
} |
| 422 |
+ |
} |
| 423 |
+ |
|
| 424 |
+ |
|
| 425 |
+ |
static void |
| 426 |
+ |
ourtrace( /* print ray values */ |
| 427 |
+ |
RAY *r |
| 428 |
+ |
) |
| 429 |
+ |
{ |
| 430 |
+ |
register oputf_t **tp; |
| 431 |
+ |
|
| 432 |
|
if (every_out[0] == NULL) |
| 433 |
|
return; |
| 434 |
+ |
if (r->ro == NULL) { |
| 435 |
+ |
if (traincl == 1) |
| 436 |
+ |
return; |
| 437 |
+ |
} else if (traincl != -1 && traincl != inset(traset, r->ro->omod)) |
| 438 |
+ |
return; |
| 439 |
|
tabin(r); |
| 440 |
|
for (tp = every_out; *tp != NULL; tp++) |
| 441 |
|
(**tp)(r); |
| 443 |
|
} |
| 444 |
|
|
| 445 |
|
|
| 446 |
< |
static |
| 447 |
< |
tabin(r) /* tab in appropriate amount */ |
| 448 |
< |
RAY *r; |
| 446 |
> |
static void |
| 447 |
> |
tabin( /* tab in appropriate amount */ |
| 448 |
> |
RAY *r |
| 449 |
> |
) |
| 450 |
|
{ |
| 451 |
|
register RAY *rp; |
| 452 |
|
|
| 455 |
|
} |
| 456 |
|
|
| 457 |
|
|
| 458 |
< |
static |
| 459 |
< |
oputo(r) /* print origin */ |
| 460 |
< |
register RAY *r; |
| 458 |
> |
static void |
| 459 |
> |
oputo( /* print origin */ |
| 460 |
> |
RAY *r |
| 461 |
> |
) |
| 462 |
|
{ |
| 463 |
|
(*putreal)(r->rorg[0]); |
| 464 |
|
(*putreal)(r->rorg[1]); |
| 466 |
|
} |
| 467 |
|
|
| 468 |
|
|
| 469 |
< |
static |
| 470 |
< |
oputd(r) /* print direction */ |
| 471 |
< |
register RAY *r; |
| 469 |
> |
static void |
| 470 |
> |
oputd( /* print direction */ |
| 471 |
> |
RAY *r |
| 472 |
> |
) |
| 473 |
|
{ |
| 474 |
|
(*putreal)(r->rdir[0]); |
| 475 |
|
(*putreal)(r->rdir[1]); |
| 477 |
|
} |
| 478 |
|
|
| 479 |
|
|
| 480 |
< |
static |
| 481 |
< |
oputv(r) /* print value */ |
| 482 |
< |
register RAY *r; |
| 480 |
> |
static void |
| 481 |
> |
oputv( /* print value */ |
| 482 |
> |
RAY *r |
| 483 |
> |
) |
| 484 |
|
{ |
| 485 |
+ |
COLR cout; |
| 486 |
+ |
|
| 487 |
+ |
if (outform == 'c') { |
| 488 |
+ |
setcolr(cout, colval(r->rcol,RED), |
| 489 |
+ |
colval(r->rcol,GRN), |
| 490 |
+ |
colval(r->rcol,BLU)); |
| 491 |
+ |
fwrite((char *)cout, sizeof(cout), 1, stdout); |
| 492 |
+ |
return; |
| 493 |
+ |
} |
| 494 |
|
(*putreal)(colval(r->rcol,RED)); |
| 495 |
|
(*putreal)(colval(r->rcol,GRN)); |
| 496 |
|
(*putreal)(colval(r->rcol,BLU)); |
| 497 |
|
} |
| 498 |
|
|
| 499 |
|
|
| 500 |
< |
static |
| 501 |
< |
oputl(r) /* print length */ |
| 502 |
< |
register RAY *r; |
| 500 |
> |
static void |
| 501 |
> |
oputl( /* print effective distance */ |
| 502 |
> |
RAY *r |
| 503 |
> |
) |
| 504 |
|
{ |
| 505 |
|
(*putreal)(r->rt); |
| 506 |
|
} |
| 507 |
|
|
| 508 |
|
|
| 509 |
< |
static |
| 510 |
< |
oputp(r) /* print point */ |
| 511 |
< |
register RAY *r; |
| 509 |
> |
static void |
| 510 |
> |
oputL( /* print single ray length */ |
| 511 |
> |
RAY *r |
| 512 |
> |
) |
| 513 |
|
{ |
| 514 |
+ |
(*putreal)(r->rot); |
| 515 |
+ |
} |
| 516 |
+ |
|
| 517 |
+ |
|
| 518 |
+ |
static void |
| 519 |
+ |
oputc( /* print local coordinates */ |
| 520 |
+ |
RAY *r |
| 521 |
+ |
) |
| 522 |
+ |
{ |
| 523 |
+ |
(*putreal)(r->uv[0]); |
| 524 |
+ |
(*putreal)(r->uv[1]); |
| 525 |
+ |
} |
| 526 |
+ |
|
| 527 |
+ |
|
| 528 |
+ |
static void |
| 529 |
+ |
oputp( /* print point */ |
| 530 |
+ |
RAY *r |
| 531 |
+ |
) |
| 532 |
+ |
{ |
| 533 |
|
if (r->rot < FHUGE) { |
| 534 |
|
(*putreal)(r->rop[0]); |
| 535 |
|
(*putreal)(r->rop[1]); |
| 542 |
|
} |
| 543 |
|
|
| 544 |
|
|
| 545 |
< |
static |
| 546 |
< |
oputn(r) /* print normal */ |
| 547 |
< |
register RAY *r; |
| 545 |
> |
static void |
| 546 |
> |
oputN( /* print unperturbed normal */ |
| 547 |
> |
RAY *r |
| 548 |
> |
) |
| 549 |
|
{ |
| 550 |
|
if (r->rot < FHUGE) { |
| 551 |
|
(*putreal)(r->ron[0]); |
| 559 |
|
} |
| 560 |
|
|
| 561 |
|
|
| 562 |
< |
static |
| 563 |
< |
oputs(r) /* print name */ |
| 564 |
< |
register RAY *r; |
| 562 |
> |
static void |
| 563 |
> |
oputn( /* print perturbed normal */ |
| 564 |
> |
RAY *r |
| 565 |
> |
) |
| 566 |
|
{ |
| 567 |
+ |
FVECT pnorm; |
| 568 |
+ |
|
| 569 |
+ |
if (r->rot >= FHUGE) { |
| 570 |
+ |
(*putreal)(0.0); |
| 571 |
+ |
(*putreal)(0.0); |
| 572 |
+ |
(*putreal)(0.0); |
| 573 |
+ |
return; |
| 574 |
+ |
} |
| 575 |
+ |
raynormal(pnorm, r); |
| 576 |
+ |
(*putreal)(pnorm[0]); |
| 577 |
+ |
(*putreal)(pnorm[1]); |
| 578 |
+ |
(*putreal)(pnorm[2]); |
| 579 |
+ |
} |
| 580 |
+ |
|
| 581 |
+ |
|
| 582 |
+ |
static void |
| 583 |
+ |
oputs( /* print name */ |
| 584 |
+ |
RAY *r |
| 585 |
+ |
) |
| 586 |
+ |
{ |
| 587 |
|
if (r->ro != NULL) |
| 588 |
|
fputs(r->ro->oname, stdout); |
| 589 |
|
else |
| 592 |
|
} |
| 593 |
|
|
| 594 |
|
|
| 595 |
< |
static |
| 596 |
< |
oputw(r) /* print weight */ |
| 597 |
< |
register RAY *r; |
| 595 |
> |
static void |
| 596 |
> |
oputw( /* print weight */ |
| 597 |
> |
RAY *r |
| 598 |
> |
) |
| 599 |
|
{ |
| 600 |
|
(*putreal)(r->rweight); |
| 601 |
|
} |
| 602 |
|
|
| 603 |
|
|
| 604 |
< |
static |
| 605 |
< |
oputm(r) /* print modifier */ |
| 606 |
< |
register RAY *r; |
| 604 |
> |
static void |
| 605 |
> |
oputm( /* print modifier */ |
| 606 |
> |
RAY *r |
| 607 |
> |
) |
| 608 |
|
{ |
| 609 |
|
if (r->ro != NULL) |
| 610 |
< |
fputs(objptr(r->ro->omod)->oname, stdout); |
| 610 |
> |
if (r->ro->omod != OVOID) |
| 611 |
> |
fputs(objptr(r->ro->omod)->oname, stdout); |
| 612 |
> |
else |
| 613 |
> |
fputs(VOIDID, stdout); |
| 614 |
|
else |
| 615 |
|
putchar('*'); |
| 616 |
|
putchar('\t'); |
| 617 |
|
} |
| 618 |
|
|
| 619 |
|
|
| 620 |
< |
static |
| 621 |
< |
puta(v) /* print ascii value */ |
| 622 |
< |
double v; |
| 620 |
> |
static void |
| 621 |
> |
puta( /* print ascii value */ |
| 622 |
> |
double v |
| 623 |
> |
) |
| 624 |
|
{ |
| 625 |
|
printf("%e\t", v); |
| 626 |
|
} |
| 627 |
|
|
| 628 |
|
|
| 629 |
< |
static |
| 629 |
> |
static void |
| 630 |
|
putd(v) /* print binary double */ |
| 631 |
|
double v; |
| 632 |
|
{ |
| 634 |
|
} |
| 635 |
|
|
| 636 |
|
|
| 637 |
< |
static |
| 637 |
> |
static void |
| 638 |
|
putf(v) /* print binary float */ |
| 639 |
|
double v; |
| 640 |
|
{ |