| 1 |
– |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* rtrace.c - program and variables for individual ray tracing. |
| 6 |
+ |
*/ |
| 7 |
+ |
|
| 8 |
+ |
/* ==================================================================== |
| 9 |
+ |
* The Radiance Software License, Version 1.0 |
| 10 |
|
* |
| 11 |
< |
* 6/11/86 |
| 11 |
> |
* Copyright (c) 1990 - 2002 The Regents of the University of California, |
| 12 |
> |
* through Lawrence Berkeley National Laboratory. All rights reserved. |
| 13 |
> |
* |
| 14 |
> |
* Redistribution and use in source and binary forms, with or without |
| 15 |
> |
* modification, are permitted provided that the following conditions |
| 16 |
> |
* are met: |
| 17 |
> |
* |
| 18 |
> |
* 1. Redistributions of source code must retain the above copyright |
| 19 |
> |
* notice, this list of conditions and the following disclaimer. |
| 20 |
> |
* |
| 21 |
> |
* 2. Redistributions in binary form must reproduce the above copyright |
| 22 |
> |
* notice, this list of conditions and the following disclaimer in |
| 23 |
> |
* the documentation and/or other materials provided with the |
| 24 |
> |
* distribution. |
| 25 |
> |
* |
| 26 |
> |
* 3. The end-user documentation included with the redistribution, |
| 27 |
> |
* if any, must include the following acknowledgment: |
| 28 |
> |
* "This product includes Radiance software |
| 29 |
> |
* (http://radsite.lbl.gov/) |
| 30 |
> |
* developed by the Lawrence Berkeley National Laboratory |
| 31 |
> |
* (http://www.lbl.gov/)." |
| 32 |
> |
* Alternately, this acknowledgment may appear in the software itself, |
| 33 |
> |
* if and wherever such third-party acknowledgments normally appear. |
| 34 |
> |
* |
| 35 |
> |
* 4. The names "Radiance," "Lawrence Berkeley National Laboratory" |
| 36 |
> |
* and "The Regents of the University of California" must |
| 37 |
> |
* not be used to endorse or promote products derived from this |
| 38 |
> |
* software without prior written permission. For written |
| 39 |
> |
* permission, please contact [email protected]. |
| 40 |
> |
* |
| 41 |
> |
* 5. Products derived from this software may not be called "Radiance", |
| 42 |
> |
* nor may "Radiance" appear in their name, without prior written |
| 43 |
> |
* permission of Lawrence Berkeley National Laboratory. |
| 44 |
> |
* |
| 45 |
> |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
| 46 |
> |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 47 |
> |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 48 |
> |
* DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR |
| 49 |
> |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 50 |
> |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 51 |
> |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 52 |
> |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 53 |
> |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 54 |
> |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 55 |
> |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 56 |
> |
* SUCH DAMAGE. |
| 57 |
> |
* ==================================================================== |
| 58 |
> |
* |
| 59 |
> |
* This software consists of voluntary contributions made by many |
| 60 |
> |
* individuals on behalf of Lawrence Berkeley National Laboratory. For more |
| 61 |
> |
* information on Lawrence Berkeley National Laboratory, please see |
| 62 |
> |
* <http://www.lbl.gov/>. |
| 63 |
|
*/ |
| 64 |
|
|
| 65 |
|
/* |
| 78 |
|
|
| 79 |
|
#include "ray.h" |
| 80 |
|
|
| 29 |
– |
#include "octree.h" |
| 30 |
– |
|
| 81 |
|
#include "otypes.h" |
| 82 |
|
|
| 83 |
|
#include "resolu.h" |
| 84 |
|
|
| 85 |
+ |
CUBE thescene; /* our scene */ |
| 86 |
+ |
OBJECT nsceneobjs; /* number of objects in our scene */ |
| 87 |
+ |
|
| 88 |
|
int dimlist[MAXDIM]; /* sampling dimensions */ |
| 89 |
|
int ndims = 0; /* number of sampling dimensions */ |
| 90 |
|
int samplendx = 0; /* index for this sample */ |
| 96 |
|
int outform = 'a'; /* output format */ |
| 97 |
|
char *outvals = "v"; /* output specification */ |
| 98 |
|
|
| 99 |
+ |
int do_irrad = 0; /* compute irradiance? */ |
| 100 |
+ |
|
| 101 |
+ |
void (*trace)() = NULL; /* trace call */ |
| 102 |
+ |
|
| 103 |
+ |
extern void ambnotify(), tranotify(); |
| 104 |
+ |
void (*addobjnotify[])() = {ambnotify, tranotify, NULL}; |
| 105 |
|
char *tralist[128]; /* list of modifers to trace (or no) */ |
| 106 |
|
int traincl = -1; /* include == 1, exclude == 0 */ |
| 107 |
|
#define MAXTSET 511 /* maximum number in trace set */ |
| 131 |
|
int maxdepth = 6; /* maximum recursion depth */ |
| 132 |
|
double minweight = 4e-3; /* minimum ray weight */ |
| 133 |
|
|
| 134 |
+ |
char *ambfile = NULL; /* ambient file name */ |
| 135 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
| 136 |
|
int ambvwt = 0; /* initial weight for ambient value */ |
| 137 |
|
double ambacc = 0.2; /* ambient accuracy */ |
| 142 |
|
char *amblist[128]; /* ambient include/exclude list */ |
| 143 |
|
int ambincl = -1; /* include == 1, exclude == 0 */ |
| 144 |
|
|
| 85 |
– |
extern OBJREC Lamb; /* a Lambertian surface */ |
| 86 |
– |
extern OBJREC Aftplane; /* aft clipping object */ |
| 145 |
|
|
| 88 |
– |
|
| 146 |
|
static RAY thisray; /* for our convenience */ |
| 147 |
|
|
| 148 |
< |
static int oputo(), oputd(), oputv(), oputl(), oputL(), |
| 148 |
> |
static void oputo(), oputd(), oputv(), oputl(), oputL(), |
| 149 |
|
oputp(), oputn(), oputN(), oputs(), oputw(), oputm(); |
| 150 |
|
|
| 151 |
< |
static int ourtrace(), tabin(); |
| 152 |
< |
static int (*ray_out[16])(), (*every_out[16])(); |
| 151 |
> |
static void ourtrace(), tabin(); |
| 152 |
> |
static void (*ray_out[16])(), (*every_out[16])(); |
| 153 |
|
static int castonly = 0; |
| 154 |
|
|
| 155 |
< |
static int puta(), putf(), putd(); |
| 155 |
> |
static void puta(), putf(), putd(); |
| 156 |
|
|
| 157 |
< |
static int (*putreal)(); |
| 157 |
> |
static void (*putreal)(); |
| 158 |
|
|
| 159 |
+ |
void bogusray(), rad(), irrad(), printvals(); |
| 160 |
|
|
| 161 |
+ |
|
| 162 |
+ |
void |
| 163 |
|
quit(code) /* quit program */ |
| 164 |
|
int code; |
| 165 |
|
{ |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
|
| 188 |
+ |
void |
| 189 |
|
rtrace(fname) /* trace rays from file */ |
| 190 |
|
char *fname; |
| 191 |
|
{ |
| 263 |
|
setoutput(vs) /* set up output tables */ |
| 264 |
|
register char *vs; |
| 265 |
|
{ |
| 266 |
< |
extern int (*trace)(); |
| 267 |
< |
register int (**table)() = ray_out; |
| 266 |
> |
extern void (*trace)(); |
| 267 |
> |
register void (**table)() = ray_out; |
| 268 |
|
|
| 269 |
|
castonly = 1; |
| 270 |
|
while (*vs) |
| 316 |
|
} |
| 317 |
|
|
| 318 |
|
|
| 319 |
+ |
void |
| 320 |
|
bogusray() /* print out empty record */ |
| 321 |
|
{ |
| 322 |
|
thisray.rorg[0] = thisray.rorg[1] = thisray.rorg[2] = |
| 326 |
|
} |
| 327 |
|
|
| 328 |
|
|
| 329 |
+ |
void |
| 330 |
|
rad(org, dir, dmax) /* compute and print ray value(s) */ |
| 331 |
|
FVECT org, dir; |
| 332 |
|
double dmax; |
| 348 |
|
} |
| 349 |
|
|
| 350 |
|
|
| 351 |
+ |
void |
| 352 |
|
irrad(org, dir) /* compute immediate irradiance value */ |
| 353 |
|
FVECT org, dir; |
| 354 |
|
{ |
| 371 |
|
} |
| 372 |
|
|
| 373 |
|
|
| 374 |
+ |
void |
| 375 |
|
printvals(r) /* print requested ray values */ |
| 376 |
|
RAY *r; |
| 377 |
|
{ |
| 378 |
< |
register int (**tp)(); |
| 378 |
> |
register void (**tp)(); |
| 379 |
|
|
| 380 |
|
if (ray_out[0] == NULL) |
| 381 |
|
return; |
| 386 |
|
} |
| 387 |
|
|
| 388 |
|
|
| 389 |
+ |
int |
| 390 |
|
getvec(vec, fmt, fp) /* get a vector from fp */ |
| 391 |
|
register FVECT vec; |
| 392 |
|
int fmt; |
| 393 |
|
FILE *fp; |
| 394 |
|
{ |
| 329 |
– |
extern char *fgetword(); |
| 395 |
|
static float vf[3]; |
| 396 |
|
static double vd[3]; |
| 397 |
|
char buf[32]; |
| 423 |
|
} |
| 424 |
|
|
| 425 |
|
|
| 426 |
+ |
void |
| 427 |
|
tranotify(obj) /* record new modifier */ |
| 428 |
|
OBJECT obj; |
| 429 |
|
{ |
| 431 |
|
register OBJREC *o = objptr(obj); |
| 432 |
|
register char **tralp; |
| 433 |
|
|
| 434 |
+ |
if (obj == OVOID) { /* starting over */ |
| 435 |
+ |
traset[0] = 0; |
| 436 |
+ |
hitlimit = 0; |
| 437 |
+ |
return; |
| 438 |
+ |
} |
| 439 |
|
if (hitlimit || !ismodifier(o->otype)) |
| 440 |
|
return; |
| 441 |
|
for (tralp = tralist; *tralp != NULL; tralp++) |
| 451 |
|
} |
| 452 |
|
|
| 453 |
|
|
| 454 |
< |
static |
| 454 |
> |
static void |
| 455 |
|
ourtrace(r) /* print ray values */ |
| 456 |
|
RAY *r; |
| 457 |
|
{ |
| 458 |
< |
register int (**tp)(); |
| 458 |
> |
register void (**tp)(); |
| 459 |
|
|
| 460 |
|
if (every_out[0] == NULL) |
| 461 |
|
return; |
| 471 |
|
} |
| 472 |
|
|
| 473 |
|
|
| 474 |
< |
static |
| 474 |
> |
static void |
| 475 |
|
tabin(r) /* tab in appropriate amount */ |
| 476 |
|
RAY *r; |
| 477 |
|
{ |
| 482 |
|
} |
| 483 |
|
|
| 484 |
|
|
| 485 |
< |
static |
| 485 |
> |
static void |
| 486 |
|
oputo(r) /* print origin */ |
| 487 |
|
register RAY *r; |
| 488 |
|
{ |
| 492 |
|
} |
| 493 |
|
|
| 494 |
|
|
| 495 |
< |
static |
| 495 |
> |
static void |
| 496 |
|
oputd(r) /* print direction */ |
| 497 |
|
register RAY *r; |
| 498 |
|
{ |
| 502 |
|
} |
| 503 |
|
|
| 504 |
|
|
| 505 |
< |
static |
| 505 |
> |
static void |
| 506 |
|
oputv(r) /* print value */ |
| 507 |
|
register RAY *r; |
| 508 |
|
{ |
| 521 |
|
} |
| 522 |
|
|
| 523 |
|
|
| 524 |
< |
static |
| 524 |
> |
static void |
| 525 |
|
oputl(r) /* print effective distance */ |
| 526 |
|
register RAY *r; |
| 527 |
|
{ |
| 529 |
|
} |
| 530 |
|
|
| 531 |
|
|
| 532 |
< |
static |
| 532 |
> |
static void |
| 533 |
|
oputL(r) /* print single ray length */ |
| 534 |
|
register RAY *r; |
| 535 |
|
{ |
| 537 |
|
} |
| 538 |
|
|
| 539 |
|
|
| 540 |
< |
static |
| 540 |
> |
static void |
| 541 |
|
oputp(r) /* print point */ |
| 542 |
|
register RAY *r; |
| 543 |
|
{ |
| 553 |
|
} |
| 554 |
|
|
| 555 |
|
|
| 556 |
< |
static |
| 556 |
> |
static void |
| 557 |
|
oputN(r) /* print unperturbed normal */ |
| 558 |
|
register RAY *r; |
| 559 |
|
{ |
| 569 |
|
} |
| 570 |
|
|
| 571 |
|
|
| 572 |
< |
static |
| 572 |
> |
static void |
| 573 |
|
oputn(r) /* print perturbed normal */ |
| 574 |
|
RAY *r; |
| 575 |
|
{ |
| 588 |
|
} |
| 589 |
|
|
| 590 |
|
|
| 591 |
< |
static |
| 591 |
> |
static void |
| 592 |
|
oputs(r) /* print name */ |
| 593 |
|
register RAY *r; |
| 594 |
|
{ |
| 600 |
|
} |
| 601 |
|
|
| 602 |
|
|
| 603 |
< |
static |
| 603 |
> |
static void |
| 604 |
|
oputw(r) /* print weight */ |
| 605 |
|
register RAY *r; |
| 606 |
|
{ |
| 608 |
|
} |
| 609 |
|
|
| 610 |
|
|
| 611 |
< |
static |
| 611 |
> |
static void |
| 612 |
|
oputm(r) /* print modifier */ |
| 613 |
|
register RAY *r; |
| 614 |
|
{ |
| 623 |
|
} |
| 624 |
|
|
| 625 |
|
|
| 626 |
< |
static |
| 626 |
> |
static void |
| 627 |
|
puta(v) /* print ascii value */ |
| 628 |
|
double v; |
| 629 |
|
{ |
| 631 |
|
} |
| 632 |
|
|
| 633 |
|
|
| 634 |
< |
static |
| 634 |
> |
static void |
| 635 |
|
putd(v) /* print binary double */ |
| 636 |
|
double v; |
| 637 |
|
{ |
| 639 |
|
} |
| 640 |
|
|
| 641 |
|
|
| 642 |
< |
static |
| 642 |
> |
static void |
| 643 |
|
putf(v) /* print binary float */ |
| 644 |
|
double v; |
| 645 |
|
{ |