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 2.2 by greg, Thu Dec 19 14:54:53 1991 UTC vs.
Revision 2.12 by greg, Fri Jan 22 09:51:20 1993 UTC

# Line 1 | Line 1
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";
# Line 30 | Line 30 | 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 */
# Line 48 | Line 50 | double  shadthresh = .05;              /* shadow threshold */
50   double  shadcert = .5;                  /* shadow certainty */
51   int  directrelay = 1;                   /* number of source relays */
52   int  vspretest = 512;                   /* virtual source pretest density */
53 < int  directinvis = 0;                   /* sources invisible? */
53 > int  directvis = 1;                     /* sources visible? */
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  
# Line 67 | Line 72 | extern OBJREC  Lamb;                   /* a Lambertian surface */
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;
# Line 81 | Line 86 | static int  (*putreal)();
86   quit(code)                      /* quit program */
87   int  code;
88   {
89 + #ifndef  NIX
90 +        headclean();            /* delete header file */
91 +        pfclean();              /* clean up persist files */
92 + #endif
93          exit(code);
94   }
95  
96  
97 + char *
98 + formstr(f)                              /* return format identifier */
99 + int  f;
100 + {
101 +        switch (f) {
102 +        case 'a': return("ascii");
103 +        case 'f': return("float");
104 +        case 'd': return("double");
105 +        case 'c': return(COLRFMT);
106 +        }
107 +        return("unknown");
108 + }
109 +
110 +
111   rtrace(fname)                           /* trace rays from file */
112   char  *fname;
113   {
# Line 99 | Line 122 | char  *fname;
122                  sprintf(errmsg, "cannot open input file \"%s\"", fname);
123                  error(SYSTEM, errmsg);
124          }
125 + #ifdef MSDOS
126 +        if (inform != 'a')
127 +                setmode(fileno(fp), O_BINARY);
128 + #endif
129                                          /* set up output */
130          setoutput(outvals);
131          switch (outform) {
132          case 'a': putreal = puta; break;
133          case 'f': putreal = putf; break;
134          case 'd': putreal = putd; break;
135 +        case 'c':
136 +                if (strcmp(outvals, "v"))
137 +                        error(USER, "color format with value output only");
138 +                break;
139 +        default:
140 +                error(CONSISTENCY, "botched output format");
141          }
142 +        if (hresolu > 0) {
143 +                if (vresolu > 0)
144 +                        fprtresolu(hresolu, vresolu, stdout);
145 +                fflush(stdout);
146 +        }
147                                          /* process file */
148          while (getvec(orig, inform, fp) == 0 &&
149                          getvec(direc, inform, fp) == 0) {
# Line 130 | Line 168 | char  *fname;
168                  if (--vcount == 0)                      /* check for end */
169                          break;
170          }
171 +        fflush(stdout);
172          if (vcount > 0)
173                  error(USER, "read error");
174 <        fclose(fp);
174 >        if (fname != NULL)
175 >                fclose(fp);
176   }
177  
178  
# Line 161 | Line 201 | register char  *vs;
201                          *table++ = oputv;
202                          castonly = 0;
203                          break;
204 <                case 'l':                               /* length */
204 >                case 'l':                               /* effective distance */
205                          *table++ = oputl;
206                          castonly = 0;
207                          break;
208 +                case 'L':                               /* single ray length */
209 +                        *table++ = oputL;
210 +                        break;
211                  case 'p':                               /* point */
212                          *table++ = oputp;
213                          break;
214 <                case 'n':                               /* normal */
214 >                case 'n':                               /* perturbed normal */
215                          *table++ = oputn;
216 +                        castonly = 0;
217                          break;
218 +                case 'N':                               /* unperturbed normal */
219 +                        *table++ = oputN;
220 +                        break;
221                  case 's':                               /* surface */
222                          *table++ = oputs;
223                          break;
# Line 238 | Line 285 | FILE  *fp;
285   {
286          extern char  *fgetword();
287          static float  vf[3];
288 +        static double  vd[3];
289          char  buf[32];
290          register int  i;
291  
# Line 256 | Line 304 | FILE  *fp;
304                  vec[0] = vf[0]; vec[1] = vf[1]; vec[2] = vf[2];
305                  break;
306          case 'd':                                       /* binary double */
307 <                if (fread((char *)vec, sizeof(double), 3, fp) != 3)
307 >                if (fread((char *)vd, sizeof(double), 3, fp) != 3)
308                          return(-1);
309 +                vec[0] = vd[0]; vec[1] = vd[1]; vec[2] = vd[2];
310                  break;
311 +        default:
312 +                error(CONSISTENCY, "botched input format");
313          }
314          return(0);
315   }
# Line 314 | Line 365 | static
365   oputv(r)                                /* print value */
366   register RAY  *r;
367   {
368 +        COLR  cout;
369 +        
370 +        if (outform == 'c') {
371 +                setcolr(cout,   colval(r->rcol,RED),
372 +                                colval(r->rcol,GRN),
373 +                                colval(r->rcol,BLU));
374 +                fwrite((char *)cout, sizeof(cout), 1, stdout);
375 +                return;
376 +        }
377          (*putreal)(colval(r->rcol,RED));
378          (*putreal)(colval(r->rcol,GRN));
379          (*putreal)(colval(r->rcol,BLU));
# Line 321 | Line 381 | register RAY  *r;
381  
382  
383   static
384 < oputl(r)                                /* print length */
384 > oputl(r)                                /* print effective distance */
385   register RAY  *r;
386   {
387          (*putreal)(r->rt);
# Line 329 | Line 389 | register RAY  *r;
389  
390  
391   static
392 + oputL(r)                                /* print single ray length */
393 + register RAY  *r;
394 + {
395 +        (*putreal)(r->rot);
396 + }
397 +
398 +
399 + static
400   oputp(r)                                /* print point */
401   register RAY  *r;
402   {
# Line 345 | Line 413 | register RAY  *r;
413  
414  
415   static
416 < oputn(r)                                /* print normal */
416 > oputN(r)                                /* print unperturbed normal */
417   register RAY  *r;
418   {
419          if (r->rot < FHUGE) {
# Line 357 | Line 425 | register RAY  *r;
425                  (*putreal)(0.0);
426                  (*putreal)(0.0);
427          }
428 + }
429 +
430 +
431 + static
432 + oputn(r)                                /* print perturbed normal */
433 + RAY  *r;
434 + {
435 +        FVECT  pnorm;
436 +
437 +        if (r->rot >= FHUGE) {
438 +                (*putreal)(0.0);
439 +                (*putreal)(0.0);
440 +                (*putreal)(0.0);
441 +                return;
442 +        }
443 +        raynormal(pnorm, r);
444 +        (*putreal)(pnorm[0]);
445 +        (*putreal)(pnorm[1]);
446 +        (*putreal)(pnorm[2]);
447   }
448  
449  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines