annotate CollidoscopeApp/include/ParticleController.h @ 3:7fb593d53361

added comments
author Fiore Martin <f.martin@qmul.ac.uk>
date Tue, 12 Jul 2016 18:29:38 +0200
parents 02467299402e
children ab6db404403a
rev   line source
f@0 1 #pragma once
f@0 2
f@0 3 #include "cinder/gl/gl.h"
f@0 4 #include <vector>
f@0 5
f@3 6 /**
f@3 7 * The ParticleController creates/updates/draws and destroys particles
f@3 8 */
f@0 9 class ParticleController {
f@0 10
f@0 11 struct Particle {
f@0 12
f@0 13 ci::vec2 mCloudCenter;
f@0 14 ci::vec2 mVel;
f@0 15 float mCloudSize;
f@0 16
f@0 17 int mAge;
f@0 18 int mLifespan;
f@0 19 bool mFlyOver;
f@0 20
f@0 21 };
f@0 22
f@0 23 static const int kMaxParticles = 150;
f@0 24
f@0 25 std::vector<Particle> mParticles;
f@0 26 std::vector< ci::vec2 > mParticlePositions;
f@0 27
f@3 28 // current number of active particles
f@0 29 size_t mNumParticles;
f@0 30
f@0 31 ci::gl::VboRef mParticleVbo;
f@0 32 ci::gl::BatchRef mParticleBatch;
f@0 33
f@0 34 public:
f@3 35 /**
f@3 36 * Every time addParticles is run, up to kMaxParticleAdd are added at once
f@3 37 */
f@0 38 static const int kMaxParticleAdd = 22;
f@0 39
f@0 40 ParticleController();
f@3 41
f@3 42 /**
f@3 43 * Adds \a amount particles and places them in \a initialLocation.
f@3 44 * \cloudSize determines how far the particles can go
f@3 45 */
f@0 46 void addParticles(int amount, const ci::vec2 &initialLocation, const float cloudSize);
f@0 47
f@3 48 /**
f@3 49 * Updates position and age of the particles
f@3 50 */
f@0 51 void updateParticles();
f@0 52
f@3 53 /**
f@3 54 * Draws all the particles
f@3 55 */
f@0 56 inline void draw()
f@0 57 {
f@0 58 mParticleBatch->draw();
f@0 59 }
f@0 60
f@0 61 };
f@0 62