浏览代码

Documented Emitter

Thomas Buck 11 年前
父节点
当前提交
fb537a41a8
共有 2 个文件被更改,包括 203 次插入421 次删除
  1. 160
    273
      include/Emitter.h
  2. 43
    148
      src/Emitter.cpp

+ 160
- 273
include/Emitter.h 查看文件

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
 #ifndef _EMITTER_H_
8
 #ifndef _EMITTER_H_
27
 #define _EMITTER_H_
9
 #define _EMITTER_H_
28
 
10
 
29
 #include <Particle.h>
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
     } EmitterFlags;
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
     void Orientation(float x, float y, float z);
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
     void Orientation(float *x, float *y, float *z);
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
     static int compareParticleDist(const void *voidA, const void *voidB);
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
 #endif
179
 #endif

+ 43
- 148
src/Emitter.cpp 查看文件

1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file src/Emitter.cpp
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.06.30:
19
- * Mongoose - Created
20
- =================================================================*/
5
+ * \author Mongoose
6
+ */
21
 
7
 
22
 #include <stdlib.h>
8
 #include <stdlib.h>
23
 #include <string.h>
9
 #include <string.h>
38
 
24
 
39
 vec_t Emitter::mFrustum[6][4];
25
 vec_t Emitter::mFrustum[6][4];
40
 
26
 
41
-
42
-int Emitter::compareParticleDist(const void *voidA, const void *voidB)
43
-{
27
+int Emitter::compareParticleDist(const void *voidA, const void *voidB) {
44
     Particle *a = (Particle *)voidA, *b = (Particle *)voidB;
28
     Particle *a = (Particle *)voidA, *b = (Particle *)voidB;
45
     float x, y, z, distA, distB;
29
     float x, y, z, distA, distB;
46
 
30
 
68
     return 1;
52
     return 1;
69
 }
53
 }
70
 
54
 
71
-
72
-Emitter::Emitter(const char *name, int n)
73
-{
55
+Emitter::Emitter(const char *name, int n) {
74
     _name = NULL;
56
     _name = NULL;
75
     _flags = 0;
57
     _flags = 0;
76
     _particle = NULL;
58
     _particle = NULL;
82
     ParticleArray(n);
64
     ParticleArray(n);
83
 }
65
 }
84
 
66
 
85
-
86
-Emitter::~Emitter()
87
-{
67
+Emitter::~Emitter() {
88
     if (_name)
68
     if (_name)
89
-    {
90
         delete [] _name;
69
         delete [] _name;
91
-    }
92
 
70
 
93
     if (_particle)
71
     if (_particle)
94
-    {
95
         delete [] _particle;
72
         delete [] _particle;
96
-    }
97
 
73
 
98
     _count = 0;
74
     _count = 0;
99
 }
75
 }
100
 
76
 
101
-Particle *Emitter::Particles()
102
-{
77
+Particle *Emitter::Particles() {
103
     return _particle;
78
     return _particle;
104
 }
79
 }
105
 
80
 
106
 
81
 
107
-int Emitter::Count()
108
-{
82
+int Emitter::Count() {
109
     return _count;
83
     return _count;
110
 }
84
 }
111
 
85
 
112
-
113
-void Emitter::Pos(float *x, float *y, float *z)
114
-{
86
+void Emitter::Pos(float *x, float *y, float *z) {
115
     *x = _pos[0];
87
     *x = _pos[0];
116
     *y = _pos[1];
88
     *y = _pos[1];
117
     *z = _pos[2];
89
     *z = _pos[2];
118
 }
90
 }
119
 
91
 
120
-
121
-void Emitter::Pos(float x, float y, float z)
122
-{
92
+void Emitter::Pos(float x, float y, float z) {
123
     _pos[0] = x;
93
     _pos[0] = x;
124
     _pos[1] = y;
94
     _pos[1] = y;
125
     _pos[2] = z;
95
     _pos[2] = z;
126
 }
96
 }
127
 
97
 
128
-
129
-void Emitter::Orientation(float *x, float *y, float *z)
130
-{
98
+void Emitter::Orientation(float *x, float *y, float *z) {
131
     *x = _mangle[0];
99
     *x = _mangle[0];
132
     *y = _mangle[1];
100
     *y = _mangle[1];
133
     *z = _mangle[2];
101
     *z = _mangle[2];
134
 }
102
 }
