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.6 by greg, Fri Jul 10 14:56:24 1992 UTC vs.
Revision 2.15 by greg, Fri Jun 18 10:14:42 1993 UTC

# Line 42 | Line 42 | int  inform = 'a';                     /* input format */
42   int  outform = 'a';                     /* output format */
43   char  *outvals = "v";                   /* output specification */
44  
45 + char  *tralist[128];                    /* list of modifers to trace (or no) */
46 + int  traincl = -1;                      /* include == 1, exclude == 0 */
47 + #define  MAXTSET        511             /* maximum number in trace set */
48 + OBJECT  traset[MAXTSET+1]={0};          /* trace include/exclude set */
49 +
50   int  hresolu = 0;                       /* horizontal (scan) size */
51   int  vresolu = 0;                       /* vertical resolution */
52  
# Line 50 | Line 55 | double  shadthresh = .05;              /* shadow threshold */
55   double  shadcert = .5;                  /* shadow certainty */
56   int  directrelay = 1;                   /* number of source relays */
57   int  vspretest = 512;                   /* virtual source pretest density */
58 < int  directinvis = 0;                   /* sources invisible? */
58 > int  directvis = 1;                     /* sources visible? */
59   double  srcsizerat = .25;               /* maximum ratio source size/dist. */
60  
61   double  specthresh = .15;               /* specular sampling threshold */
# Line 73 | Line 78 | extern OBJREC  Lamb;                   /* a Lambertian surface */
78   static RAY  thisray;                    /* for our convenience */
79  
80   static int  oputo(), oputd(), oputv(), oputl(), oputL(),
81 <                oputp(), oputn(), oputs(), oputw(), oputm();
81 >                oputp(), oputn(), oputN(), oputs(), oputw(), oputm();
82  
83 < static int  (*ray_out[10])(), (*every_out[10])();
84 < static int  castonly;
83 > static int  ourtrace(), tabin();
84 > static int  (*ray_out[16])(), (*every_out[16])();
85 > static int  castonly = 0;
86  
87   static int  puta(), putf(), putd();
88  
# Line 86 | Line 92 | static int  (*putreal)();
92   quit(code)                      /* quit program */
93   int  code;
94   {
95 + #ifndef  NIX
96 +        headclean();            /* delete header file */
97 +        pfclean();              /* clean up persist files */
98 + #endif
99          exit(code);
100   }
101  
# Line 118 | Line 128 | char  *fname;
128                  sprintf(errmsg, "cannot open input file \"%s\"", fname);
129                  error(SYSTEM, errmsg);
130          }
131 + #ifdef MSDOS
132 +        if (inform != 'a')
133 +                setmode(fileno(fp), O_BINARY);
134 + #endif
135                                          /* set up output */
136 <        setoutput(outvals);
136 >        if (imm_irrad)
137 >                outvals = "v";
138 >        else
139 >                setoutput(outvals);
140          switch (outform) {
141          case 'a': putreal = puta; break;
142          case 'f': putreal = putf; break;
# Line 131 | Line 148 | char  *fname;
148          default:
149                  error(CONSISTENCY, "botched output format");
150          }
151 <        fputformat(formstr(outform), stdout);
152 <        putchar('\n');
153 <        if (hresolu > 0 && vresolu > 0)
154 <                fprtresolu(hresolu, vresolu, stdout);
151 >        if (hresolu > 0) {
152 >                if (vresolu > 0)
153 >                        fprtresolu(hresolu, vresolu, stdout);
154 >                fflush(stdout);
155 >        }
156                                          /* process file */
157          while (getvec(orig, inform, fp) == 0 &&
158                          getvec(direc, inform, fp) == 0) {
# Line 159 | Line 177 | char  *fname;
177                  if (--vcount == 0)                      /* check for end */
178                          break;
179          }
180 +        fflush(stdout);
181          if (vcount > 0)
182                  error(USER, "read error");
183 <        fclose(fp);
183 >        if (fname != NULL)
184 >                fclose(fp);
185   }
186  
187  
188   setoutput(vs)                           /* set up output tables */
189   register char  *vs;
190   {
191 <        extern int  ourtrace(), (*trace)();
191 >        extern int  (*trace)();
192          register int (**table)() = ray_out;
193  
194          castonly = 1;
# Line 200 | Line 220 | register char  *vs;
220                  case 'p':                               /* point */
221                          *table++ = oputp;
222                          break;
223 <                case 'n':                               /* normal */
223 >                case 'n':                               /* perturbed normal */
224                          *table++ = oputn;
225 +                        castonly = 0;
226                          break;
227 +                case 'N':                               /* unperturbed normal */
228 +                        *table++ = oputN;
229 +                        break;
230                  case 's':                               /* surface */
231                          *table++ = oputs;
232                          break;
# Line 300 | Line 324 | FILE  *fp;
324   }
325  
326  
327 + tranotify(obj)                  /* record new modifier */
328 + OBJECT  obj;
329 + {
330 +        static int  hitlimit = 0;
331 +        register OBJREC  *o = objptr(obj);
332 +        register char  **tralp;
333 +
334 +        if (hitlimit || !ismodifier(o->otype))
335 +                return;
336 +        for (tralp = tralist; *tralp != NULL; tralp++)
337 +                if (!strcmp(o->oname, *tralp)) {
338 +                        if (traset[0] >= MAXTSET) {
339 +                                error(WARNING, "too many modifiers in trace list");
340 +                                hitlimit++;
341 +                                return;         /* should this be fatal? */
342 +                        }
343 +                        insertelem(traset, obj);
344 +                        return;
345 +                }
346 + }
347 +
348 +
349   static
350   ourtrace(r)                             /* print ray values */
351   RAY  *r;
# Line 308 | Line 354 | RAY  *r;
354  
355          if (every_out[0] == NULL)
356                  return;
357 +        if (traincl == 1 && r->ro == NULL)
358 +                return;
359 +        if (traincl != -1 && traincl != inset(traset, r->ro->omod))
360 +                return;
361          tabin(r);
362          for (tp = every_out; *tp != NULL; tp++)
363                  (**tp)(r);
# Line 398 | Line 448 | register RAY  *r;
448  
449  
450   static
451 < oputn(r)                                /* print normal */
451 > oputN(r)                                /* print unperturbed normal */
452   register RAY  *r;
453   {
454          if (r->rot < FHUGE) {
# Line 410 | Line 460 | register RAY  *r;
460                  (*putreal)(0.0);
461                  (*putreal)(0.0);
462          }
463 + }
464 +
465 +
466 + static
467 + oputn(r)                                /* print perturbed normal */
468 + RAY  *r;
469 + {
470 +        FVECT  pnorm;
471 +
472 +        if (r->rot >= FHUGE) {
473 +                (*putreal)(0.0);
474 +                (*putreal)(0.0);
475 +                (*putreal)(0.0);
476 +                return;
477 +        }
478 +        raynormal(pnorm, r);
479 +        (*putreal)(pnorm[0]);
480 +        (*putreal)(pnorm[1]);
481 +        (*putreal)(pnorm[2]);
482   }
483  
484  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines