|
@@ -1,292 +1,179 @@
|
1
|
|
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
|
2
|
|
-/*================================================================
|
|
1
|
+/*!
|
|
2
|
+ * \file include/Emitter.h
|
|
3
|
+ * \brief Particle emitter class.
|
3
|
4
|
*
|
4
|
|
- * Project : Freyja
|
5
|
|
- * Author : Terry 'Mongoose' Hendrix II
|
6
|
|
- * Website : http://www.westga.edu/~stu7440/
|
7
|
|
- * Email : stu7440@westga.edu
|
8
|
|
- * Object : Emitter
|
9
|
|
- * License : No use w/o permission (C)2001Mongoose
|
10
|
|
- * Comments: Particle emitter for freyja
|
11
|
|
- *
|
12
|
|
- *
|
13
|
|
- * This file was generated using Mongoose's C++
|
14
|
|
- * template generator script. <stu7440@westga.edu>
|
15
|
|
- *
|
16
|
|
- *-- History ------------------------------------------------
|
17
|
|
- *
|
18
|
|
- * 2001.08.13:
|
19
|
|
- * Mongoose - Now using new Particle class!
|
20
|
|
- *
|
21
|
|
- * 2001.06.30:
|
22
|
|
- * Mongoose - Created
|
23
|
|
- ================================================================*/
|
24
|
|
-
|
|
5
|
+ * \author Mongoose
|
|
6
|
+ */
|
25
|
7
|
|
26
|
8
|
#ifndef _EMITTER_H_
|
27
|
9
|
#define _EMITTER_H_
|
28
|
10
|
|
29
|
11
|
#include <Particle.h>
|
30
|
12
|
|
31
|
|
-
|
32
|
|
-class Emitter
|
33
|
|
-{
|
34
|
|
- public:
|
35
|
|
-
|
36
|
|
- typedef enum
|
37
|
|
- {
|
38
|
|
- fUseFrustumCulling = 1,
|
39
|
|
- fUseDepthSorting = 2
|
|
13
|
+/*!
|
|
14
|
+ * \brief Particle emitter class.
|
|
15
|
+ */
|
|
16
|
+class Emitter {
|
|
17
|
+public:
|
|
18
|
+
|
|
19
|
+ /*!
|
|
20
|
+ * \brief Flags an Emitter can have
|
|
21
|
+ */
|
|
22
|
+ typedef enum {
|
|
23
|
+ fUseFrustumCulling = (1 << 0), //!< Use frustum culling
|
|
24
|
+ fUseDepthSorting = (1 << 1) //!< Use depth sorting
|
40
|
25
|
} EmitterFlags;
|
41
|
26
|
|
42
|
27
|
|
43
|
|
- Emitter(const char *name, int n);
|
44
|
|
- /*------------------------------------------------------
|
45
|
|
- * Pre : name is a valid C string
|
46
|
|
- * n is a number greater than 0
|
47
|
|
- *
|
48
|
|
- * Post : Constructs an object of Emitter
|
49
|
|
- *
|
50
|
|
- *-- History ------------------------------------------
|
51
|
|
- *
|
52
|
|
- * 2001.06.30:
|
53
|
|
- * Mongoose - Created
|
54
|
|
- ------------------------------------------------------*/
|
55
|
|
-
|
56
|
|
- ~Emitter();
|
57
|
|
- /*------------------------------------------------------
|
58
|
|
- * Pre : Emitter object is allocated
|
59
|
|
- * Post : Deconstructs an object of Emitter
|
60
|
|
- *
|
61
|
|
- *-- History ------------------------------------------
|
62
|
|
- *
|
63
|
|
- * 2001.06.30:
|
64
|
|
- * Mongoose - Created
|
65
|
|
- ------------------------------------------------------*/
|
66
|
|
-
|
67
|
|
- Particle *Particles();
|
68
|
|
- /*------------------------------------------------------
|
69
|
|
- * Pre :
|
70
|
|
- * Post : Returns particle array
|
71
|
|
- *
|
72
|
|
- *-- History ------------------------------------------
|
73
|
|
- *
|
74
|
|
- * 2001.08.14:
|
75
|
|
- * Mongoose - Created
|
76
|
|
- ------------------------------------------------------*/
|
77
|
|
-
|
78
|
|
- int Count();
|
79
|
|
- /*------------------------------------------------------
|
80
|
|
- * Pre :
|
81
|
|
- * Post : Returns number of particles emitted
|
82
|
|
- *
|
83
|
|
- *-- History ------------------------------------------
|
84
|
|
- *
|
85
|
|
- * 2001.08.14:
|
86
|
|
- * Mongoose - Created
|
87
|
|
- ------------------------------------------------------*/
|
88
|
|
-
|
89
|
|
- void Pos(float x, float y, float z);
|
90
|
|
- /*------------------------------------------------------
|
91
|
|
- * Pre : x,y,z exist
|
92
|
|
- * Post : Sets position of emitter in 3 space
|
93
|
|
- *
|
94
|
|
- *-- History ------------------------------------------
|
95
|
|
- *
|
96
|
|
- * 2001.08.13:
|
97
|
|
- * Mongoose - Created
|
98
|
|
- ------------------------------------------------------*/
|
99
|
|
-
|
100
|
|
- void Pos(float *x, float *y, float *z);
|
101
|
|
- /*------------------------------------------------------
|
102
|
|
- * Pre : x,y,z exist
|
103
|
|
- * Post : Returns position of emitter in 3 space
|
104
|
|
- *
|
105
|
|
- *-- History ------------------------------------------
|
106
|
|
- *
|
107
|
|
- * 2001.08.13:
|
108
|
|
- * Mongoose - Created
|
109
|
|
- ------------------------------------------------------*/
|
110
|
|
-
|
|
28
|
+ /*!
|
|
29
|
+ * \brief Constructs an object of Emitter
|
|
30
|
+ * \param name valid C string
|
|
31
|
+ * \param n greater than 0
|
|
32
|
+ */
|
|
33
|
+ Emitter(const char *name, int n);
|
|
34
|
+
|
|
35
|
+ /*!
|
|
36
|
+ * \brief Deconstructs an object of Emitter
|
|
37
|
+ */
|
|
38
|
+ ~Emitter();
|
|
39
|
+
|
|
40
|
+ /*!
|
|
41
|
+ * \brief Get the particles
|
|
42
|
+ * \returns array of Particles
|
|
43
|
+ */
|
|
44
|
+ Particle *Particles();
|
|
45
|
+
|
|
46
|
+ /*!
|
|
47
|
+ * \brief Number of particles emitted
|
|
48
|
+ * \returns Number of particles emitted
|
|
49
|
+ */
|
|
50
|
+ int Count();
|
|
51
|
+
|
|
52
|
+ /*!
|
|
53
|
+ * \brief Sets position of emitter in 3D space
|
|
54
|
+ * \param x X coordinate
|
|
55
|
+ * \param y Y coordinate
|
|
56
|
+ * \param z Z coordinate
|
|
57
|
+ */
|
|
58
|
+ void Pos(float x, float y, float z);
|
|
59
|
+
|
|
60
|
+ /*!
|
|
61
|
+ * \brief Returns position of emitter in 3D space
|
|
62
|
+ * \param x Where X coordinate will be stored
|
|
63
|
+ * \param y Where Y coordinate will be stored
|
|
64
|
+ * \param z Where Z coordinate will be stored
|
|
65
|
+ */
|
|
66
|
+ void Pos(float *x, float *y, float *z);
|
|
67
|
+
|
|
68
|
+ /*!
|
|
69
|
+ * \brief Sets orientation of emitter in 3D space
|
|
70
|
+ * \param x X coordinate
|
|
71
|
+ * \param y Y coordinate
|
|
72
|
+ * \param z Z coordinate
|
|
73
|
+ */
|
111
|
74
|
void Orientation(float x, float y, float z);
|
112
|
|
- /*------------------------------------------------------
|
113
|
|
- * Pre : x,y,z exist
|
114
|
|
- * Post : Sets orientation of emitter in 3 space
|
115
|
|
- *
|
116
|
|
- *-- History ------------------------------------------
|
117
|
|
- *
|
118
|
|
- * 2001.08.13:
|
119
|
|
- * Mongoose - Created
|
120
|
|
- ------------------------------------------------------*/
|
121
|
75
|
|
|
76
|
+ /*!
|
|
77
|
+ * \brief Returns orientation of emitter in 3D space
|
|
78
|
+ * \param x Where X coordinate will be stored
|
|
79
|
+ * \param y Where Y coordinate will be stored
|
|
80
|
+ * \param z Where Z coordinate will be stored
|
|
81
|
+ */
|
122
|
82
|
void Orientation(float *x, float *y, float *z);
|
123
|
|
- /*------------------------------------------------------
|
124
|
|
- * Pre : x,y,z exist
|
125
|
|
- * Post : Returns orientation of emitter in 3 space
|
126
|
|
- *
|
127
|
|
- *-- History ------------------------------------------
|
128
|
|
- *
|
129
|
|
- * 2001.08.13:
|
130
|
|
- * Mongoose - Created
|
131
|
|
- ------------------------------------------------------*/
|
132
|
|
-
|
133
|
|
- unsigned int Flags();
|
134
|
|
- /*------------------------------------------------------
|
135
|
|
- * Pre :
|
136
|
|
- * Post : Returns emitter flags
|
137
|
|
- *
|
138
|
|
- *-- History ------------------------------------------
|
139
|
|
- *
|
140
|
|
- * 2001.08.14:
|
141
|
|
- * Mongoose - Created
|
142
|
|
- ------------------------------------------------------*/
|
143
|
|
-
|
144
|
|
-
|
145
|
|
- void Flags(unsigned int flag, bool op);
|
146
|
|
- /*------------------------------------------------------
|
147
|
|
- * Pre :
|
148
|
|
- * Post : Set and Unset flag with op
|
149
|
|
- *
|
150
|
|
- * true - set
|
151
|
|
- * flase - unset
|
152
|
|
- *
|
153
|
|
- *-- History ------------------------------------------
|
154
|
|
- *
|
155
|
|
- * 2001.08.14:
|
156
|
|
- * Mongoose - Created
|
157
|
|
- ------------------------------------------------------*/
|
158
|
|
-
|
159
|
|
- void ParticleArray(int n);
|
160
|
|
- /*------------------------------------------------------
|
161
|
|
- * Pre : n is a number greater than 0
|
162
|
|
- * Post : Allocates the particle array and sets the count.
|
163
|
|
- * If the array has been allocated previously, then
|
164
|
|
- * the array is deallocated and a new one made.
|
165
|
|
- *
|
166
|
|
- *
|
167
|
|
- *-- History ------------------------------------------
|
168
|
|
- *
|
169
|
|
- * 2001.08.13:
|
170
|
|
- * Mongoose - Created
|
171
|
|
- ------------------------------------------------------*/
|
172
|
|
-
|
173
|
|
- void Draw();
|
174
|
|
- /*------------------------------------------------------
|
175
|
|
- * Pre :
|
176
|
|
- * Post : Renders particles
|
177
|
|
- *
|
178
|
|
- *-- History ------------------------------------------
|
179
|
|
- *
|
180
|
|
- * 2001.06.30:
|
181
|
|
- * Mongoose - Created
|
182
|
|
- ------------------------------------------------------*/
|
183
|
|
-
|
184
|
|
- void Name(const char *name);
|
185
|
|
- /*------------------------------------------------------
|
186
|
|
- * Pre : name is a valid C string
|
187
|
|
- * Post : Sets the emitters name
|
188
|
|
- *
|
189
|
|
- *-- History ------------------------------------------
|
190
|
|
- *
|
191
|
|
- * 2001.08.13:
|
192
|
|
- * Mongoose - Created
|
193
|
|
- ------------------------------------------------------*/
|
194
|
|
-
|
195
|
|
- void SetTextureId(int id);
|
196
|
|
- /*------------------------------------------------------
|
197
|
|
- * Pre :
|
198
|
|
- * Post : Resets all particle texture ids
|
199
|
|
- *
|
200
|
|
- *-- History ------------------------------------------
|
201
|
|
- *
|
202
|
|
- * 2001.08.13:
|
203
|
|
- * Mongoose - Created
|
204
|
|
- ------------------------------------------------------*/
|
205
|
|
-
|
206
|
|
- void TextureId(unsigned int particle_start, unsigned int particle_end,
|
207
|
|
- int id);
|
208
|
|
- /*------------------------------------------------------
|
209
|
|
- * Pre : particle_start and particle_end are a valid
|
210
|
|
- * range of particles in the array
|
211
|
|
- *
|
212
|
|
- * id is a valid texture id
|
213
|
|
- *
|
214
|
|
- * Post :
|
215
|
|
- *
|
216
|
|
- *-- History ------------------------------------------
|
217
|
|
- *
|
218
|
|
- * 2001.08.14:
|
219
|
|
- * Mongoose - Created
|
220
|
|
- ------------------------------------------------------*/
|
221
|
|
-
|
222
|
|
- void Color(unsigned int particle_start, unsigned int particle_end,
|
223
|
|
- float r, float g, float b);
|
224
|
|
- /*------------------------------------------------------
|
225
|
|
- * Pre : particle_start and particle_end are a valid
|
226
|
|
- * range of particles in the array
|
227
|
|
- *
|
228
|
|
- * r,g,b are colors 0.0 to 1.0
|
229
|
|
- *
|
230
|
|
- * Post :
|
231
|
|
- *
|
232
|
|
- *-- History ------------------------------------------
|
233
|
|
- *
|
234
|
|
- * 2001.08.14:
|
235
|
|
- * Mongoose - Created
|
236
|
|
- ------------------------------------------------------*/
|
237
|
|
-
|
238
|
|
- void Speed(unsigned int particle_start, unsigned int particle_end,
|
239
|
|
- float x, float y, float z);
|
240
|
|
- /*------------------------------------------------------
|
241
|
|
- * Pre : particle_start and particle_end are a valid
|
242
|
|
- * range of particles in the array
|
243
|
|
- *
|
244
|
|
- * take note speed inits at 2000, lower is faster
|
245
|
|
- *
|
246
|
|
- * Post :
|
247
|
|
- *
|
248
|
|
- *-- History ------------------------------------------
|
249
|
|
- *
|
250
|
|
- * 2001.08.14:
|
251
|
|
- * Mongoose - Created
|
252
|
|
- ------------------------------------------------------*/
|
253
|
|
-
|
254
|
|
- void Force(unsigned int particle_start, unsigned int particle_end,
|
255
|
|
- float x, float y, float z);
|
256
|
|
- /*------------------------------------------------------
|
257
|
|
- * Pre : particle_start and particle_end are a valid
|
258
|
|
- * range of particles in the array
|
259
|
|
- *
|
260
|
|
- * Force/Gravity acting on particles
|
261
|
|
- *
|
262
|
|
- * Post :
|
263
|
|
- *
|
264
|
|
- *-- History ------------------------------------------
|
265
|
|
- *
|
266
|
|
- * 2001.08.14:
|
267
|
|
- * Mongoose - Created
|
268
|
|
- ------------------------------------------------------*/
|
269
|
|
-
|
270
|
|
-
|
271
|
|
- static vec_t mFrustum[6][4]; /* View Volume copy */
|
272
|
|
-
|
273
|
|
-
|
274
|
|
- private:
|
275
|
83
|
|
|
84
|
+ /*!
|
|
85
|
+ * \brief Get the flags of this Emitter
|
|
86
|
+ * \returns EmitterFlags
|
|
87
|
+ */
|
|
88
|
+ unsigned int Flags();
|
|
89
|
+
|
|
90
|
+ /*!
|
|
91
|
+ * \brief Set or Unset a flag
|
|
92
|
+ * \param flag EmitterFlag to change
|
|
93
|
+ * \param op new state (true - set)
|
|
94
|
+ */
|
|
95
|
+ void Flags(unsigned int flag, bool op);
|
|
96
|
+
|
|
97
|
+ /*!
|
|
98
|
+ * \brief Allocates the particle array and sets the count.
|
|
99
|
+ * If the array has been allocated previously it will be
|
|
100
|
+ * deallocated and a new one made.
|
|
101
|
+ * \param n new size, greater than 0
|
|
102
|
+ */
|
|
103
|
+ void ParticleArray(int n);
|
|
104
|
+
|
|
105
|
+ /*!
|
|
106
|
+ * \brief Renders the particles
|
|
107
|
+ */
|
|
108
|
+ void Draw();
|
|
109
|
+
|
|
110
|
+ /*!
|
|
111
|
+ * \brief Sets the emitters name
|
|
112
|
+ * \param name is a valid C string
|
|
113
|
+ */
|
|
114
|
+ void Name(const char *name);
|
|
115
|
+
|
|
116
|
+ /*!
|
|
117
|
+ * \brief Resets all particle texture ids
|
|
118
|
+ * \param id new id
|
|
119
|
+ * \sa Particle::TextureId()
|
|
120
|
+ */
|
|
121
|
+ void SetTextureId(int id);
|
|
122
|
+
|
|
123
|
+ /*!
|
|
124
|
+ * \brief Set the texture id for a range of particles in the array
|
|
125
|
+ * \param particle_start start of range
|
|
126
|
+ * \param particle_end end of range
|
|
127
|
+ * \param id new id
|
|
128
|
+ * \sa Particle::TextureId()
|
|
129
|
+ */
|
|
130
|
+ void TextureId(unsigned int particle_start, unsigned int particle_end, int id);
|
|
131
|
+
|
|
132
|
+ /*!
|
|
133
|
+ * \brief Set the color of a range of particles in the array
|
|
134
|
+ * \param particle_start start of range
|
|
135
|
+ * \param particle_end end of range
|
|
136
|
+ * \param r new red part of color (0.0 to 1.0)
|
|
137
|
+ * \param g new green part of color (0.0 to 1.0)
|
|
138
|
+ * \param b new blue part of color (0.0 to 1.0)
|
|
139
|
+ * \sa Particle::Color()
|
|
140
|
+ */
|
|
141
|
+ void Color(unsigned int particle_start, unsigned int particle_end, float r, float g, float b);
|
|
142
|
+
|
|
143
|
+ /*!
|
|
144
|
+ * \brief Set the speed of a range of particles in the array.
|
|
145
|
+ * Take note that the speed starts out at 2000, and lower means faster.
|
|
146
|
+ * \param particle_start start of range
|
|
147
|
+ * \param particle_end end of range
|
|
148
|
+ * \param x X speed
|
|
149
|
+ * \param y Y speed
|
|
150
|
+ * \param z Z speed
|
|
151
|
+ * \sa Particle::Speed
|
|
152
|
+ */
|
|
153
|
+ void Speed(unsigned int particle_start, unsigned int particle_end, float x, float y, float z);
|
|
154
|
+
|
|
155
|
+ /*!
|
|
156
|
+ * \brief Let a force (eg. Gravity) act on a range of particles in the array
|
|
157
|
+ * \param particle_start start of range
|
|
158
|
+ * \param particle_end end of range
|
|
159
|
+ * \param x X force
|
|
160
|
+ * \param y Y force
|
|
161
|
+ * \param z Z force
|
|
162
|
+ * \sa Particle::Force()
|
|
163
|
+ */
|
|
164
|
+ void Force(unsigned int particle_start, unsigned int particle_end, float x, float y, float z);
|
|
165
|
+
|
|
166
|
+ static vec_t mFrustum[6][4]; //!< View Volume copy
|
|
167
|
+
|
|
168
|
+private:
|
276
|
169
|
static int compareParticleDist(const void *voidA, const void *voidB);
|
277
|
170
|
|
278
|
|
-
|
279
|
|
- char *_name; /* Emitter name */
|
280
|
|
-
|
281
|
|
- unsigned int _flags; /* Emitter flags */
|
282
|
|
-
|
283
|
|
- vec3_t _pos; /* Position in 3 space */
|
284
|
|
-
|
285
|
|
- vec3_t _mangle; /* Oreintation in 3 space */
|
286
|
|
-
|
287
|
|
- Particle *_particle; /* Array of particles */
|
288
|
|
-
|
289
|
|
- unsigned int _count; /* Particle count */
|
|
171
|
+ char *_name; //!< Emitter name
|
|
172
|
+ unsigned int _flags; //!< Emitter flags
|
|
173
|
+ vec3_t _pos; //!< Position in 3D space
|
|
174
|
+ vec3_t _mangle; //!< Oreintation in 3D space
|
|
175
|
+ Particle *_particle; //!< Array of particles
|
|
176
|
+ unsigned int _count; //!< Particle count
|
290
|
177
|
};
|
291
|
178
|
|
292
|
179
|
#endif
|