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.2 by greg, Wed Jun 7 08:35:12 1989 UTC vs.
Revision 2.15 by greg, Wed Sep 8 17:10:16 2004 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 <        short  sflags;          /* source flags */
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 {
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 <        float  ss;              /* tangent or disk radius */
56 <        float  ss2;             /* domega or projected area */
57 <        long  ntests, nhits;    /* shadow tests and hits */
58 <        OBJREC  *so;            /* source object */
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 >        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 <        int  sno;               /* source number */
88 <        FVECT  dir;             /* source direction */
89 <        float  dom;             /* domega for source */
90 <        float  brt;             /* brightness (for comparison) */
91 <        COLOR  val;             /* contribution */
92 < }  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  (*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 > #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 > typedef void srcdirf_t(COLOR cv, void *np, FVECT ldir, double omega);
152 > extern void     direct(RAY *r, srcdirf_t *f, void *p);
153 > extern void     srcscatter(RAY *r);
154 > extern int      m_light(OBJREC *m, RAY *r);
155 > extern void     initobscache(int sn);
156 > extern int      srcblocker(RAY *r);
157 > extern int      srcblocked(RAY *r);
158 > extern void     freeobscache(SRCREC *s);
159 >                                        /* defined in srcsamp.c */
160 > extern double   nextssamp(RAY *r, SRCINDEX *si);
161 > extern int      skipparts(int ct[3], int sz[3], int pp[2], unsigned char *pt);
162 > extern void     nopart(SRCINDEX *si, RAY *r);
163 > extern void     cylpart(SRCINDEX *si, RAY *r);
164 > extern void     flatpart(SRCINDEX *si, RAY *r);
165 > extern double   scylform(int sn, FVECT dir);
166 >                                        /* defined in srcsupp.c */
167 > extern void     initstypes(void);
168 > extern int      newsource(void);
169 > extern void     setflatss(SRCREC *src);
170 > extern void     fsetsrc(SRCREC *src, OBJREC *so);
171 > extern void     ssetsrc(SRCREC *src, OBJREC *so);
172 > extern void     sphsetsrc(SRCREC *src, OBJREC *so);
173 > extern void     rsetsrc(SRCREC *src, OBJREC *so);
174 > extern void     cylsetsrc(SRCREC *src, OBJREC *so);
175 > extern SPOT     *makespot(OBJREC *m);
176 > extern int      spotout(RAY *r, SPOT *s);
177 > extern double   fgetmaxdisk(FVECT ocent, OBJREC *op);
178 > extern double   rgetmaxdisk(FVECT ocent, OBJREC *op);
179 > extern double   fgetplaneq(FVECT nvec, OBJREC *op);
180 > extern double   rgetplaneq(FVECT nvec, OBJREC *op);
181 > extern int      commonspot(SPOT *sp1, SPOT *sp2, FVECT org);
182 > extern int      commonbeam(SPOT *sp1, SPOT *sp2, FVECT org);
183 > extern int      checkspot(SPOT *sp, FVECT nrm);
184 > extern double   spotdisk(FVECT oc, OBJREC *op, SPOT *sp, FVECT pos);
185 > extern double   beamdisk(FVECT oc, OBJREC *op, SPOT *sp, FVECT dir);
186 > extern double   intercircle(FVECT cc, FVECT c1, FVECT c2,
187 >                        double r1s, double r2s);
188 >                                        /* defined in virtuals.c */
189 > extern void     markvirtuals(void);
190 > extern void     addvirtuals(int sn, int nr);
191 > extern void     vproject(OBJREC *o, int sn, int n);
192 > extern OBJREC   *vsmaterial(OBJREC *o);
193 > extern int      makevsrc(OBJREC *op, int sn, MAT4 pm);
194 > extern double   getdisk(FVECT oc, OBJREC *op, int sn);
195 > extern int      vstestvis(int f, OBJREC *o, FVECT oc, double or2, int sn);
196 > extern void     virtverb(int sn, FILE *fp);
197 >
198 >
199 > #ifdef __cplusplus
200 > }
201 > #endif
202 > #endif /* _RAD_SOURCE_H_ */
203 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines