ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/source.h
(Generate patch)

Comparing ray/src/rt/source.h (file contents):
Revision 1.9 by greg, Thu Jun 20 16:36:44 1991 UTC vs.
Revision 2.9 by greg, Fri Jun 27 06:53:23 2003 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
2 <
3 < /* SCCSid "$SunId$ LBL" */
4 <
1 > /* RCSid $Id$ */
2   /*
3   *  source.h - header file for ray tracing sources.
4   *
5 < *     8/20/85
5 > *  Include after ray.h
6   */
7 + #ifndef _RAD_SOURCE_H_
8 + #define _RAD_SOURCE_H_
9 + #ifdef __cplusplus
10 + extern "C" {
11 + #endif
12  
13   #define  AIMREQT        100             /* required aim success/failure */
14  
# Line 16 | Line 18
18   #define  SSPOT          010             /* source spotlight flag */
19   #define  SVIRTUAL       020             /* source virtual flag */
20   #define  SFLAT          040             /* source flat flag */
21 < #define  SFOLLOW        0100            /* source follow path flag */
21 > #define  SCYL           0100            /* source cylindrical flag */
22 > #define  SFOLLOW        0200            /* source follow path flag */
23  
24   typedef struct {
25          FVECT  aim;             /* aim direction or center */
26          float  siz;             /* output solid angle or area */
27 <        float  flen;            /* focal length */
27 >        float  flen;            /* focal length (negative if distant source) */
28   } SPOT;                 /* spotlight */
29  
30   typedef struct {
31          int  sflags;            /* source flags */
32          FVECT  sloc;            /* direction or position of source */
33 <        FVECT  snorm;           /* surface normal of flat source */
34 <        float  ss;              /* tangent or disk radius */
35 <        float  ss2;             /* domega or projected area */
33 >        FVECT  ss[3];           /* source dimension vectors, U, V, and W */
34 >        float  srad;            /* maximum source radius */
35 >        float  ss2;             /* solid angle or projected area */
36          struct {
37                  float  prox;            /* proximity */
38                  SPOT  *s;               /* spot */
39          } sl;                   /* localized source information */
40          union {
41 <                int  success;           /* successes - AIMREQT*failures */
42 <                int  svnext;            /* next source to aim for */
41 >                long  success;          /* successes - AIMREQT*failures */
42 >                struct {
43 >                        short  pn;              /* projection number */
44 >                        int  sn;                /* next source to aim for */
45 >                }  sv;                  /* virtual source */
46          } sa;                   /* source aiming information */
47 <        long  ntests, nhits;    /* shadow tests and hits */
47 >        unsigned long
48 >                ntests, nhits;  /* shadow tests and hits */
49          OBJREC  *so;            /* source destination object */
50   }  SRCREC;              /* light source */
51  
52 + #define MAXSPART        64              /* maximum partitions per source */
53 +
54 + #define SU              0               /* U vector or partition */
55 + #define SV              1               /* V vector or partition */
56 + #define SW              2               /* W vector or partition */
57 + #define S0              3               /* leaf partition */
58 +
59 + #define snorm           ss[SW]          /* normal vector for flat source */
60 +
61 + typedef struct {
62 +        int  sn;                                /* source number */
63 +        short  np;                              /* number of partitions */
64 +        short  sp;                              /* this partition number */
65 +        double  dom;                            /* solid angle of partition */
66 +        unsigned char  spt[MAXSPART/2];         /* source partitioning */
67 + }  SRCINDEX;            /* source index structure */
68 +
69 + #define initsrcindex(s) ((s)->sn = (s)->sp = -1, (s)->np = 0)
70 +
71 + #define clrpart(pt)     bzero((char *)(pt), MAXSPART/2)
72 + #define setpart(pt,i,v) ((pt)[(i)>>2] |= (v)<<(((i)&3)<<1))
73 + #define spart(pt,pi)    ((pt)[(pi)>>2] >> (((pi)&3)<<1) & 3)
74 +
75   /*
76   * Special support functions for sources
77   */
78  
79   /*
80 < * Virtual source materials must support the following functions:
80 > * Virtual source materials must define the following.
81   *
82   *      vproj(pm, op, sp, i)    Compute i'th virtual projection
83   *                              of source sp in object op and assign
# Line 64 | Line 94 | typedef struct {
94   } VSMATERIAL;           /* virtual source material functions */
95  
96   typedef struct {
97 <        int     (*setsrc)();    /* set light source for object */
97 >        void    (*setsrc)();    /* set light source for object */
98 >        void    (*partit)();    /* partition light source object */
99          double  (*getpleq)();   /* plane equation for surface */
100          double  (*getdisk)();   /* maximum disk for surface */
101   } SOBJECT;              /* source object functions */
# Line 79 | Line 110 | extern SRCFUNC  sfun[];                        /* source dispatch table */
110   extern SRCREC  *source;                 /* our source list */
111   extern int  nsources;                   /* the number of sources */
112  
113 < extern double  srcray();                /* ray to source */
113 > #define  sflatform(sn,dir)      -DOT(source[sn].snorm, dir)
114  
115 < extern SPOT  *makespot();               /* make spotlight */
115 > #define  getplaneq(c,o)         (*sfun[(o)->otype].of->getpleq)(c,o)
116 > #define  getmaxdisk(c,o)        (*sfun[(o)->otype].of->getdisk)(c,o)
117 > #define  setsource(s,o)         (*sfun[(o)->otype].of->setsrc)(s,o)
118  
119 < extern double  dstrsrc;                 /* source distribution amount */
120 < extern double  shadthresh;              /* relative shadow threshold */
121 < extern double  shadcert;                /* shadow testing certainty */
122 < extern int  directrelay;                /* maximum number of source relays */
119 >                                        /* defined in source.c */
120 > extern void     marksources(void);
121 > extern void     freesources(void);
122 > extern int      srcray(RAY *sr, RAY *r, SRCINDEX *si);
123 > extern void     srcvalue(RAY *r);
124 > extern int      sourcehit(RAY *r);
125 > extern void     direct(RAY *r, void (*f)(), char *p);
126 > extern void     srcscatter(RAY *r);
127 > extern int      m_light(OBJREC *m, RAY *r);
128 >                                        /* defined in srcsamp.c */
129 > extern double   nextssamp(RAY *r, SRCINDEX *si);
130 > extern int      skipparts(int ct[3], int sz[3], int pp[2], unsigned char *pt);
131 > extern void     nopart(SRCINDEX *si, RAY *r);
132 > extern void     cylpart(SRCINDEX *si, RAY *r);
133 > extern void     flatpart(SRCINDEX *si, RAY *r);
134 > extern double   scylform(int sn, FVECT dir);
135 >                                        /* defined in srcsupp.c */
136 > extern void     initstypes(void);
137 > extern int      newsource(void);
138 > extern void     setflatss(SRCREC *src);
139 > extern void     fsetsrc(SRCREC *src, OBJREC *so);
140 > extern void     ssetsrc(SRCREC *src, OBJREC *so);
141 > extern void     sphsetsrc(SRCREC *src, OBJREC *so);
142 > extern void     rsetsrc(SRCREC *src, OBJREC *so);
143 > extern void     cylsetsrc(SRCREC *src, OBJREC *so);
144 > extern SPOT     *makespot(OBJREC *m);
145 > extern int      spotout(RAY *r, SPOT *s);
146 > extern double   fgetmaxdisk(FVECT ocent, OBJREC *op);
147 > extern double   rgetmaxdisk(FVECT ocent, OBJREC *op);
148 > extern double   fgetplaneq(FVECT nvec, OBJREC *op);
149 > extern double   rgetplaneq(FVECT nvec, OBJREC *op);
150 > extern int      commonspot(SPOT *sp1, SPOT *sp2, FVECT org);
151 > extern int      commonbeam(SPOT *sp1, SPOT *sp2, FVECT org);
152 > extern int      checkspot(SPOT *sp, FVECT nrm);
153 > extern double   spotdisk(FVECT oc, OBJREC *op, SPOT *sp, FVECT pos);
154 > extern double   beamdisk(FVECT oc, OBJREC *op, SPOT *sp, FVECT dir);
155 > extern double   intercircle(FVECT cc, FVECT c1, FVECT c2,
156 >                        double r1s, double r2s);
157 >                                        /* defined in virtuals.c */
158 > extern void     markvirtuals(void);
159 > extern void     addvirtuals(int sn, int nr);
160 > extern void     vproject(OBJREC *o, int sn, int n);
161 > extern OBJREC   *vsmaterial(OBJREC *o);
162 > extern int      makevsrc(OBJREC *op, int sn, MAT4 pm);
163 > extern double   getdisk(FVECT oc, OBJREC *op, int sn);
164 > extern int      vstestvis(int f, OBJREC *o, FVECT oc, double or2, int sn);
165 > extern void     virtverb(int sn, FILE *fp);
166 >
167 >
168 > #ifdef __cplusplus
169 > }
170 > #endif
171 > #endif /* _RAD_SOURCE_H_ */
172 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines