aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/graphics/particles/je_particle.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-01-12 21:48:33 +0800
committerchai <chaifix@163.com>2019-01-12 21:48:33 +0800
commit8b00d67febf133e89f6a0bfabc41feed555dc4a9 (patch)
treefe48ef17c250afa40c2588300fcdb5920dba6951 /src/libjin/graphics/particles/je_particle.h
parenta907c39756ef6b368d06643afa491c49a9044a8e (diff)
*去掉文件前缀je_
Diffstat (limited to 'src/libjin/graphics/particles/je_particle.h')
-rw-r--r--src/libjin/graphics/particles/je_particle.h222
1 files changed, 0 insertions, 222 deletions
diff --git a/src/libjin/graphics/particles/je_particle.h b/src/libjin/graphics/particles/je_particle.h
deleted file mode 100644
index 2b5966b..0000000
--- a/src/libjin/graphics/particles/je_particle.h
+++ /dev/null
@@ -1,222 +0,0 @@
-#ifndef __JE_PARTICLE_H__
-#define __JE_PARTICLE_H__
-
-#include "../../game/je_gameobject.h"
-#include "../../math/je_ranged_value.h"
-#include "../../math/je_transform.h"
-#include "../../math/je_vector2.hpp"
-#include "../../math/je_percentage.h"
-
-#include "../je_color.h"
-#include "../je_sprite.h"
-
-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 JinEngine
-
-#endif \ No newline at end of file