aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/particles/je_particle.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-11-18 23:45:58 +0800
committerchai <chaifix@163.com>2018-11-18 23:45:58 +0800
commit4279e16ddb6273a9711ff331d21325dd5f63e769 (patch)
tree0d7ff12807fba478134f3bf9e01fd474c3a0b510 /src/libjin/Graphics/particles/je_particle.cpp
parent8cb74178c2b8e5883a1181af687fa8cfc0c6e5da (diff)
*修改目录为小写
Diffstat (limited to 'src/libjin/Graphics/particles/je_particle.cpp')
-rw-r--r--src/libjin/Graphics/particles/je_particle.cpp72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/libjin/Graphics/particles/je_particle.cpp b/src/libjin/Graphics/particles/je_particle.cpp
deleted file mode 100644
index 53f4570..0000000
--- a/src/libjin/Graphics/particles/je_particle.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-#include "../../math/je_math.h"
-
-#include "je_particle.h"
-
-using namespace JinEngine::Math;
-
-namespace JinEngine
-{
- namespace Graphics
- {
- namespace Particles
- {
-
- Particle::Particle(const Graphic* grc)
- : graphic(grc)
- {
- reset();
- }
-
- void Particle::reset()
- {
- transform.set(0, 0, 1, 1, 0, 0, 0);
- lifeTime = 1.0f;
- life = 0.0f;
- speed.set(0, 0);
- linearAcceleration.set(0, 0);
- radialAcceleration = 0.0f;
- angularSpeed = 0;
- scaleBegin = 1;
- scaleEnd = 1;
- color = Color::WHITE;
- colorStart = Color::WHITE;
- colorEnd = Color::WHITE;
- alive = true;
- }
-
- void Particle::update(float dt)
- {
- float t = life / lifeTime;
- // Lerp color
- color.r = lerp<int>(colorStart.r, colorEnd.r, t);
- color.g = lerp<int>(colorStart.g, colorEnd.g, t);
- color.b = lerp<int>(colorStart.b, colorEnd.b, t);
- color.a = lerp<int>(colorStart.a, colorEnd.a, t);
- // Lerp scale.
- Vector2<float> scale = transform.getScale();
- scale.x = lerp<float>(scaleBegin, scaleEnd, t);
- scale.y = scale.x;
- transform.setScale(scale.x, scale.y);
- // Calculate position.
- speed += linearAcceleration * dt;
- transform.move(speed * dt);
- // Calculate rotation.
- angularSpeed += radialAcceleration * dt;
- transform.rotate(angularSpeed * dt);
- // Update life time.
- life += dt;
- alive = life < lifeTime;
- }
-
- void Particle::render()
- {
- Color c = gl.getColor();
- gl.setColor(color);
- if (graphic != nullptr)
- graphic->render(transform);
- gl.getColor();
- }
-
- }
- }
-} \ No newline at end of file