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.7 by greg, Tue Jul 21 10:36:37 1992 UTC vs.
Revision 2.16 by greg, Wed Jul 14 10:38:49 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);
137          switch (outform) {
# Line 131 | Line 145 | char  *fname;
145          default:
146                  error(CONSISTENCY, "botched output format");
147          }
148 <        if (hresolu > 0 && vresolu > 0)
149 <                fprtresolu(hresolu, vresolu, stdout);
148 >        if (hresolu > 0) {
149 >                if (vresolu > 0)
150 >                        fprtresolu(hresolu, vresolu, stdout);
151 >                fflush(stdout);
152 >        }
153                                          /* process file */
154          while (getvec(orig, inform, fp) == 0 &&
155                          getvec(direc, inform, fp) == 0) {
# Line 146 | Line 163 | char  *fname;
163                  if (imm_irrad)
164                          irrad(orig, direc);
165                  else
166 <                        traceray(orig, direc);
166 >                        rad(orig, direc);
167                                                          /* flush if time */
168                  if (--nextflush == 0) {
169                          fflush(stdout);
# Line 157 | Line 174 | char  *fname;
174                  if (--vcount == 0)                      /* check for end */
175                          break;
176          }
177 +        fflush(stdout);
178          if (vcount > 0)
179                  error(USER, "read error");
180 <        fclose(fp);
180 >        if (fname != NULL)
181 >                fclose(fp);
182   }
183  
184  
185   setoutput(vs)                           /* set up output tables */
186   register char  *vs;
187   {
188 <        extern int  ourtrace(), (*trace)();
188 >        extern int  (*trace)();
189          register int (**table)() = ray_out;
190  
191          castonly = 1;
# Line 198 | Line 217 | register char  *vs;
217                  case 'p':                               /* point */
218                          *table++ = oputp;
219                          break;
220 <                case 'n':                               /* normal */
220 >                case 'n':                               /* perturbed normal */
221                          *table++ = oputn;
222 +                        castonly = 0;
223                          break;
224 +                case 'N':                               /* unperturbed normal */
225 +                        *table++ = oputN;
226 +                        break;
227                  case 's':                               /* surface */
228                          *table++ = oputs;
229                          break;
# Line 215 | Line 238 | register char  *vs;
238   }
239  
240  
241 < traceray(org, dir)              /* compute and print ray value(s) */
241 > rad(org, dir)                   /* compute and print ray value(s) */
242   FVECT  org, dir;
243   {
221        register int  (**tp)();
222
244          VCOPY(thisray.rorg, org);
245          VCOPY(thisray.rdir, dir);
246          rayorigin(&thisray, NULL, PRIMARY, 1.0);
# Line 227 | Line 248 | FVECT  org, dir;
248                  localhit(&thisray, &thescene) || sourcehit(&thisray);
249          else
250                  rayvalue(&thisray);
251 <
231 <        if (ray_out[0] == NULL)
232 <                return;
233 <        for (tp = ray_out; *tp != NULL; tp++)
234 <                (**tp)(&thisray);
235 <        if (outform == 'a')
236 <                putchar('\n');
251 >        printvals(&thisray);
252   }
253  
254  
# Line 248 | Line 263 | FVECT  org, dir;
263          }
264          rayorigin(&thisray, NULL, PRIMARY, 1.0);
265                                          /* pretend we hit surface */
266 <        thisray.rot = 1.0;
266 >        thisray.rot = 1.0-1e-4;
267          thisray.rod = 1.0;
268          VCOPY(thisray.ron, dir);
269          for (i = 0; i < 3; i++)         /* fudge factor */
270                  thisray.rop[i] = org[i] + 1e-4*dir[i];
271                                          /* compute and print */
272          (*ofun[Lamb.otype].funp)(&Lamb, &thisray);
273 <        oputv(&thisray);
273 >        printvals(&thisray);
274 > }
275 >
276 >
277 > printvals(r)                    /* print requested ray values */
278 > RAY  *r;
279 > {
280 >        register int  (**tp)();
281 >
282 >        if (ray_out[0] == NULL)
283 >                return;
284 >        for (tp = ray_out; *tp != NULL; tp++)
285 >                (**tp)(r);
286          if (outform == 'a')
287                  putchar('\n');
288   }
# Line 298 | Line 325 | FILE  *fp;
325   }
326  
327  
328 + tranotify(obj)                  /* record new modifier */
329 + OBJECT  obj;
330 + {
331 +        static int  hitlimit = 0;
332 +        register OBJREC  *o = objptr(obj);
333 +        register char  **tralp;
334 +
335 +        if (hitlimit || !ismodifier(o->otype))
336 +                return;
337 +        for (tralp = tralist; *tralp != NULL; tralp++)
338 +                if (!strcmp(o->oname, *tralp)) {
339 +                        if (traset[0] >= MAXTSET) {
340 +                                error(WARNING, "too many modifiers in trace list");
341 +                                hitlimit++;
342 +                                return;         /* should this be fatal? */
343 +                        }
344 +                        insertelem(traset, obj);
345 +                        return;
346 +                }
347 + }
348 +
349 +
350   static
351   ourtrace(r)                             /* print ray values */
352   RAY  *r;
# Line 306 | Line 355 | RAY  *r;
355  
356          if (every_out[0] == NULL)
357                  return;
358 +        if (r->ro == NULL) {
359 +                if (traincl == 1)
360 +                        return;
361 +        } else if (traincl != -1 && traincl != inset(traset, r->ro->omod))
362 +                return;
363          tabin(r);
364          for (tp = every_out; *tp != NULL; tp++)
365                  (**tp)(r);
# Line 396 | Line 450 | register RAY  *r;
450  
451  
452   static
453 < oputn(r)                                /* print normal */
453 > oputN(r)                                /* print unperturbed normal */
454   register RAY  *r;
455   {
456          if (r->rot < FHUGE) {
# Line 408 | Line 462 | register RAY  *r;
462                  (*putreal)(0.0);
463                  (*putreal)(0.0);
464          }
465 + }
466 +
467 +
468 + static
469 + oputn(r)                                /* print perturbed normal */
470 + RAY  *r;
471 + {
472 +        FVECT  pnorm;
473 +
474 +        if (r->rot >= FHUGE) {
475 +                (*putreal)(0.0);
476 +                (*putreal)(0.0);
477 +                (*putreal)(0.0);
478 +                return;
479 +        }
480 +        raynormal(pnorm, r);
481 +        (*putreal)(pnorm[0]);
482 +        (*putreal)(pnorm[1]);
483 +        (*putreal)(pnorm[2]);
484   }
485  
486  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines