TDME2
1.9.121
src
tdme
engine
subsystems
particlesystem
PointParticleEmitter.cpp
Go to the documentation of this file.
1
#include <
tdme/engine/subsystems/particlesystem/PointParticleEmitter.h
>
2
3
#include <
tdme/tdme.h
>
4
#include <
tdme/engine/model/Color4.h
>
5
#include <
tdme/engine/model/Color4Base.h
>
6
#include <
tdme/engine/subsystems/particlesystem/Particle.h
>
7
#include <
tdme/engine/Transformations.h
>
8
#include <
tdme/math/Math.h
>
9
#include <
tdme/math/Matrix4x4.h
>
10
#include <
tdme/math/Vector3.h
>
11
12
using
tdme::engine::model::Color4
;
13
using
tdme::engine::model::Color4Base
;
14
using
tdme::engine::subsystems::particlesystem::Particle
;
15
using
tdme::engine::subsystems::particlesystem::PointParticleEmitter
;
16
using
tdme::engine::Transformations
;
17
using
tdme::math::Math
;
18
using
tdme::math::Matrix4x4
;
19
using
tdme::math::Vector3
;
20
21
PointParticleEmitter::PointParticleEmitter(int32_t count, int64_t lifeTime, int64_t lifeTimeRnd,
float
mass,
float
massRnd,
const
Vector3
& position,
const
Vector3
& velocity,
const
Vector3
& velocityRnd,
const
Color4
& colorStart,
const
Color4
& colorEnd)
22
{
23
this->count =
count
;
24
this->lifeTime =
lifeTime
;
25
this->lifeTimeRnd =
lifeTimeRnd
;
26
this->mass =
mass
;
27
this->massRnd =
massRnd
;
28
this->position.
set
(
position
);
29
this->
positionTransformed
.
set
(position);
30
this->velocity.
set
(
velocity
);
31
this->velocityRnd.
set
(
velocityRnd
);
32
this->colorStart.
set
(
colorStart
);
33
this->colorEnd.
set
(
colorEnd
);
34
}
35
36
void
PointParticleEmitter::emit
(
Particle
* particle)
37
{
38
// set up particle
39
particle->
active
=
true
;
40
particle->
spriteIndex
= 0.0f;
41
particle->
position
.
set
(0.0f, 0.0f, 0.0f);
42
particle->
velocity
.
set
(
43
velocity
[0] + (Math::random() *
velocityRnd
[0] * (Math::random() > 0.5 ? +1.0f : -1.0f)),
44
velocity
[1] + (Math::random() *
velocityRnd
[1] * (Math::random() > 0.5 ? +1.0f : -1.0f)),
45
velocity
[2] + (Math::random() *
velocityRnd
[2] * (Math::random() > 0.5 ? +1.0f : -1.0f))
46
);
47
particle->
mass
=
mass
+
static_cast<
float
>
((Math::random() * (
massRnd
)));
48
particle->
lifeTimeMax
=
lifeTime
+
static_cast<
int64_t
>
((Math::random() *
lifeTimeRnd
));
49
particle->
lifeTimeCurrent
= 0LL;
50
particle->
color
.
set
(
colorStart
);
51
particle->
colorAdd
.
set
(
52
(
colorEnd
.
getRed
() -
colorStart
.
getRed
()) / particle->
lifeTimeMax
,
53
(
colorEnd
.
getGreen
() -
colorStart
.
getGreen
()) / particle->
lifeTimeMax
,
54
(
colorEnd
.
getBlue
() -
colorStart
.
getBlue
()) / particle->
lifeTimeMax
,
55
(
colorEnd
.
getAlpha
() -
colorStart
.
getAlpha
()) / particle->
lifeTimeMax
56
);
57
}
58
59
void
PointParticleEmitter::fromTransformations
(
const
Transformations
& transformations)
60
{
61
//
62
auto
& transformationsMatrix = transformations.
getTransformationsMatrix
();
63
// apply translations
64
positionTransformed
= transformationsMatrix.multiply(
position
);
65
}
Color4Base.h
Color4.h
Math.h
Matrix4x4.h
Particle.h
PointParticleEmitter.h
Transformations.h
Vector3.h
tdme::engine::Transformations
Transformations which contain scale, rotations and translation.
Definition:
Transformations.h:27
tdme::engine::Transformations::getTransformationsMatrix
const Matrix4x4 & getTransformationsMatrix() const
Definition:
Transformations.h:169
tdme::engine::model::Color4Base
Color 4 base definition class.
Definition:
Color4Base.h:19
tdme::engine::model::Color4Base::set
void set(const array< float, 4 > &color)
Set up color.
Definition:
Color4Base.h:68
tdme::engine::model::Color4Base::getRed
float getRed() const
Definition:
Color4Base.h:111
tdme::engine::model::Color4Base::getGreen
float getGreen() const
Definition:
Color4Base.h:125
tdme::engine::model::Color4Base::getAlpha
float getAlpha() const
Definition:
Color4Base.h:153
tdme::engine::model::Color4Base::getBlue
float getBlue() const
Definition:
Color4Base.h:139
tdme::engine::model::Color4
Color 4 definition.
Definition:
Color4.h:20
tdme::engine::subsystems::particlesystem::PointParticleEmitter
Point particle emitter.
Definition:
PointParticleEmitter.h:26
tdme::engine::subsystems::particlesystem::PointParticleEmitter::colorEnd
Color4 colorEnd
Definition:
PointParticleEmitter.h:39
tdme::engine::subsystems::particlesystem::PointParticleEmitter::count
int32_t count
Definition:
PointParticleEmitter.h:28
tdme::engine::subsystems::particlesystem::PointParticleEmitter::velocityRnd
Vector3 velocityRnd
Definition:
PointParticleEmitter.h:36
tdme::engine::subsystems::particlesystem::PointParticleEmitter::velocity
Vector3 velocity
Definition:
PointParticleEmitter.h:35
tdme::engine::subsystems::particlesystem::PointParticleEmitter::colorStart
Color4 colorStart
Definition:
PointParticleEmitter.h:38
tdme::engine::subsystems::particlesystem::PointParticleEmitter::lifeTimeRnd
int64_t lifeTimeRnd
Definition:
PointParticleEmitter.h:30
tdme::engine::subsystems::particlesystem::PointParticleEmitter::fromTransformations
void fromTransformations(const Transformations &transformations) override
Update transformation with given transformations.
Definition:
PointParticleEmitter.cpp:59
tdme::engine::subsystems::particlesystem::PointParticleEmitter::mass
float mass
Definition:
PointParticleEmitter.h:31
tdme::engine::subsystems::particlesystem::PointParticleEmitter::lifeTime
int64_t lifeTime
Definition:
PointParticleEmitter.h:29
tdme::engine::subsystems::particlesystem::PointParticleEmitter::position
Vector3 position
Definition:
PointParticleEmitter.h:33
tdme::engine::subsystems::particlesystem::PointParticleEmitter::emit
void emit(Particle *particle) override
Emits particles.
Definition:
PointParticleEmitter.cpp:36
tdme::engine::subsystems::particlesystem::PointParticleEmitter::massRnd
float massRnd
Definition:
PointParticleEmitter.h:32
tdme::engine::subsystems::particlesystem::PointParticleEmitter::positionTransformed
Vector3 positionTransformed
Definition:
PointParticleEmitter.h:34
tdme::math::Math
Standard math functions.
Definition:
Math.h:21
tdme::math::Matrix4x4
4x4 3D Matrix class
Definition:
Matrix4x4.h:24
tdme::math::Vector3
3D vector 3 class
Definition:
Vector3.h:22
tdme::math::Vector3::set
Vector3 & set(float x, float y, float z)
Set up vector.
Definition:
Vector3.h:73
tdme::engine::subsystems::particlesystem::Particle
Particle entity.
Definition:
Particle.h:20
tdme::engine::subsystems::particlesystem::Particle::active
bool active
Definition:
Particle.h:21
tdme::engine::subsystems::particlesystem::Particle::colorAdd
Color4 colorAdd
Definition:
Particle.h:29
tdme::engine::subsystems::particlesystem::Particle::velocity
Vector3 velocity
Definition:
Particle.h:23
tdme::engine::subsystems::particlesystem::Particle::mass
float mass
Definition:
Particle.h:25
tdme::engine::subsystems::particlesystem::Particle::lifeTimeCurrent
int64_t lifeTimeCurrent
Definition:
Particle.h:27
tdme::engine::subsystems::particlesystem::Particle::spriteIndex
float spriteIndex
Definition:
Particle.h:22
tdme::engine::subsystems::particlesystem::Particle::lifeTimeMax
int64_t lifeTimeMax
Definition:
Particle.h:26
tdme::engine::subsystems::particlesystem::Particle::position
Vector3 position
Definition:
Particle.h:24
tdme::engine::subsystems::particlesystem::Particle::color
Color4 color
Definition:
Particle.h:28
tdme.h
Generated by
1.9.3