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.1 by greg, Tue Nov 12 17:09:39 1991 UTC vs.
Revision 2.14 by greg, Tue May 4 13:26:52 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;
78 > static int  ourtrace(), tabin();
79 > static int  (*ray_out[16])(), (*every_out[16])();
80 > static int  castonly = 0;
81  
82   static int  puta(), putf(), putd();
83  
# Line 81 | Line 87 | static int  (*putreal)();
87   quit(code)                      /* quit program */
88   int  code;
89   {
90 + #ifndef  NIX
91 +        headclean();            /* delete header file */
92 +        pfclean();              /* clean up persist files */
93 + #endif
94          exit(code);
95   }
96  
97  
98 + char *
99 + formstr(f)                              /* return format identifier */
100 + int  f;
101 + {
102 +        switch (f) {
103 +        case 'a': return("ascii");
104 +        case 'f': return("float");
105 +        case 'd': return("double");
106 +        case 'c': return(COLRFMT);
107 +        }
108 +        return("unknown");
109 + }
110 +
111 +
112   rtrace(fname)                           /* trace rays from file */
113   char  *fname;
114   {
# Line 99 | Line 123 | char  *fname;
123                  sprintf(errmsg, "cannot open input file \"%s\"", fname);
124                  error(SYSTEM, errmsg);
125          }
126 + #ifdef MSDOS
127 +        if (inform != 'a')
128 +                setmode(fileno(fp), O_BINARY);
129 + #endif
130                                          /* set up output */
131 <        setoutput(outvals);
131 >        if (imm_irrad)
132 >                outvals = "v";
133 >        else
134 >                setoutput(outvals);
135          switch (outform) {
136          case 'a': putreal = puta; break;
137          case 'f': putreal = putf; break;
138          case 'd': putreal = putd; break;
139 +        case 'c':
140 +                if (strcmp(outvals, "v"))
141 +                        error(USER, "color format with value output only");
142 +                break;
143 +        default:
144 +                error(CONSISTENCY, "botched output format");
145          }
146 +        if (hresolu > 0) {
147 +                if (vresolu > 0)
148 +                        fprtresolu(hresolu, vresolu, stdout);
149 +                fflush(stdout);
150 +        }
151                                          /* process file */
152          while (getvec(orig, inform, fp) == 0 &&
153                          getvec(direc, inform, fp) == 0) {
# Line 130 | Line 172 | char  *fname;
172                  if (--vcount == 0)                      /* check for end */
173                          break;
174          }
175 +        fflush(stdout);
176          if (vcount > 0)
177                  error(USER, "read error");
178 <        fclose(fp);
178 >        if (fname != NULL)
179 >                fclose(fp);
180   }
181  
182  
183   setoutput(vs)                           /* set up output tables */
184   register char  *vs;
185   {
186 <        extern int  ourtrace(), (*trace)();
186 >        extern int  (*trace)();
187          register int (**table)() = ray_out;
188  
189          castonly = 1;
# Line 161 | Line 205 | register char  *vs;
205                          *table++ = oputv;
206                          castonly = 0;
207                          break;
208 <                case 'l':                               /* length */
208 >                case 'l':                               /* effective distance */
209                          *table++ = oputl;
210                          castonly = 0;
211                          break;
212 +                case 'L':                               /* single ray length */
213 +                        *table++ = oputL;
214 +                        break;
215                  case 'p':                               /* point */
216                          *table++ = oputp;
217                          break;
218 <                case 'n':                               /* normal */
218 >                case 'n':                               /* perturbed normal */
219                          *table++ = oputn;
220 +                        castonly = 0;
221                          break;
222 +                case 'N':                               /* unperturbed normal */
223 +                        *table++ = oputN;
224 +                        break;
225                  case 's':                               /* surface */
226                          *table++ = oputs;
227                          break;
# Line 237 | Line 288 | int  fmt;
288   FILE  *fp;
289   {
290          extern char  *fgetword();
240        extern double  atof();
291          static float  vf[3];
292 +        static double  vd[3];
293          char  buf[32];
294          register int  i;
295  
# Line 257 | Line 308 | FILE  *fp;
308                  vec[0] = vf[0]; vec[1] = vf[1]; vec[2] = vf[2];
309                  break;
310          case 'd':                                       /* binary double */
311 <                if (fread((char *)vec, sizeof(double), 3, fp) != 3)
311 >                if (fread((char *)vd, sizeof(double), 3, fp) != 3)
312                          return(-1);
313 +                vec[0] = vd[0]; vec[1] = vd[1]; vec[2] = vd[2];
314                  break;
315 +        default:
316 +                error(CONSISTENCY, "botched input format");
317          }
318          return(0);
319   }
# Line 315 | Line 369 | static
369   oputv(r)                                /* print value */
370   register RAY  *r;
371   {
372 +        COLR  cout;
373 +        
374 +        if (outform == 'c') {
375 +                setcolr(cout,   colval(r->rcol,RED),
376 +                                colval(r->rcol,GRN),
377 +                                colval(r->rcol,BLU));
378 +                fwrite((char *)cout, sizeof(cout), 1, stdout);
379 +                return;
380 +        }
381          (*putreal)(colval(r->rcol,RED));
382          (*putreal)(colval(r->rcol,GRN));
383          (*putreal)(colval(r->rcol,BLU));
# Line 322 | Line 385 | register RAY  *r;
385  
386  
387   static
388 < oputl(r)                                /* print length */
388 > oputl(r)                                /* print effective distance */
389   register RAY  *r;
390   {
391          (*putreal)(r->rt);
# Line 330 | Line 393 | register RAY  *r;
393  
394  
395   static
396 + oputL(r)                                /* print single ray length */
397 + register RAY  *r;
398 + {
399 +        (*putreal)(r->rot);
400 + }
401 +
402 +
403 + static
404   oputp(r)                                /* print point */
405   register RAY  *r;
406   {
# Line 346 | Line 417 | register RAY  *r;
417  
418  
419   static
420 < oputn(r)                                /* print normal */
420 > oputN(r)                                /* print unperturbed normal */
421   register RAY  *r;
422   {
423          if (r->rot < FHUGE) {
# Line 358 | Line 429 | register RAY  *r;
429                  (*putreal)(0.0);
430                  (*putreal)(0.0);
431          }
432 + }
433 +
434 +
435 + static
436 + oputn(r)                                /* print perturbed normal */
437 + RAY  *r;
438 + {
439 +        FVECT  pnorm;
440 +
441 +        if (r->rot >= FHUGE) {
442 +                (*putreal)(0.0);
443 +                (*putreal)(0.0);
444 +                (*putreal)(0.0);
445 +                return;
446 +        }
447 +        raynormal(pnorm, r);
448 +        (*putreal)(pnorm[0]);
449 +        (*putreal)(pnorm[1]);
450 +        (*putreal)(pnorm[2]);
451   }
452  
453  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines