aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/graphics/particles/particle.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/graphics/particles/particle.h')
-rw-r--r--src/libjin/graphics/particles/particle.h410
1 files changed, 205 insertions, 205 deletions
diff --git a/src/libjin/graphics/particles/particle.h b/src/libjin/graphics/particles/particle.h
index 081ad26..25db6ae 100644
--- a/src/libjin/graphics/particles/particle.h
+++ b/src/libjin/graphics/particles/particle.h
@@ -12,211 +12,211 @@
namespace JinEngine
{
- namespace Graphics
- {
- namespace Particles
- {
-
- class ParticleEmitter;
-
- class ScaledRangedValue : public Math::RangedValue
- {
- public:
- ScaledRangedValue() {};
- ScaledRangedValue(Math::Percentage* points, uint n);
- void set(Math::Percentage* points, uint n);
-
- };
-
- class GradientColorValue
- {
- public:
- GradientColorValue();
-
- void addColor(Color col, Math::Percentage time);
- Color getColor(Math::Percentage time);
- void insertColor(uint i, Color col, Math::Percentage time);
- void removeColor(uint i);
-
- private:
- std::vector<Color> mColors;
- std::vector<Math::Percentage> mTimeline;
- uint mCount;
-
- };
-
- ///
- ///
- ///
- struct LifeTimeDef
- {
- bool enableRandom = false;
- Struct(life,
- struct
- {
- float floor, ceil;
- } random;
- float life = 1.0f;
- );
- };
-
- struct ScaleDef
- {
- float scale = 1;
- Struct(overTime,
- bool enable = false;
- ScaledRangedValue value;
- );
- };
-
- struct ColorDef
- {
- Color color = Color::WHITE;
- Struct(overTime,
- bool enable = false;
- GradientColorValue value;
- );
- };
-
- struct TransparencyDef
- {
- Math::Percentage transparency = 1.f;
- Struct(overTime,
- bool enable = false;
- ScaledRangedValue value;
- );
- };
-
- struct linearAccelarationDef
- {
- Math::Vector2<float> linearAccelaration;
- };
-
- struct RadialAccelarationDef
- {
- float radialAccelaration = 0.f;
- };
-
- struct AngularSpeedDef
- {
- bool enableRandom = false;
- Struct(angularSpeed,
- struct
- {
- float floor = 0;
- float ceil = 0;
- } random;
- float angularSpeed = 0;
- );
- };
-
- enum SpriteMode
- {
- SINGLE = 1,
- RANDOM = 2,
- ANIMATED = 3,
- };
-
- struct SpritesDef
- {
- SpriteMode mode = SpriteMode::SINGLE;
- std::vector<const Sprite*> sprites;
- };
-
- struct BlendDef
- {
- bool additive = false;
- };
-
- ///
- ///
- ///
- struct ParticleDef
- {
- public:
- // Basic definitions.
- LifeTimeDef lifeTimeDef; ///<
- linearAccelarationDef linearAccelarationDef; ///<
- RadialAccelarationDef radialAccelarationDef; ///<
- AngularSpeedDef angularSpeedDef; ///<
- SpritesDef spritesDef; ///<
- BlendDef blendDef; ///<
- // Optional definitions.
- ScaleDef scaleDef; ///<
- ColorDef colorDef; ///<
- TransparencyDef transparencyDef; ///<
-
- private:
- friend class ParticleEmitter;
-
- };
-
- ///
- /// A single particle contains various properties of particle, such as position, accelaration, color
- /// and other attributes changed over time.
- ///
- class Particle : public Renderable, public Game::GameObject
- {
- public:
- enum ParticleUpdateMask
- {
- NONE = 0,
- UPDATE_COLOR = 1 << 0,
- UPDATE_SCALE = 1 << 1,
- UPDATE_POSITION = 1 << 2,
- UPDATE_ROTATION = 1 << 3,
- UPDATE_SPRITE = 1 << 4,
- UPDATE_VELOCITY = 1 << 5,
- };
-
- ///
- /// Default constructor.
- ///
- Particle();
-
- ///
- /// Reset to default.
- ///
- void reset();
-
- ///
- ///
- ///
- void update(float dt);
-
- ///
- ///
- ///
- void render();
-
- // Methods end.
-
- ParticleDef* def;
-
- uint updateFlags = ParticleUpdateMask::NONE;
-
- float lifeTime = 1.0f;
-
- float life = 0.0f;
-
- int spriteIndex = 0;
-
- Color color = Color::WHITE;
-
- Math::Transform transform;
-
- Math::Vector2<float> velocity;
- Math::Vector2<float> linearAcceleration;
-
- float angularSpeed;
- float radialAcceleration = 0;
-
- bool alive = true;
-
- };
-
- } // namespace Particles
- } // namespace Graphics
+ namespace Graphics
+ {
+ namespace Particles
+ {
+
+ class ParticleEmitter;
+
+ class ScaledRangedValue : public Math::RangedValue
+ {
+ public:
+ ScaledRangedValue() {};
+ ScaledRangedValue(Math::Percentage* points, uint n);
+ void set(Math::Percentage* points, uint n);
+
+ };
+
+ class GradientColorValue
+ {
+ public:
+ GradientColorValue();
+
+ void addColor(Color col, Math::Percentage time);
+ Color getColor(Math::Percentage time);
+ void insertColor(uint i, Color col, Math::Percentage time);
+ void removeColor(uint i);
+
+ private:
+ std::vector<Color> mColors;
+ std::vector<Math::Percentage> mTimeline;
+ uint mCount;
+
+ };
+
+ ///
+ ///
+ ///
+ struct LifeTimeDef
+ {
+ bool enableRandom = false;
+ Struct(life,
+ struct
+ {
+ float floor, ceil;
+ } random;
+ float life = 1.0f;
+ );
+ };
+
+ struct ScaleDef
+ {
+ float scale = 1;
+ Struct(overTime,
+ bool enable = false;
+ ScaledRangedValue value;
+ );
+ };
+
+ struct ColorDef
+ {
+ Color color = Color::WHITE;
+ Struct(overTime,
+ bool enable = false;
+ GradientColorValue value;
+ );
+ };
+
+ struct TransparencyDef
+ {
+ Math::Percentage transparency = 1.f;
+ Struct(overTime,
+ bool enable = false;
+ ScaledRangedValue value;
+ );
+ };
+
+ struct linearAccelarationDef
+ {
+ Math::Vector2<float> linearAccelaration;
+ };
+
+ struct RadialAccelarationDef
+ {
+ float radialAccelaration = 0.f;
+ };
+
+ struct AngularSpeedDef
+ {
+ bool enableRandom = false;
+ Struct(angularSpeed,
+ struct
+ {
+ float floor = 0;
+ float ceil = 0;
+ } random;
+ float angularSpeed = 0;
+ );
+ };
+
+ enum SpriteMode
+ {
+ SINGLE = 1,
+ RANDOM = 2,
+ ANIMATED = 3,
+ };
+
+ struct SpritesDef
+ {
+ SpriteMode mode = SpriteMode::SINGLE;
+ std::vector<const Sprite*> sprites;
+ };
+
+ struct BlendDef
+ {
+ bool additive = false;
+ };
+
+ ///
+ ///
+ ///
+ struct ParticleDef
+ {
+ public:
+ // Basic definitions.
+ LifeTimeDef lifeTimeDef; ///<
+ linearAccelarationDef linearAccelarationDef; ///<
+ RadialAccelarationDef radialAccelarationDef; ///<
+ AngularSpeedDef angularSpeedDef; ///<
+ SpritesDef spritesDef; ///<
+ BlendDef blendDef; ///<
+ // Optional definitions.
+ ScaleDef scaleDef; ///<
+ ColorDef colorDef; ///<
+ TransparencyDef transparencyDef; ///<
+
+ private:
+ friend class ParticleEmitter;
+
+ };
+
+ ///
+ /// A single particle contains various properties of particle, such as position, accelaration, color
+ /// and other attributes changed over time.
+ ///
+ class Particle : public Renderable, public Game::GameObject
+ {
+ public:
+ enum ParticleUpdateMask
+ {
+ NONE = 0,
+ UPDATE_COLOR = 1 << 0,
+ UPDATE_SCALE = 1 << 1,
+ UPDATE_POSITION = 1 << 2,
+ UPDATE_ROTATION = 1 << 3,
+ UPDATE_SPRITE = 1 << 4,
+ UPDATE_VELOCITY = 1 << 5,
+ };
+
+ ///
+ /// Default constructor.
+ ///
+ Particle();
+
+ ///
+ /// Reset to default.
+ ///
+ void reset();
+
+ ///
+ ///
+ ///
+ void update(float dt);
+
+ ///
+ ///
+ ///
+ void render();
+
+ // Methods end.
+
+ ParticleDef* def;
+
+ uint updateFlags = ParticleUpdateMask::NONE;
+
+ float lifeTime = 1.0f;
+
+ float life = 0.0f;
+
+ int spriteIndex = 0;
+
+ Color color = Color::WHITE;
+
+ Math::Transform transform;
+
+ Math::Vector2<float> velocity;
+ Math::Vector2<float> linearAcceleration;
+
+ float angularSpeed;
+ float radialAcceleration = 0;
+
+ bool alive = true;
+
+ };
+
+ } // namespace Particles
+ } // namespace Graphics
} // namespace JinEngine
#endif \ No newline at end of file