nCine::ParticleSystem class

Scene node that emits and simulates a pool of textured particles.

Owns a fixed pool of Particle child nodes that are recycled between alive and dead states. emitParticles() spawns particles from a ParticleInitializer, and each frame the attached ParticleAffector list animates every alive particle before it is drawn as part of the scene graph.

Base classes

class SceneNode
Base node of the scene graph transformation hierarchy.

Public static functions

static auto sType() -> ObjectType
Returns the static object type of the class.

Constructors, destructors, conversion operators

ParticleSystem(SceneNode* parent, std::uint32_t count, Texture* texture)
Constructs a particle system with the specified maximum amount of particles.
ParticleSystem(SceneNode* parent, std::uint32_t count, Texture* texture, Recti texRect)
Constructs a particle system with the specified maximum amount of particles and the specified texture rectangle.
~ParticleSystem() override
ParticleSystem(ParticleSystem&&)
ParticleSystem(const ParticleSystem& other) protected
Protected copy constructor used to clone objects.

Public functions

auto operator=(const ParticleSystem&) -> ParticleSystem& deleted
auto operator=(ParticleSystem&&) -> ParticleSystem&
auto clone() const -> ParticleSystem
Returns a copy of this object.
void addAffector(std::unique_ptr<ParticleAffector> affector)
Adds a particle affector, taking ownership of it.
void clearAffectors()
Deletes all particle affectors.
void emitParticles(const ParticleInitializer& init)
Emits particles with the specified initialization parameters.
void killParticles()
Kills all alive particles, returning them to the pool.
auto inLocalSpace() const -> bool
Returns whether the system is simulated in local space.
void setInLocalSpace(bool inLocalSpace)
Sets whether the system is simulated in local space.
auto numParticles() const -> std::uint32_t
Returns the total number of particles in the pool.
auto numAliveParticles() const -> std::uint32_t
Returns the number of particles currently alive.
void setTexture(Texture* texture)
Sets the texture object for every particle.
void setTexRect(const Recti& rect)
Sets the texture source rectangle for every particle.
void setAnchorPoint(float xx, float yy)
Sets the transformation anchor point for every particle.
void setAnchorPoint(Vector2f point)
Sets the transformation anchor point for every particle with a Vector2f.
void setFlippedX(bool flippedX)
Flips the texture rect horizontally for every particle.
void setFlippedY(bool flippedY)
Flips the texture rect vertically for every particle.
void setBlendingPreset(DrawableNode::BlendingPreset blendingPreset)
Sets the blending factors preset for every particle.
void setBlendingFactors(DrawableNode::BlendingFactor srcBlendingFactor, DrawableNode::BlendingFactor destBlendingFactor)
Sets the source and destination blending factors for every particle.
void setLayer(uint16_t layer)
Sets the rendering layer for every particle.
void OnUpdate(float timeMult) override
Called every frame to update the node state.