ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/source.h
Revision: 2.7
Committed: Sat Jun 7 00:54:58 2003 UTC (20 years, 10 months ago) by schorsch
Content type: text/plain
Branch: MAIN
Changes since 2.6: +12 -47 lines
Log Message:
Instrumented headers against multiple inclusion and for use from C++.
Removed NOPROTO sections.

File Contents

# Content
1 /* RCSid $Id: source.h,v 2.6 2003/02/25 02:47:23 greg 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 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13
14 #include "copyright.h"
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 long ntests, nhits; /* shadow tests and hits */
51 OBJREC *so; /* source destination object */
52 } SRCREC; /* light source */
53
54 #define MAXSPART 64 /* maximum partitions per source */
55
56 #define SU 0 /* U vector or partition */
57 #define SV 1 /* V vector or partition */
58 #define SW 2 /* W vector or partition */
59 #define S0 3 /* leaf partition */
60
61 #define snorm ss[SW] /* normal vector for flat source */
62
63 typedef struct {
64 int sn; /* source number */
65 short np; /* number of partitions */
66 short sp; /* this partition number */
67 double dom; /* solid angle of partition */
68 unsigned char spt[MAXSPART/2]; /* source partitioning */
69 } SRCINDEX; /* source index structure */
70
71 #define initsrcindex(s) ((s)->sn = (s)->sp = -1, (s)->np = 0)
72
73 #define clrpart(pt) bzero((char *)(pt), MAXSPART/2)
74 #define setpart(pt,i,v) ((pt)[(i)>>2] |= (v)<<(((i)&3)<<1))
75 #define spart(pt,pi) ((pt)[(pi)>>2] >> (((pi)&3)<<1) & 3)
76
77 /*
78 * Special support functions for sources
79 */
80
81 /*
82 * Virtual source materials must define the following.
83 *
84 * vproj(pm, op, sp, i) Compute i'th virtual projection
85 * of source sp in object op and assign
86 * the 4x4 transformation matrix pm.
87 * Return 1 on success, 0 if no i'th projection.
88 *
89 * nproj The number of projections. The value of
90 * i passed to vproj runs from 0 to nproj-1.
91 */
92
93 typedef struct {
94 int (*vproj)(); /* project virtual sources */
95 int nproj; /* number of possible projections */
96 } VSMATERIAL; /* virtual source material functions */
97
98 typedef struct {
99 void (*setsrc)(); /* set light source for object */
100 void (*partit)(); /* partition light source object */
101 double (*getpleq)(); /* plane equation for surface */
102 double (*getdisk)(); /* maximum disk for surface */
103 } SOBJECT; /* source object functions */
104
105 typedef union {
106 VSMATERIAL *mf; /* material functions */
107 SOBJECT *of; /* object functions */
108 } SRCFUNC; /* source functions */
109
110 extern SRCFUNC sfun[]; /* source dispatch table */
111
112 extern SRCREC *source; /* our source list */
113 extern int nsources; /* the number of sources */
114
115 #define sflatform(sn,dir) -DOT(source[sn].snorm, dir)
116
117 #define getplaneq(c,o) (*sfun[(o)->otype].of->getpleq)(c,o)
118 #define getmaxdisk(c,o) (*sfun[(o)->otype].of->getdisk)(c,o)
119 #define setsource(s,o) (*sfun[(o)->otype].of->setsrc)(s,o)
120
121 /* defined in source.c */
122 extern void marksources(void);
123 extern void freesources(void);
124 extern int srcray(RAY *sr, RAY *r, SRCINDEX *si);
125 extern void srcvalue(RAY *r);
126 extern int sourcehit(RAY *r);
127 extern void direct(RAY *r, void (*f)(), char *p);
128 extern void srcscatter(RAY *r);
129 extern int m_light(OBJREC *m, RAY *r);
130 /* defined in srcsamp.c */
131 extern double nextssamp(RAY *r, SRCINDEX *si);
132 extern int skipparts(int ct[3], int sz[3], int pp[2], unsigned char *pt);
133 extern void nopart(SRCINDEX *si, RAY *r);
134 extern void cylpart(SRCINDEX *si, RAY *r);
135 extern void flatpart(SRCINDEX *si, RAY *r);
136 extern double scylform(int sn, FVECT dir);
137 /* defined in srcsupp.c */
138 extern void initstypes(void);
139 extern int newsource(void);
140 extern void setflatss(SRCREC *src);
141 extern void fsetsrc(SRCREC *src, OBJREC *so);
142 extern void ssetsrc(SRCREC *src, OBJREC *so);
143 extern void sphsetsrc(SRCREC *src, OBJREC *so);
144 extern void rsetsrc(SRCREC *src, OBJREC *so);
145 extern void cylsetsrc(SRCREC *src, OBJREC *so);
146 extern SPOT *makespot(OBJREC *m);
147 extern int spotout(RAY *r, SPOT *s);
148 extern double fgetmaxdisk(FVECT ocent, OBJREC *op);
149 extern double rgetmaxdisk(FVECT ocent, OBJREC *op);
150 extern double fgetplaneq(FVECT nvec, OBJREC *op);
151 extern double rgetplaneq(FVECT nvec, OBJREC *op);
152 extern int commonspot(SPOT *sp1, SPOT *sp2, FVECT org);
153 extern int commonbeam(SPOT *sp1, SPOT *sp2, FVECT org);
154 extern int checkspot(SPOT *sp, FVECT nrm);
155 extern double spotdisk(FVECT oc, OBJREC *op, SPOT *sp, FVECT pos);
156 extern double beamdisk(FVECT oc, OBJREC *op, SPOT *sp, FVECT dir);
157 extern double intercircle(FVECT cc, FVECT c1, FVECT c2,
158 double r1s, double r2s);
159 /* defined in virtuals.c */
160 extern void markvirtuals(void);
161 extern void addvirtuals(int sn, int nr);
162 extern void vproject(OBJREC *o, int sn, int n);
163 extern OBJREC *vsmaterial(OBJREC *o);
164 extern int makevsrc(OBJREC *op, int sn, MAT4 pm);
165 extern double getdisk(FVECT oc, OBJREC *op, int sn);
166 extern int vstestvis(int f, OBJREC *o, FVECT oc, double or2, int sn);
167 extern void virtverb(int sn, FILE *fp);
168
169
170 #ifdef __cplusplus
171 }
172 #endif
173 #endif /* _RAD_SOURCE_H_ */
174