1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
|
/*
render/particleejectorscript.h
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/
#ifndef __INCLUDED_RENDER_PARTICLEEJECTORSCRIPT_H__
#define __INCLUDED_RENDER_PARTICLEEJECTORSCRIPT_H__
#include "math/axis.h"
#include "math/color.h"
#include "math/vector2f.h"
#include "math/vector3f.h"
#include "model/model.h"
namespace render {
class ParticleEjectorScript {
public:
/**
* @brief definition for type of ejector
* */
enum Type { Sprite = 0, Flare = 1, Trail = 2, Flame = 3 , Streak = 4 };
ParticleEjectorScript();
ParticleEjectorScript(const ParticleEjectorScript & other);
~ParticleEjectorScript();
/* ---- inspectors ----------------------------------------- */
/**
* @brief the tytpe of ejector
* */
inline const Type type() const
{
return script_type;
}
/**
* @brief ejector axis relative to the particle system
* */
inline const math::Axis &axis() const
{
return script_axis;
}
inline const unsigned int interval() const
{
return script_interval;
}
inline const unsigned long timeout() const
{
return script_timeout;
}
/**
* @brief angle of the cone through which to randomly spread ejected particles
* */
inline const float cone() const
{
return script_cone;
}
/**
* @brief offset defines the interpolation midpoint for alpha and radius ranges, default 0.5f
* */
inline const float offset() const {
return script_offset;
}
/**
* @brief lifespan of ejected particles, in milliseconds
* */
inline const unsigned long lifespan() const {
return script_lifespan;
}
/**
* @brief true if engine color is to be applied to ejected particles
* */
inline const bool engine() const {
return script_engine;
}
/**
* @brief true if entity primary color is to be applied to ejected particles
* */
inline const bool entity() const
{
return script_entity;
}
/**
* @brief true for a thrust activated ejector
* */
inline const bool thrust() const
{
return script_thrust;
}
/**
* @brief true for a thrust impulse ejector
* */
inline const bool impulse() const
{
return script_impulse;
}
/**
* @brief true for a thrust impulse ejector
* */
inline const bool explosion() const
{
return script_explosion;
}
/**
* @brief true if entity secondary color is to be applied to ejected particles
* */
inline const bool entity_second() const
{
return script_entity_second;
}
/**
* @brief true if particles are drawn in model coordinates
* */
inline const bool attached() const
{
return script_attached;
}
/**
* @brief true if particle color is interpolated between color() and color_second()
* */
inline const bool color_interpolated() const
{
return script_color_interpolated;
}
/**
* @brief ejector particles and speed are scaled according to modelscale
* */
inline const bool scaled() const
{
return script_scaled;
}
/**
* @brief name of the texture used to render ejected particles
* */
inline const std::string &texture() const {
return script_texture;
}
inline const model::Cull cull() const
{
return script_cull;
}
/**
* @brief color used to render ejected particles
* */
inline const math::Color &color() const
{
return script_color;
}
/**
* @brief secondary color used to render ejected particles
* */
inline const math::Color &color_second() const
{
return script_color_second;
}
/**
* @brief radius vector for ejected particles, start, middle, end
* The radius is interpolated depending on the age and lifespan of the particle
* */
inline const math::Vector3f &radius_vec() const
{
return script_radius_vec;
}
/**
* @brief alpha vector for ejected particles, start, middle, end
* The alpha value is interpolated depending on the age and lifespan of the particle
* */
inline const math::Vector3f & alpha_vec() const
{
return script_alpha_vec;
}
/**
* @brief minimum and maximum speed of ejected particles, in gameunits per second
* */
inline const math::Vector2f & speed_vec() const
{
return script_speed_vec;
}
/**
* @brief minimum and maximum tail speed of ejected particles, in gameunits per second
* */
inline const math::Vector2f & tailspeed_vec() const
{
return script_tailspeed_vec;
}
/**
* @brief acceleration of ejected particles, in gameunits per second squared
* */
inline const float acceleration() const
{
return script_acceleration;
}
/**
* @brief spawn radius
* radius within wich particles are spawn
* */
inline const float spawn_radius() const
{
return script_spawn_radius;
}
/* ---- mutators ------------------------------------------- */
/**
* @brief return a reference to the ejector axis
* */
inline math::Axis &get_axis()
{
return script_axis;
}
/**
* @brief return a reference to the radius vector
* */
inline math::Vector3f &get_radius_vec()
{
return script_radius_vec;
}
/**
* @brief return a reference to the alpha vector
* */
inline math::Vector3f &get_alpha_vec()
{
return script_alpha_vec;
}
/**
* @brief return a reference to the speed vector
* */
inline math::Vector2f &get_speed_vec()
{
return script_speed_vec;
}
/**
* @brief return a reference to the tail speed vector
* */
inline math::Vector2f &get_tailspeed_vec()
{
return script_tailspeed_vec;
}
/**
* @brief return a reference to primary particle color
* */
inline math::Color &get_color()
{
return script_color;
}
/**
* @brief return a reference to secondary particle color
* */
inline math::Color &get_color_second()
{
return script_color_second;
}
/**
* @brief set the ejector type
* */
inline void set_type(const Type type)
{
script_type = type;
}
/**
* @brief set the radius within which particles are spawned
* */
void set_spawn_radius(const float spawn_radius)
{
script_spawn_radius = spawn_radius;
}
/**
* @brief set the speed of ejected particles, in gameunits per second
* */
inline void set_speed_vec(const math::Vector2f &speed_vec)
{
script_speed_vec.assign(speed_vec);
}
/**
* @brief set the acceleration of ejected particles, in gameunits per second squared
* */
inline void set_acceleration(const float acceleration)
{
script_acceleration = acceleration;
}
/**
* @brief set ejector cone, in degrees
* */
inline void set_cone(const float cone)
{
script_cone = cone;
}
/**
* @brief set ejector interval, in milliseconds
* */
inline void set_interval(const unsigned long interval)
{
script_interval = interval;
}
/**
* @brief set the time after which no more particles are ejected, in milliseconds
* */
inline void set_timeout(const unsigned long timeout)
{
script_timeout = timeout;
}
/**
* @brief set particle lifespan, in milliseconds
* */
inline void set_lifespan(const unsigned long lifespan)
{
script_lifespan = lifespan;
}
/**
* @brief set polygon cull rule
* */
inline void set_cull(const model::Cull cull)
{
script_cull = cull;
}
/**
* @brief set texture name
* */
inline void set_texture(const std::string &texture)
{
script_texture.assign(texture);
}
/**
* @brief temporal interpolation midpoint, default 0.5f
* */
inline void set_offset(const float offset)
{
script_offset = offset;
}
/**
* @brief set the radius vector
* */
inline void set_radius_vec(const math::Vector3f radius_vec)
{
script_radius_vec.assign(radius_vec);
}
/**
* @brief set the alpha vector
* */
inline void set_alpha_vec(const math::Vector3f alpha_vec)
{
script_alpha_vec.assign(alpha_vec);
}
/**
* @brief set particle entity primary color
* */
inline void set_entity(const bool use_color_entity)
{
script_entity = use_color_entity;
}
/**
* @brief set particle entity secondary color
* */
inline void set_entity_second(const bool use_color_entity_second)
{
script_entity_second = use_color_entity_second;
}
/**
* @brief set particle engine color
* */
inline void set_engine(const bool use_color_engine)
{
script_engine = use_color_engine;
}
/**
* @brief enable or disable thrust activated ejector
* */
inline void set_thrust(const bool use_thrust)
{
script_thrust = use_thrust;
}
/**
* @brief enable or disable impulse activated ejector
* */
inline void set_impulse(const bool use_impulse)
{
script_impulse = use_impulse;
}
/**
* @brief enable or disable explosion activated ejector
* */
inline void set_explosion(const bool use_explosion)
{
script_explosion = use_explosion;
}
/**
* @brief ejector particles are drawn in entity coordinates
* */
inline void set_attached(const bool attached)
{
script_attached = attached;
}
/**
* @brief set to true to interpolate particle color between color() and color_second()
* */
inline void set_color_interpolated(const bool color_interpolated)
{
script_color_interpolated = color_interpolated;
}
inline void set_scaled(const bool scaled)
{
script_scaled = scaled;
}
/**
* @brief set the particle color at the begin of lifespan
* */
inline void set_color(const math::Color &color)
{
script_color.assign(color);
}
/**
* @brief set the particle color at the end of lifespane
* */
inline void set_color_second(const math::Color &color_second)
{
script_color_second.assign(color_second);
}
private:
/// type of ejector
Type script_type;
/// ejector axis, relative to the particle system axis
math::Axis script_axis;
/// interval between to ejects, in milliseconds
unsigned long script_interval;
/// time after which no more particles are ejected, in milliseconds
unsigned long script_timeout;
/// lifespan of a particle, in milliseconds
unsigned long script_lifespan;
/// ejector cone, in default 360 degrees
float script_cone;
/// offset defines the 'middle' point for radius and alpha, range 0.0f-1.0f, default 0.5f.
float script_offset;
/// particle alpha vector: 0.0 - middle - 1.0
math::Vector3f script_alpha_vec;
/// particle radius vector: 0.0 - middle - 1.0
math::Vector3f script_radius_vec;
/// minimum and maximum speed of ejected particles, in gameunits per second
math::Vector2f script_speed_vec;
/// minimum and maximum speed of ejected tail particles, in gameunits per second
math::Vector2f script_tailspeed_vec;
/// acceleration of ejected particles, in gameunits per second squared
float script_acceleration;
/// spawn radius
float script_spawn_radius;
/// color of ejected particles at start of lifespan
math::Color script_color;
/// color of ejected particles at end of lifespan
math::Color script_color_second;
/// true of the particle color has to be interpolated betwoon color and color_second
bool script_color_interpolated;
/// particles have entity primary color
bool script_entity;
/// particles have entity secondary color
bool script_entity_second;
/// particles jave engine color
bool script_engine;
/// thrust activated ejector
bool script_thrust;
/// impulse activated ejector
bool script_impulse;
/// explosion activated ejector
bool script_explosion;
/// ejector is attached to entity coordinates
bool script_attached;
/// ejector particles and speed are scaled according to modelscale
bool script_scaled;
/// texture to render particles with
std::string script_texture;
/// texture cull
model::Cull script_cull;
};
} // namespace render
#endif // __INCLUDED_RENDER_PARTICLEEJECTORSCRIPT_H__
|