135
 
103
 
136
-
137
-void Emitter::Orientation(float x, float y, float z)
138
-{
104
+void Emitter::Orientation(float x, float y, float z) {
139
     _mangle[0] = x;
105
     _mangle[0] = x;
140
     _mangle[1] = y;
106
     _mangle[1] = y;
141
     _mangle[2] = z;
107
     _mangle[2] = z;
142
 }
108
 }
143
 
109
 
144
-
145
-unsigned int Emitter::Flags()
146
-{
110
+unsigned int Emitter::Flags() {
147
     return _flags;
111
     return _flags;
148
 }
112
 }
149
 
113
 
150
-
151
-void Emitter::Flags(unsigned int flag, bool op)
152
-{
114
+void Emitter::Flags(unsigned int flag, bool op) {
153
     _flags |= flag;
115
     _flags |= flag;
154
 
116
 
155
     if (!op)
117
     if (!op)
156
         _flags ^= flag;
118
         _flags ^= flag;
157
 }
119
 }
158
 
120
 
159
-
160
-void Emitter::ParticleArray(int n)
161
-{
162
-    if (n)
163
-    {
164
-        if (_particle)
165
-        {
121
+void Emitter::ParticleArray(int n) {
122
+    if (n) {
123
+        if (_particle) {
166
             _count = 0;
124
             _count = 0;
167
             delete [] _particle;
125
             delete [] _particle;
168
         }
126
         }
172
     }
130
     }
173
 }
131
 }
174
 
132
 
175
-
176
-void Emitter::Name(const char *name)
177
-{
178
-    int l;
179
-
180
-
181
-    if (name && name[0])
182
-    {
133
+void Emitter::Name(const char *name) {
134
+    if (name && name[0]) {
183
         if (_name)
135
         if (_name)
184
-        {
185
             delete [] _name;
136
             delete [] _name;
186
-        }
187
 
137
 
188
-        l = strlen(name);
138
+        int l = strlen(name);
189
         _name = new char[l+1];
139
         _name = new char[l+1];
190
 
140
 
191
         // Mongoose 2002.01.09, Mongoose says 'Only you can prevent overflows'
141
         // Mongoose 2002.01.09, Mongoose says 'Only you can prevent overflows'
194
     }
144
     }
195
 }
145
 }
196
 
146
 
197
-
198
-void Emitter::SetTextureId(int id)
199
-{
200
-    unsigned int i;
201
-
202
-
203
-    for (i = 0; i < _count; i++)
147
+void Emitter::SetTextureId(int id) {
148
+    for (unsigned int i = 0; i < _count; i++)
204
         _particle[i].TextureId(id);
149
         _particle[i].TextureId(id);
205
 }
150
 }
206
 
151
 
207
-
208
-void Emitter::TextureId(unsigned int particle_start,
209
-        unsigned int particle_end, int id)
210
-{
211
-    unsigned int i;
212
-
213
-
214
-    if ((particle_start < _count) &&
215
-            (particle_end > 0 && particle_end <= _count) &&
216
-            (particle_start < particle_end))
217
-    {
218
-        for (i = particle_start; i < particle_end; i++)
152
+void Emitter::TextureId(unsigned int particle_start, unsigned int particle_end, int id) {
153
+    if ((particle_start < _count) && (particle_end > 0 && particle_end <= _count) && (particle_start < particle_end)) {
154
+        for (unsigned int i = particle_start; i < particle_end; i++)
219
             _particle[i].TextureId(id);
155
             _particle[i].TextureId(id);
220
     }
156
     }
221
 }
157
 }
222
 
158
 
223
-
224
-void Emitter::Color(unsigned int particle_start, unsigned int particle_end,
225
-        float r, float g, float b)
226
-{
227
-    unsigned int i;
228
-
229
-
230
-    if ((particle_start < _count) &&
231
-            (particle_end > 0 && particle_end <= _count) &&
232
-            (particle_start < particle_end))
233
-    {
234
-        for (i = particle_start; i < particle_end; i++)
159
+void Emitter::Color(unsigned int particle_start, unsigned int particle_end, float r, float g, float b) {
160
+    if ((particle_start < _count) && (particle_end > 0 && particle_end <= _count) && (particle_start < particle_end)) {
161
+        for (unsigned int i = particle_start; i < particle_end; i++)
235
             _particle[i].Color(r, g, b);
162
             _particle[i].Color(r, g, b);
236
     }
163
     }
237
 }
164
 }
