aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/particles/je_particle.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-10-29 08:27:51 +0800
committerchai <chaifix@163.com>2018-10-29 08:27:51 +0800
commitaca962d7ce3d404671cace2a82b04ff937375009 (patch)
treeec315ef9df3dbd971bc914dae689e97cf9cf31ff /src/libjin/Graphics/particles/je_particle.h
parent297c78319e6bd891f27f9546334feedc030fc0a7 (diff)
*修改代码结构
Diffstat (limited to 'src/libjin/Graphics/particles/je_particle.h')
-rw-r--r--src/libjin/Graphics/particles/je_particle.h157
1 files changed, 157 insertions, 0 deletions
diff --git a/src/libjin/Graphics/particles/je_particle.h b/src/libjin/Graphics/particles/je_particle.h
new file mode 100644
index 0000000..819b95c
--- /dev/null
+++ b/src/libjin/Graphics/particles/je_particle.h
@@ -0,0 +1,157 @@
+#ifndef __JE_PARTICLE_H
+#define __JE_PARTICLE_H
+
+#include "../../math/je_vector2.hpp"
+
+namespace JinEngine
+{
+ namespace Graphics
+ {
+ namespace Particles
+ {
+
+ class ParticleEmitter;
+
+ struct LifeTimeDef
+ {
+ bool enableRandom = false;
+ union
+ {
+ struct
+ {
+ float min, max;
+ } random;
+ float life;
+ } life;
+ };
+
+ struct LinearAccelaration
+ {
+
+ };
+
+ struct SpeedOverTimeDef
+ {
+ bool enable = false;
+ bool enableRandom = false;
+ union
+ {
+ struct
+ {
+ Math::Vector2<float> startFloor;
+ Math::Vector2<float> startCeil;
+ Math::Vector2<float> endFloor;
+ Math::Vector2<float> endCeil;
+ } random;
+ struct
+ {
+ Math::Vector2<float> start;
+ Math::Vector2<float> end;
+ } speed;
+ } speed;
+ };
+
+ struct SizeOverTimeDef
+ {
+ bool enable = false;
+ bool enableRandom = false;
+ union {
+ struct {
+ float startFloor = 1;
+ float startCeil = 1;
+ float endFloor = 1;
+ float endCeil = 1;
+ } random;
+ struct {
+ float start = 1;
+ float end = 1;
+ } size;
+ } size;
+ };
+
+ struct ColorOverTime
+ {
+ bool enable = false;
+ Color colorStart = Color::WHITE;
+ Color colorEnd = Color::WHITE;
+ };
+
+ ///
+ ///
+ ///
+ struct ParticleDef
+ {
+ private:
+ friend class ParticleEmitter;
+
+ public:
+ // Basic definitions.
+ LifeTimeDef lifeTimeDef; ///<
+ // Optional definitions.
+
+ SpeedOverTimeDef speedOverTimeDef; ///<
+ SizeOverTimeDef sizeOverTimeDef; ///<
+ ColorOverTime colorOverTimeDef; ///<
+ };
+
+ ///
+ /// A single particle contains various properties of particle, such as position, accelaration, color and
+ /// other attributes changed over time.
+ ///
+ struct Particle
+ {
+ Particle(const ParticleDef& particleDef);
+ ///
+ /// Whole life time.
+ ///
+ float lifeTime = 0.0f;
+
+ ///
+ /// Current life time.
+ ///
+ float life = 0.0f;
+
+ ///
+ /// Current position.
+ ///
+ float position[2] = { 0,0 };
+
+ ///
+ /// Emitte direction.
+ ///
+ float direction = 0;
+
+ Math::Vector2<float> speed;
+ Math::Vector2<float> linearAcceleration;
+ float radialAcceleration = 0;
+ float tangetialAcceleration = 0;
+
+ ///
+ /// Size over lifetime.
+ ///
+ float size = 1;
+ float sizeBegin = 1;
+ float sizeEnd = 1;
+
+ float rotation = 0;
+ float angle = 0;
+
+ ///
+ /// Color over lifetime.
+ ///
+ Color color = Color::WHITE;
+ Color colorStart = Color::WHITE;
+ Color colorEnd = Color::WHITE;
+
+ ///
+ /// Is particle still alive? Alive is equivalent to NOT available in particle pool.
+ ///
+ bool alive = false;
+
+ };
+
+ } // namespace Particles
+ } // namespace Graphics
+} // namespace JinEngine
+
+#endif \ No newline at end of file