aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/particles/je_particle.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/Graphics/particles/je_particle.h')
-rw-r--r--src/libjin/Graphics/particles/je_particle.h124
1 files changed, 56 insertions, 68 deletions
diff --git a/src/libjin/Graphics/particles/je_particle.h b/src/libjin/Graphics/particles/je_particle.h
index 2d112d1..70a2653 100644
--- a/src/libjin/Graphics/particles/je_particle.h
+++ b/src/libjin/Graphics/particles/je_particle.h
@@ -1,8 +1,10 @@
#ifndef __JE_PARTICLE_H__
#define __JE_PARTICLE_H__
+#include "../../math/je_transform.h"
#include "../../math/je_vector2.hpp"
#include "../je_color.h"
+#include "../je_graphic.h"
namespace JinEngine
{
@@ -19,56 +21,20 @@ namespace JinEngine
struct LifeTimeDef
{
bool enableRandom = false;
- union
- {
- struct
- {
- float min, max;
- } random;
- float life;
- } life;
- };
-
- ///
- ///
- ///
- struct SpeedOverTimeDef
- {
- bool enable = false;
- bool enableRandom = false;
- union
- {
+ Struct(life,
struct
{
- Math::Vector2<float> startFloor;
- Math::Vector2<float> startCeil;
- Math::Vector2<float> endFloor;
- Math::Vector2<float> endCeil;
+ float floor, ceil;
} random;
- struct
- {
- Math::Vector2<float> start;
- Math::Vector2<float> end;
- } speed;
- } speed;
+ float life = 1.0f;
+ );
};
- struct SizeOverTimeDef
+ struct ScaleOverTimeDef
{
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;
+ float start = 1;
+ float end = 1;
};
struct ColorOverTimeDef
@@ -85,7 +51,20 @@ namespace JinEngine
struct RadialAccelarationDef
{
- float radialAccelaration;
+ float radialAccelaration = 0.f;
+ };
+
+ struct AngularSpeedDef
+ {
+ bool enableRandom = false;
+ Struct(angularSpeed,
+ struct
+ {
+ float floor = 0;
+ float ceil = 0;
+ } random;
+ float angularSpeed = 0;
+ );
};
///
@@ -101,22 +80,22 @@ namespace JinEngine
LifeTimeDef lifeTimeDef; ///<
linearAccelarationDef linearAccelarationDef; ///<
RadialAccelarationDef radialAccelarationDef; ///<
+ AngularSpeedDef angularSpeedDef; ///<
// Optional definitions.
- SpeedOverTimeDef speedOverTimeDef; ///<
- SizeOverTimeDef sizeOverTimeDef; ///<
+ ScaleOverTimeDef sizeOverTimeDef; ///<
ColorOverTimeDef colorOverTimeDef; ///<
};
///
- /// A single particle contains various properties of particle, such as position, accelaration, color and
- /// other attributes changed over time.
+ /// A single particle contains various properties of particle, such as position, accelaration, color
+ /// and other attributes changed over time.
///
struct Particle
{
///
/// Default constructor.
///
- Particle() {};
+ Particle(const Graphic* graphic);
///
/// Reset to default.
@@ -124,45 +103,54 @@ namespace JinEngine
void reset();
///
+ ///
+ ///
+ void update(float dt);
+
+ ///
+ ///
+ ///
+ void render();
+
+ //////////////////////////////////////////////////////////////////////////////////////////////////
+
+ ///
/// Whole life time.
///
- float lifeTime = 0.0f;
+ float lifeTime = 1.0f;
///
/// Current life time.
///
float life = 0.0f;
+ const Graphic* graphic;
+
///
- /// Current position.
+ /// Color over lifetime.
///
- Math::Vector2<float> position;
+ Color color = Color::WHITE;
+ Color colorStart = Color::WHITE;
+ Color colorEnd = Color::WHITE;
///
- /// Emitte direction.
- ///
- float direction = 0;
+ /// Position scale rotation origin.
+ ///
+ Math::Transform transform;
+ ///
+ /// Speeds.
+ ///
Math::Vector2<float> speed;
Math::Vector2<float> linearAcceleration;
+ float angularSpeed;
float radialAcceleration = 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;
+ float scaleBegin = 1;
+ float scaleEnd = 1;
///
/// Is particle still alive? Alive is equivalent to NOT available in particle pool.