5 |
|
* rtrace.c - program and variables for individual ray tracing. |
6 |
|
*/ |
7 |
|
|
8 |
< |
/* ==================================================================== |
9 |
< |
* The Radiance Software License, Version 1.0 |
10 |
< |
* |
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 |
< |
*/ |
8 |
> |
#include "copyright.h" |
9 |
|
|
10 |
|
/* |
11 |
|
* Input is in the form: |
21 |
|
* irradiance values are desired. |
22 |
|
*/ |
23 |
|
|
24 |
+ |
#include "platform.h" |
25 |
|
#include "ray.h" |
80 |
– |
|
26 |
|
#include "otypes.h" |
82 |
– |
|
27 |
|
#include "resolu.h" |
28 |
|
|
29 |
|
CUBE thescene; /* our scene */ |
89 |
|
|
90 |
|
static RAY thisray; /* for our convenience */ |
91 |
|
|
92 |
< |
static void oputo(), oputd(), oputv(), oputl(), oputL(), |
92 |
> |
static void oputo(), oputd(), oputv(), oputl(), oputL(), oputc(), |
93 |
|
oputp(), oputn(), oputN(), oputs(), oputw(), oputm(); |
94 |
|
|
95 |
|
static void ourtrace(), tabin(); |
145 |
|
sprintf(errmsg, "cannot open input file \"%s\"", fname); |
146 |
|
error(SYSTEM, errmsg); |
147 |
|
} |
148 |
< |
#ifdef MSDOS |
148 |
> |
#ifdef _WIN32 |
149 |
|
if (inform != 'a') |
150 |
< |
setmode(fileno(fp), O_BINARY); |
150 |
> |
SET_FILE_BINARY(fp); |
151 |
|
#endif |
152 |
|
/* set up output */ |
153 |
|
setoutput(outvals); |
233 |
|
*table++ = oputl; |
234 |
|
castonly = 0; |
235 |
|
break; |
236 |
+ |
case 'c': /* local coordinates */ |
237 |
+ |
*table++ = oputc; |
238 |
+ |
break; |
239 |
|
case 'L': /* single ray length */ |
240 |
|
*table++ = oputL; |
241 |
|
break; |
431 |
|
|
432 |
|
static void |
433 |
|
oputo(r) /* print origin */ |
434 |
< |
register RAY *r; |
434 |
> |
RAY *r; |
435 |
|
{ |
436 |
|
(*putreal)(r->rorg[0]); |
437 |
|
(*putreal)(r->rorg[1]); |
441 |
|
|
442 |
|
static void |
443 |
|
oputd(r) /* print direction */ |
444 |
< |
register RAY *r; |
444 |
> |
RAY *r; |
445 |
|
{ |
446 |
|
(*putreal)(r->rdir[0]); |
447 |
|
(*putreal)(r->rdir[1]); |
451 |
|
|
452 |
|
static void |
453 |
|
oputv(r) /* print value */ |
454 |
< |
register RAY *r; |
454 |
> |
RAY *r; |
455 |
|
{ |
456 |
|
COLR cout; |
457 |
|
|
470 |
|
|
471 |
|
static void |
472 |
|
oputl(r) /* print effective distance */ |
473 |
< |
register RAY *r; |
473 |
> |
RAY *r; |
474 |
|
{ |
475 |
|
(*putreal)(r->rt); |
476 |
|
} |
478 |
|
|
479 |
|
static void |
480 |
|
oputL(r) /* print single ray length */ |
481 |
< |
register RAY *r; |
481 |
> |
RAY *r; |
482 |
|
{ |
483 |
|
(*putreal)(r->rot); |
484 |
|
} |
485 |
|
|
486 |
|
|
487 |
|
static void |
488 |
+ |
oputc(r) /* print local coordinates */ |
489 |
+ |
RAY *r; |
490 |
+ |
{ |
491 |
+ |
(*putreal)(r->uv[0]); |
492 |
+ |
(*putreal)(r->uv[1]); |
493 |
+ |
} |
494 |
+ |
|
495 |
+ |
|
496 |
+ |
static void |
497 |
|
oputp(r) /* print point */ |
498 |
< |
register RAY *r; |
498 |
> |
RAY *r; |
499 |
|
{ |
500 |
|
if (r->rot < FHUGE) { |
501 |
|
(*putreal)(r->rop[0]); |
511 |
|
|
512 |
|
static void |
513 |
|
oputN(r) /* print unperturbed normal */ |
514 |
< |
register RAY *r; |
514 |
> |
RAY *r; |
515 |
|
{ |
516 |
|
if (r->rot < FHUGE) { |
517 |
|
(*putreal)(r->ron[0]); |
546 |
|
|
547 |
|
static void |
548 |
|
oputs(r) /* print name */ |
549 |
< |
register RAY *r; |
549 |
> |
RAY *r; |
550 |
|
{ |
551 |
|
if (r->ro != NULL) |
552 |
|
fputs(r->ro->oname, stdout); |
558 |
|
|
559 |
|
static void |
560 |
|
oputw(r) /* print weight */ |
561 |
< |
register RAY *r; |
561 |
> |
RAY *r; |
562 |
|
{ |
563 |
|
(*putreal)(r->rweight); |
564 |
|
} |
566 |
|
|
567 |
|
static void |
568 |
|
oputm(r) /* print modifier */ |
569 |
< |
register RAY *r; |
569 |
> |
RAY *r; |
570 |
|
{ |
571 |
|
if (r->ro != NULL) |
572 |
|
if (r->ro->omod != OVOID) |