ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rtrace.c
(Generate patch)

Comparing ray/src/rt/rtrace.c (file contents):
Revision 1.9 by greg, Tue Mar 27 11:40:10 1990 UTC vs.
Revision 1.12 by greg, Thu Mar 28 10:16:35 1991 UTC

# Line 20 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20   *  All values default to ascii representation of real
21   *  numbers.  Binary representations can be selected
22   *  with '-ff' for float or '-fd' for double.  By default,
23 < *  radiance is computed.  The '-i' option indicates that
23 > *  radiance is computed.  The '-oi' or '-oI' options indicate that
24   *  irradiance values are desired.
25   */
26  
27   #include  "ray.h"
28  
29 + #include  "octree.h"
30 +
31   #include  "otypes.h"
32  
33   int  inform = 'a';                      /* input format */
# Line 53 | Line 55 | int  ambincl = -1;                     /* include == 1, exclude == 0 */
55  
56   static RAY  thisray;                    /* for our convenience */
57  
58 < extern int  oputo(), oputd(), oputv(), oputl(),
58 > static int  oputo(), oputd(), oputv(), oputl(),
59                  oputp(), oputn(), oputs(), oputw(), oputm();
60  
61   static int  (*ray_out[10])(), (*every_out[10])();
62 + static int  castonly;
63  
64 < extern int  puta(), putf(), putd();
64 > static int  puta(), putf(), putd();
65  
66   static int  (*putreal)();
67  
68 + static double  Lambfa[5] = {PI, PI, PI, 0.0, 0.0};
69 + static OBJREC  Lamb = {
70 +        OVOID, MAT_PLASTIC, "Lambertian",
71 +        {0, 5, NULL, Lambfa}, NULL, -1,
72 + };                                      /* a Lambertian surface */
73  
74 +
75   quit(code)                      /* quit program */
76   int  code;
77   {
# Line 102 | Line 111 | char  *fname;
111                                                          /* compute and print */
112                  if (outvals[0] == 'i')
113                          irrad(orig, direc);
114 +                else if (outvals[0] == 'I')
115 +                        Irrad(orig, direc);
116                  else
117                          radiance(orig, direc);
118                                                          /* flush if time */
# Line 126 | Line 137 | register char  *vs;
137          extern int  ourtrace(), (*trace)();
138          register int (**table)() = ray_out;
139  
140 +        castonly = 1;
141          while (*vs)
142                  switch (*vs++) {
143                  case 't':                               /* trace */
144                          *table = NULL;
145                          table = every_out;
146                          trace = ourtrace;
147 +                        castonly = 0;
148                          break;
149                  case 'o':                               /* origin */
150                          *table++ = oputo;
# Line 141 | Line 154 | register char  *vs;
154                          break;
155                  case 'v':                               /* value */
156                          *table++ = oputv;
157 +                        castonly = 0;
158                          break;
159                  case 'l':                               /* length */
160                          *table++ = oputl;
161 +                        castonly = 0;
162                          break;
163                  case 'p':                               /* point */
164                          *table++ = oputp;
# Line 173 | Line 188 | FVECT  org, dir;
188          VCOPY(thisray.rorg, org);
189          VCOPY(thisray.rdir, dir);
190          rayorigin(&thisray, NULL, PRIMARY, 1.0);
191 <        rayvalue(&thisray);
191 >        if (castonly)
192 >                localhit(&thisray, &thescene) || sourcehit(&thisray);
193 >        else
194 >                rayvalue(&thisray);
195  
196          if (ray_out[0] == NULL)
197                  return;
# Line 187 | Line 205 | FVECT  org, dir;
205   irrad(org, dir)                 /* compute irradiance value */
206   FVECT  org, dir;
207   {
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        };
208          register int  i;
209  
210          for (i = 0; i < 3; i++) {
# Line 207 | Line 220 | FVECT  org, dir;
220                  thisray.rop[i] = org[i] + 1e-4*dir[i];
221                                          /* compute and print */
222          (*ofun[Lamb.otype].funp)(&Lamb, &thisray);
223 +        oputv(&thisray);
224 +        if (outform == 'a')
225 +                putchar('\n');
226 + }
227 +
228 +
229 + Irrad(org, dir)         /* compute irradiance value after intersection */
230 + FVECT  org, dir;
231 + {
232 +                                        /* compute intersection */
233 +        VCOPY(thisray.rorg, org);
234 +        VCOPY(thisray.rdir, dir);
235 +        rayorigin(&thisray, NULL, PRIMARY, 1.0);
236 +        localhit(&thisray, &thescene);
237 +        if (thisray.ro != NULL)         /* pretend we hit Lambertian surf. */
238 +                (*ofun[Lamb.otype].funp)(&Lamb, &thisray);
239          oputv(&thisray);
240          if (outform == 'a')
241                  putchar('\n');

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines