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.25 by gregl, Fri Oct 17 10:14:37 1997 UTC vs.
Revision 2.29 by greg, Fri Apr 18 17:29:22 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1997 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  rtrace.c - program and variables for individual ray tracing.
9 *
10 *     6/11/86
6   */
7  
8 + #include "copyright.h"
9 +
10   /*
11   *  Input is in the form:
12   *
# Line 26 | Line 23 | static char SCCSid[] = "$SunId$ SGI";
23  
24   #include  "ray.h"
25  
29 #include  "octree.h"
30
26   #include  "otypes.h"
27  
28   #include  "resolu.h"
29  
30 + CUBE  thescene;                         /* our scene */
31 + OBJECT  nsceneobjs;                     /* number of objects in our scene */
32 +
33   int  dimlist[MAXDIM];                   /* sampling dimensions */
34   int  ndims = 0;                         /* number of sampling dimensions */
35   int  samplendx = 0;                     /* index for this sample */
# Line 43 | Line 41 | int  inform = 'a';                     /* input format */
41   int  outform = 'a';                     /* output format */
42   char  *outvals = "v";                   /* output specification */
43  
44 + int  do_irrad = 0;                      /* compute irradiance? */
45 +
46 + void  (*trace)() = NULL;                /* trace call */
47 +
48 + extern void  ambnotify(), tranotify();
49 + void  (*addobjnotify[])() = {ambnotify, tranotify, NULL};
50   char  *tralist[128];                    /* list of modifers to trace (or no) */
51   int  traincl = -1;                      /* include == 1, exclude == 0 */
52   #define  MAXTSET        511             /* maximum number in trace set */
# Line 72 | Line 76 | int  backvis = 1;                      /* back face visibility */
76   int  maxdepth = 6;                      /* maximum recursion depth */
77   double  minweight = 4e-3;               /* minimum ray weight */
78  
79 + char  *ambfile = NULL;                  /* ambient file name */
80   COLOR  ambval = BLKCOLOR;               /* ambient value */
81   int  ambvwt = 0;                        /* initial weight for ambient value */
82   double  ambacc = 0.2;                   /* ambient accuracy */
# Line 82 | Line 87 | int  ambounce = 0;                     /* ambient bounces */
87   char  *amblist[128];                    /* ambient include/exclude list */
88   int  ambincl = -1;                      /* include == 1, exclude == 0 */
89  
85 extern OBJREC  Lamb;                    /* a Lambertian surface */
86 extern OBJREC  Aftplane;                /* aft clipping object */
90  
88
91   static RAY  thisray;                    /* for our convenience */
92  
93 < static int  oputo(), oputd(), oputv(), oputl(), oputL(),
93 > static void  oputo(), oputd(), oputv(), oputl(), oputL(), oputc(),
94                  oputp(), oputn(), oputN(), oputs(), oputw(), oputm();
95  
96 < static int  ourtrace(), tabin();
97 < static int  (*ray_out[16])(), (*every_out[16])();
96 > static void  ourtrace(), tabin();
97 > static void  (*ray_out[16])(), (*every_out[16])();
98   static int  castonly = 0;
99  
100 < static int  puta(), putf(), putd();
100 > static void  puta(), putf(), putd();
101  
102 < static int  (*putreal)();
102 > static void  (*putreal)();
103  
104 + void    bogusray(), rad(), irrad(), printvals();
105  
106 +
107 + void
108   quit(code)                      /* quit program */
109   int  code;
110   {
# Line 125 | Line 130 | int  f;
130   }
131  
132  
133 + void
134   rtrace(fname)                           /* trace rays from file */
135   char  *fname;
136   {
# Line 169 | Line 175 | char  *fname;
175                  d = normalize(direc);
176                  if (d == 0.0) {                         /* zero ==> flush */
177                          bogusray();
178 <                        if (--nextflush <= 0) {
178 >                        if (--nextflush <= 0 || vcount <= 0) {
179                                  fflush(stdout);
180                                  nextflush = hresolu;
181                          }
# Line 202 | Line 208 | char  *fname;
208   setoutput(vs)                           /* set up output tables */
209   register char  *vs;
210   {
211 <        extern int  (*trace)();
212 <        register int (**table)() = ray_out;
211 >        extern void  (*trace)();
212 >        register void (**table)() = ray_out;
213  
214          castonly = 1;
215          while (*vs)
# Line 228 | Line 234 | register char  *vs;
234                          *table++ = oputl;
235                          castonly = 0;
236                          break;
237 +                case 'c':                               /* local coordinates */
238 +                        *table++ = oputc;
239 +                        break;
240                  case 'L':                               /* single ray length */
241                          *table++ = oputL;
242                          break;
# Line 255 | Line 264 | register char  *vs;
264   }
265  
266  
267 + void
268   bogusray()                      /* print out empty record */
269   {
270          thisray.rorg[0] = thisray.rorg[1] = thisray.rorg[2] =
# Line 264 | Line 274 | bogusray()                     /* print out empty record */
274   }
275  
276  
277 + void
278   rad(org, dir, dmax)             /* compute and print ray value(s) */
279   FVECT  org, dir;
280   double  dmax;
# Line 285 | Line 296 | double dmax;
296   }
297  
298  
299 + void
300   irrad(org, dir)                 /* compute immediate irradiance value */
301   FVECT  org, dir;
302   {
# Line 307 | Line 319 | FVECT  org, dir;
319   }
320  
321  
322 + void
323   printvals(r)                    /* print requested ray values */
324   RAY  *r;
325   {
326 <        register int  (**tp)();
326 >        register void  (**tp)();
327  
328          if (ray_out[0] == NULL)
329                  return;
# Line 321 | Line 334 | RAY  *r;
334   }
335  
336  
337 + int
338   getvec(vec, fmt, fp)            /* get a vector from fp */
339   register FVECT  vec;
340   int  fmt;
341   FILE  *fp;
342   {
329        extern char  *fgetword();
343          static float  vf[3];
344          static double  vd[3];
345          char  buf[32];
# Line 358 | Line 371 | FILE  *fp;
371   }
372  
373  
374 + void
375   tranotify(obj)                  /* record new modifier */
376   OBJECT  obj;
377   {
# Line 365 | Line 379 | OBJECT obj;
379          register OBJREC  *o = objptr(obj);
380          register char  **tralp;
381  
382 +        if (obj == OVOID) {             /* starting over */
383 +                traset[0] = 0;
384 +                hitlimit = 0;
385 +                return;
386 +        }
387          if (hitlimit || !ismodifier(o->otype))
388                  return;
389          for (tralp = tralist; *tralp != NULL; tralp++)
# Line 380 | Line 399 | OBJECT obj;
399   }
400  
401  
402 < static
402 > static void
403   ourtrace(r)                             /* print ray values */
404   RAY  *r;
405   {
406 <        register int  (**tp)();
406 >        register void  (**tp)();
407  
408          if (every_out[0] == NULL)
409                  return;
# Line 400 | Line 419 | RAY  *r;
419   }
420  
421  
422 < static
422 > static void
423   tabin(r)                                /* tab in appropriate amount */
424   RAY  *r;
425   {
# Line 411 | Line 430 | RAY  *r;
430   }
431  
432  
433 < static
433 > static void
434   oputo(r)                                /* print origin */
435 < register RAY  *r;
435 > RAY  *r;
436   {
437          (*putreal)(r->rorg[0]);
438          (*putreal)(r->rorg[1]);
# Line 421 | Line 440 | register RAY  *r;
440   }
441  
442  
443 < static
443 > static void
444   oputd(r)                                /* print direction */
445 < register RAY  *r;
445 > RAY  *r;
446   {
447          (*putreal)(r->rdir[0]);
448          (*putreal)(r->rdir[1]);
# Line 431 | Line 450 | register RAY  *r;
450   }
451  
452  
453 < static
453 > static void
454   oputv(r)                                /* print value */
455 < register RAY  *r;
455 > RAY  *r;
456   {
457          COLR  cout;
458          
# Line 450 | Line 469 | register RAY  *r;
469   }
470  
471  
472 < static
472 > static void
473   oputl(r)                                /* print effective distance */
474 < register RAY  *r;
474 > RAY  *r;
475   {
476          (*putreal)(r->rt);
477   }
478  
479  
480 < static
480 > static void
481   oputL(r)                                /* print single ray length */
482 < register RAY  *r;
482 > RAY  *r;
483   {
484          (*putreal)(r->rot);
485   }
486  
487  
488 < static
488 > static void
489 > oputc(r)                                /* print local coordinates */
490 > RAY  *r;
491 > {
492 >        (*putreal)(r->uv[0]);
493 >        (*putreal)(r->uv[1]);
494 > }
495 >
496 >
497 > static void
498   oputp(r)                                /* print point */
499 < register RAY  *r;
499 > RAY  *r;
500   {
501          if (r->rot < FHUGE) {
502                  (*putreal)(r->rop[0]);
# Line 482 | Line 510 | register RAY  *r;
510   }
511  
512  
513 < static
513 > static void
514   oputN(r)                                /* print unperturbed normal */
515 < register RAY  *r;
515 > RAY  *r;
516   {
517          if (r->rot < FHUGE) {
518                  (*putreal)(r->ron[0]);
# Line 498 | Line 526 | register RAY  *r;
526   }
527  
528  
529 < static
529 > static void
530   oputn(r)                                /* print perturbed normal */
531   RAY  *r;
532   {
# Line 517 | Line 545 | RAY  *r;
545   }
546  
547  
548 < static
548 > static void
549   oputs(r)                                /* print name */
550 < register RAY  *r;
550 > RAY  *r;
551   {
552          if (r->ro != NULL)
553                  fputs(r->ro->oname, stdout);
# Line 529 | Line 557 | register RAY  *r;
557   }
558  
559  
560 < static
560 > static void
561   oputw(r)                                /* print weight */
562 < register RAY  *r;
562 > RAY  *r;
563   {
564          (*putreal)(r->rweight);
565   }
566  
567  
568 < static
568 > static void
569   oputm(r)                                /* print modifier */
570 < register RAY  *r;
570 > RAY  *r;
571   {
572          if (r->ro != NULL)
573                  if (r->ro->omod != OVOID)
# Line 552 | Line 580 | register RAY  *r;
580   }
581  
582  
583 < static
583 > static void
584   puta(v)                         /* print ascii value */
585   double  v;
586   {
# Line 560 | Line 588 | double  v;
588   }
589  
590  
591 < static
591 > static void
592   putd(v)                         /* print binary double */
593   double  v;
594   {
# Line 568 | Line 596 | double  v;
596   }
597  
598  
599 < static
599 > static void
600   putf(v)                         /* print binary float */
601   double  v;
602   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines