f@0: #pragma once f@0: f@0: #include "cinder/gl/gl.h" f@0: #include f@0: f@3: /** f@3: * The ParticleController creates/updates/draws and destroys particles f@3: */ f@0: class ParticleController { f@0: f@0: struct Particle { f@0: f@0: ci::vec2 mCloudCenter; f@0: ci::vec2 mVel; f@0: float mCloudSize; f@0: f@0: int mAge; f@0: int mLifespan; f@0: bool mFlyOver; f@0: f@0: }; f@0: f@0: static const int kMaxParticles = 150; f@0: f@0: std::vector mParticles; f@0: std::vector< ci::vec2 > mParticlePositions; f@0: f@3: // current number of active particles f@0: size_t mNumParticles; f@0: f@0: ci::gl::VboRef mParticleVbo; f@0: ci::gl::BatchRef mParticleBatch; f@0: f@0: public: f@3: /** f@3: * Every time addParticles is run, up to kMaxParticleAdd are added at once f@3: */ f@0: static const int kMaxParticleAdd = 22; f@0: f@0: ParticleController(); f@3: f@3: /** f@3: * Adds \a amount particles and places them in \a initialLocation. f@3: * \cloudSize determines how far the particles can go f@3: */ f@0: void addParticles(int amount, const ci::vec2 &initialLocation, const float cloudSize); f@0: f@3: /** f@3: * Updates position and age of the particles f@3: */ f@0: void updateParticles(); f@0: f@3: /** f@3: * Draws all the particles f@3: */ f@0: inline void draw() f@0: { f@0: mParticleBatch->draw(); f@0: } f@0: f@0: }; f@0: