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