25 using std::make_unique;
27 using std::unique_ptr;
48 FogParticleSystemInternal::FogParticleSystemInternal(
const string&
id,
ParticleEmitter* emitter, int32_t maxPoints,
float pointSize,
Texture* texture, int32_t textureHorizontalSprites, int32_t textureVerticalSprites,
float fps)
54 this->emitter = unique_ptr<ParticleEmitter>(
emitter);
66 this->texture =
texture !=
nullptr?
texture:TextureReader::read(
"resources/engine/textures",
"point.png");
89 for (
auto i = 0; i <
particles.size(); i++) {
97 float distanceFromCamera;
101 auto activeParticles = 0;
102 for (
auto i = 0; i <
particles.size(); i++) {
104 if (particle.active ==
false)
continue;
110 int64_t timeRnd = (int64_t)(Math::random() * (float)particle.lifeTimeMax);
111 auto& color = particle.color;
112 const auto& colorAdd = particle.colorAdd;
113 color[0] += colorAdd[0] *
static_cast<float>(timeRnd);
114 color[1] += colorAdd[1] *
static_cast<float>(timeRnd);
115 color[2] += colorAdd[2] *
static_cast<float>(timeRnd);
116 color[3] += colorAdd[3] *
static_cast<float>(timeRnd);
119 point = localTransformMatrix.multiply(particle.position);
123 if (first ==
false) {
133 if (activeParticles == 0) {
181 auto activeParticles = 0;
183 for (
auto i = 0; i <
particles.size(); i++) {
185 if (particle.active ==
false)
continue;
187 particle.spriteIndex+= (
static_cast<float>(timeDelta) / 1000.0f) *
fps;
191 point = localTransformMatrix.multiply(particle.position);
195 if (first ==
false) {
208 if (activeParticles == 0) {
Color 4 definition class.
void set(float r, float g, float b, float a)
Sets this color by its components.
int64_t getDeltaTime()
Gets the time passed between last and current frame.
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
void extend(BoundingBox *boundingBox)
Extend bounding box with given bounding box.
void fromBoundingVolumeWithTransformMatrix(BoundingBox *original, const Matrix4x4 &transformMatrix)
Create bounding volume from given original(of same type) with applied transform matrix.
void update()
Updates this bounding box.
void updateParticles() override
Updates the particle entity.
virtual ~FogParticleSystemInternal()
Destructor.
Transform parentTransform
unique_ptr< ParticleEmitter > emitter
void initialize()
Initialize.
BoundingBox worldBoundingBox
int32_t textureHorizontalSprites
unique_ptr< TransparentRenderPointsPool > pointsRenderPool
void update() override
Update transform.
vector< Particle > particles
int32_t textureVerticalSprites
Matrix4x4 entityTransformMatrix
void setTransform(const Transform &transform) override
Set transform.
void updateInternal()
Update bounding volume.
Transparent render points pool.
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Matrix4x4 & identity()
Creates identity matrix.
Vector3 multiply(const Vector3 &vector3) const
Multiplies this matrix with vector3.
void getTranslation(Vector3 &translation) const
Get translation.
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Vector3 & add(float scalar)
Adds a scalar.
Vector3 & sub(float scalar)
Subtracts a scalar.
Vector3 & set(float x, float y, float z)
Sets this vector3 by its components.
virtual void releaseReference()
Releases a reference, thus decrementing the counter and delete it if reference counter is zero.
Particle emitter interface.
Particle system entity internal interface.