ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/source.h
Revision: 2.11
Committed: Mon Jul 14 22:24:00 2003 UTC (20 years, 9 months ago) by schorsch
Content type: text/plain
Branch: MAIN
Changes since 2.10: +4 -3 lines
Log Message:
Instrumented headers against multiple inclusion and for use from C++.
Moved includes in headers out of "C" scope.

File Contents

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