Represents a particle system
| 15 | |
| 16 | /// Represents a particle system |
| 17 | class ParticleSystem : public SceneNode |
| 18 | { |
| 19 | public: |
| 20 | /// Constructs a particle system with the specified maximum amount of particles |
| 21 | ParticleSystem(SceneNode* parent, std::uint32_t count, Texture* texture); |
| 22 | /// Constructs a particle system with the specified maximum amount of particles and the specified texture rectangle |
| 23 | ParticleSystem(SceneNode* parent, std::uint32_t count, Texture* texture, Recti texRect); |
| 24 | ~ParticleSystem() override; |
| 25 | |
| 26 | ParticleSystem& operator=(const ParticleSystem&) = delete; |
| 27 | ParticleSystem(ParticleSystem&&); |
| 28 | ParticleSystem& operator=(ParticleSystem&&); |
| 29 | |
| 30 | /// Returns a copy of this object |
| 31 | inline ParticleSystem clone() const { |
| 32 | return ParticleSystem(*this); |
| 33 | } |
| 34 | |
| 35 | /// Adds a particle affector |
| 36 | inline void addAffector(std::unique_ptr<ParticleAffector> affector) { |
| 37 | affectors_.push_back(affector.release()); |
| 38 | } |
| 39 | /// Deletes all particle affectors |
| 40 | void clearAffectors(); |
| 41 | /// Emits particles with the specified initialization parameters |
| 42 | void emitParticles(const ParticleInitializer& init); |
| 43 | /// Kills all alive particles |
| 44 | void killParticles(); |
| 45 | |
| 46 | /// Returns the local space flag of the system |
| 47 | inline bool inLocalSpace() const { |
| 48 | return inLocalSpace_; |
| 49 | } |
| 50 | /// Sets the local space flag of the system |
| 51 | inline void setInLocalSpace(bool inLocalSpace) { |
| 52 | inLocalSpace_ = inLocalSpace; |
| 53 | } |
| 54 | |
| 55 | /// Returns the total number of particles in the system |
| 56 | inline std::uint32_t numParticles() const { |
| 57 | return std::uint32_t(particleArray_.size()); |
| 58 | } |
| 59 | /// Returns the number of particles currently alive |
| 60 | inline std::uint32_t numAliveParticles() const { |
| 61 | return std::uint32_t(particleArray_.size()) - poolTop_ - 1; |
| 62 | } |
| 63 | |
| 64 | /// Sets the texture object for every particle |
| 65 | void setTexture(Texture* texture); |
| 66 | /// Sets the texture source rectangle for every particle |
| 67 | void setTexRect(const Recti& rect); |
| 68 | |
| 69 | /// Sets the transformation anchor point for every particle |
| 70 | void setAnchorPoint(float xx, float yy); |
| 71 | /// Sets the transformation anchor point for every particle with a `Vector2f` |
| 72 | void setAnchorPoint(Vector2f point); |
| 73 | |
| 74 | /// Flips the texture rect horizontally for every particle |