238
 
165
 
239
-
240
-void Emitter::Speed(unsigned int particle_start, unsigned int particle_end,
241
-        float x, float y, float z)
242
-{
243
-    unsigned int i;
244
-
245
-
246
-    if ((particle_start < _count) &&
247
-            (particle_end > 0 && particle_end <= _count) &&
248
-            (particle_start < particle_end))
249
-    {
250
-        for (i = particle_start; i < particle_end; i++)
166
+void Emitter::Speed(unsigned int particle_start, unsigned int particle_end, float x, float y, float z) {
167
+    if ((particle_start < _count) && (particle_end > 0 && particle_end <= _count) && (particle_start < particle_end)) {
168
+        for (unsigned int i = particle_start; i < particle_end; i++)
251
             _particle[i].Speed(x, y, z);
169
             _particle[i].Speed(x, y, z);
252
     }
170
     }
253
 }
171
 }
254
 
172
 
255
-
256
-void Emitter::Force(unsigned int particle_start, unsigned int particle_end,
257
-        float x, float y, float z)
258
-{
259
-    unsigned int i;
260
-
261
-
262
-    if ((particle_start < _count) &&
263
-            (particle_end > 0 && particle_end <= _count) &&
264
-            (particle_start < particle_end))
265
-    {
266
-        for (i = particle_start; i < particle_end; i++)
173
+void Emitter::Force(unsigned int particle_start, unsigned int particle_end, float x, float y, float z) {
174
+    if ((particle_start < _count) && (particle_end > 0 && particle_end <= _count) && (particle_start < particle_end)) {
175
+        for (unsigned int i = particle_start; i < particle_end; i++)
267
             _particle[i].Force(x, y, z);
176
             _particle[i].Force(x, y, z);
268
     }
177
     }
269
 }
178
 }
270
 
179
 
271
-
272
-void Emitter::Draw()
273
-{
180
+void Emitter::Draw() {
274
     unsigned int i, p;
181
     unsigned int i, p;
275
     float x, y, z;
182
     float x, y, z;
276
     float r, g, b;
183
     float r, g, b;
277
     float life;
184
     float life;
278
 
185
 
279
-
280
-    if (!_count || !_particle)
281
-    {
186
+    if (!_count || !_particle) {
282
         printf("Emitter::Draw> No particles!\n");
187
         printf("Emitter::Draw> No particles!\n");
283
         return;
188
         return;
284
     }
189
     }
291
     //glTranslatef(_pos[0], _pos[1], _pos[2]);
196
     //glTranslatef(_pos[0], _pos[1], _pos[2]);
292
 
197
 
293
     if (_flags & fUseDepthSorting)
198
     if (_flags & fUseDepthSorting)
294
-    {
295
         qsort(_particle, _count, sizeof(Particle), compareParticleDist);
199
         qsort(_particle, _count, sizeof(Particle), compareParticleDist);
296
-    }
297
 
200
 
298
-    for (i = 0; i < _count; i++)
299
-    {
300
-        if (_particle[i].isActive())
301
-        {
201
+    for (i = 0; i < _count; i++) {
202
+        if (_particle[i].isActive()) {
302
             _particle[i].Pos(&x, &y, &z);
203
             _particle[i].Pos(&x, &y, &z);
303
 
204
 
304
-            if (_flags & fUseFrustumCulling)
305
-            {
306
-                for (p = 0; p < 6; ++p)
307
-                {
308
-                    if (mFrustum[p][0] * x +
309
-                            mFrustum[p][1] * y +
310
-                            mFrustum[p][2] * z +
311
-                            mFrustum[p][3] < 0)
312
-                    {
205
+            if (_flags & fUseFrustumCulling) {
206
+                for (p = 0; p < 6; ++p) {
207
+                    if (((mFrustum[p][0] * x) + (mFrustum[p][1] * y) + (mFrustum[p][2] * z) + mFrustum[p][3]) < 0) {
313
                         _particle[i].setActive(false);
208
                         _particle[i].setActive(false);
314
                         break;
209
                         break;
315
                     }
210
                     }

正在加载...
取消
保存