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.4 by greg, Thu Jun 8 09:35:41 1989 UTC vs.
Revision 2.12 by greg, Wed Dec 31 01:50:02 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  
10 + #include <string.h>
11 +
12 + #ifdef __cplusplus
13 + extern "C" {
14 + #endif
15 +
16 + #ifndef  AIMREQT
17 + #define  AIMREQT        100             /* required aim success/failure */
18 + #endif
19 + #ifndef  SHADCACHE
20 + #define  SHADCACHE      20              /* shadow cache resolution */
21 + #endif
22 +
23   #define  SDISTANT       01              /* source distant flag */
24   #define  SSKIP          02              /* source skip flag */
25   #define  SPROX          04              /* source proximity flag */
26   #define  SSPOT          010             /* source spotlight flag */
27 + #define  SVIRTUAL       020             /* source virtual flag */
28 + #define  SFLAT          040             /* source flat flag */
29 + #define  SCYL           0100            /* source cylindrical flag */
30 + #define  SFOLLOW        0200            /* source follow path flag */
31  
32   typedef struct {
33 <        float  siz;             /* output solid angle */
34 <        float  flen;            /* focal length */
35 <        FVECT  aim;             /* aim direction */
33 >        FVECT  aim;             /* aim direction or center */
34 >        float  siz;             /* output solid angle or area */
35 >        float  flen;            /* focal length (negative if distant source) */
36   } SPOT;                 /* spotlight */
37  
38   typedef struct {
23        short  sflags;          /* source flags */
24        FVECT  sloc;            /* direction or position of source */
25        float  ss;              /* tangent or disk radius */
26        float  ss2;             /* domega or projected area */
39          union {
40 +                struct {
41 +                        FVECT   u, v;           /* unit vectors */
42 +                }  f;                   /* flat source indexing */
43 +                struct {
44 +                        FVECT   o;              /* origin position */
45 +                        RREAL   e1, e2;         /* 1/extent */
46 +                        int     ax;             /* major direction */
47 +                }  d;                   /* distant source indexing */
48 +        }  p;                   /* indexing parameters */
49 +        OBJECT  obs[1];         /* cache obstructors (extends struct) */
50 + }  OBSCACHE;            /* obstructor cache */
51 +
52 + typedef struct {
53 +        int  sflags;            /* source flags */
54 +        FVECT  sloc;            /* direction or position of source */
55 +        FVECT  ss[3];           /* source dimension vectors, U, V, and W */
56 +        float  srad;            /* maximum source radius */
57 +        float  ss2;             /* solid angle or projected area */
58 +        OBJREC  *so;            /* source destination object */
59 +        struct {
60                  float  prox;            /* proximity */
61                  SPOT  *s;               /* spot */
62          } sl;                   /* localized source information */
63 <        long  ntests, nhits;    /* shadow tests and hits */
64 <        OBJREC  *so;            /* source object */
63 >        union {
64 >                long  success;          /* successes - AIMREQT*failures */
65 >                struct {
66 >                        short  pn;              /* projection number */
67 >                        int  sn;                /* next source to aim for */
68 >                }  sv;                  /* virtual source */
69 >        } sa;                   /* source aiming information */
70 >        unsigned long
71 >                ntests, nhits;  /* shadow tests and hits */
72 > #ifdef  SHADCACHE
73 >        OBSCACHE  *obscache;    /* obstructor cache */
74 > #endif
75   }  SRCREC;              /* light source */
76  
77 + #define MAXSPART        64              /* maximum partitions per source */
78 +
79 + #define SU              0               /* U vector or partition */
80 + #define SV              1               /* V vector or partition */
81 + #define SW              2               /* W vector or partition */
82 + #define S0              3               /* leaf partition */
83 +
84 + #define snorm           ss[SW]          /* normal vector for flat source */
85 +
86   typedef struct {
87 <        FVECT  dir;             /* source direction */
88 <        float  dom;             /* domega for source */
89 <        COLOR  val;             /* contribution */
90 < }  CONTRIB;             /* direct contribution */
87 >        int  sn;                                /* source number */
88 >        short  np;                              /* number of partitions */
89 >        short  sp;                              /* this partition number */
90 >        double  dom;                            /* solid angle of partition */
91 >        unsigned char  spt[MAXSPART/2];         /* source partitioning */
92 > }  SRCINDEX;            /* source index structure */
93  
94 + #define initsrcindex(s) ((s)->sn = (s)->sp = -1, (s)->np = 0)
95 +
96 + #define clrpart(pt)     memset((char *)(pt), '\0', MAXSPART/2)
97 + #define setpart(pt,i,v) ((pt)[(i)>>2] |= (v)<<(((i)&3)<<1))
98 + #define spart(pt,pi)    ((pt)[(pi)>>2] >> (((pi)&3)<<1) & 3)
99 +
100 + /*
101 + * Special support functions for sources
102 + */
103 +
104 + /*
105 + * Virtual source materials must define the following.
106 + *
107 + *      vproj(pm, op, sp, i)    Compute i'th virtual projection
108 + *                              of source sp in object op and assign
109 + *                              the 4x4 transformation matrix pm.
110 + *                              Return 1 on success, 0 if no i'th projection.
111 + *
112 + *      nproj                   The number of projections.  The value of
113 + *                              i passed to vproj runs from 0 to nproj-1.
114 + */
115 +
116   typedef struct {
117 <        int  sno;               /* source number */
118 <        float  brt;             /* brightness (for comparison) */
119 < }  CNTPTR;              /* contribution pointer */
117 >        int  (*vproj)();        /* project virtual sources */
118 >        int  nproj;             /* number of possible projections */
119 > } VSMATERIAL;           /* virtual source material functions */
120  
121 + typedef struct {
122 +        void    (*setsrc)();    /* set light source for object */
123 +        void    (*partit)();    /* partition light source object */
124 +        double  (*getpleq)();   /* plane equation for surface */
125 +        double  (*getdisk)();   /* maximum disk for surface */
126 + } SOBJECT;              /* source object functions */
127 +
128 + typedef union {
129 +        VSMATERIAL  *mf;        /* material functions */
130 +        SOBJECT  *of;           /* object functions */
131 + } SRCFUNC;              /* source functions */
132 +
133 + extern SRCFUNC  sfun[];                 /* source dispatch table */
134 +
135   extern SRCREC  *source;                 /* our source list */
136   extern int  nsources;                   /* the number of sources */
137  
138 < extern double  srcray();                /* ray to source */
138 > #define  sflatform(sn,dir)      -DOT(source[sn].snorm, dir)
139  
140 < extern SPOT  *makespot();               /* make spotlight */
140 > #define  getplaneq(c,o)         (*sfun[(o)->otype].of->getpleq)(c,o)
141 > #define  getmaxdisk(c,o)        (*sfun[(o)->otype].of->getdisk)(c,o)
142 > #define  setsource(s,o)         (*sfun[(o)->otype].of->setsrc)(s,o)
143 >
144 >                                        /* defined in source.c */
145 > extern OBJREC   *findmaterial(OBJREC *o);
146 > extern void     marksources(void);
147 > extern void     freesources(void);
148 > extern int      srcray(RAY *sr, RAY *r, SRCINDEX *si);
149 > extern void     srcvalue(RAY *r);
150 > extern int      sourcehit(RAY *r);
151 > extern void     direct(RAY *r, void (*f)(), char *p);
152 > extern void     srcscatter(RAY *r);
153 > extern int      m_light(OBJREC *m, RAY *r);
154 > extern void     srcblocker(RAY *r);
155 > extern int      srcblocked(RAY *r);
156 > extern void     freeobscache(SRCREC *s);
157 >                                        /* defined in srcsamp.c */
158 > extern double   nextssamp(RAY *r, SRCINDEX *si);
159 > extern int      skipparts(int ct[3], int sz[3], int pp[2], unsigned char *pt);
160 > extern void     nopart(SRCINDEX *si, RAY *r);
161 > extern void     cylpart(SRCINDEX *si, RAY *r);
162 > extern void     flatpart(SRCINDEX *si, RAY *r);
163 > extern double   scylform(int sn, FVECT dir);
164 >                                        /* defined in srcsupp.c */
165 > extern void     initstypes(void);
166 > extern int      newsource(void);
167 > extern void     setflatss(SRCREC *src);
168 > extern void     fsetsrc(SRCREC *src, OBJREC *so);
169 > extern void     ssetsrc(SRCREC *src, OBJREC *so);
170 > extern void     sphsetsrc(SRCREC *src, OBJREC *so);
171 > extern void     rsetsrc(SRCREC *src, OBJREC *so);
172 > extern void     cylsetsrc(SRCREC *src, OBJREC *so);
173 > extern SPOT     *makespot(OBJREC *m);
174 > extern int      spotout(RAY *r, SPOT *s);
175 > extern double   fgetmaxdisk(FVECT ocent, OBJREC *op);
176 > extern double   rgetmaxdisk(FVECT ocent, OBJREC *op);
177 > extern double   fgetplaneq(FVECT nvec, OBJREC *op);
178 > extern double   rgetplaneq(FVECT nvec, OBJREC *op);
179 > extern int      commonspot(SPOT *sp1, SPOT *sp2, FVECT org);
180 > extern int      commonbeam(SPOT *sp1, SPOT *sp2, FVECT org);
181 > extern int      checkspot(SPOT *sp, FVECT nrm);
182 > extern double   spotdisk(FVECT oc, OBJREC *op, SPOT *sp, FVECT pos);
183 > extern double   beamdisk(FVECT oc, OBJREC *op, SPOT *sp, FVECT dir);
184 > extern double   intercircle(FVECT cc, FVECT c1, FVECT c2,
185 >                        double r1s, double r2s);
186 >                                        /* defined in virtuals.c */
187 > extern void     markvirtuals(void);
188 > extern void     addvirtuals(int sn, int nr);
189 > extern void     vproject(OBJREC *o, int sn, int n);
190 > extern OBJREC   *vsmaterial(OBJREC *o);
191 > extern int      makevsrc(OBJREC *op, int sn, MAT4 pm);
192 > extern double   getdisk(FVECT oc, OBJREC *op, int sn);
193 > extern int      vstestvis(int f, OBJREC *o, FVECT oc, double or2, int sn);
194 > extern void     virtverb(int sn, FILE *fp);
195 >
196 >
197 > #ifdef __cplusplus
198 > }
199 > #endif
200 > #endif /* _RAD_SOURCE_H_ */
201 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines