To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / CollidoscopeApp / include / ParticleController.h @ 2:dd889fff8423
History | View | Annotate | Download (781 Bytes)
| 1 |
#pragma once
|
|---|---|
| 2 |
|
| 3 |
#include "cinder/gl/gl.h" |
| 4 |
#include <vector> |
| 5 |
|
| 6 |
|
| 7 |
class ParticleController {
|
| 8 |
|
| 9 |
struct Particle {
|
| 10 |
|
| 11 |
ci::vec2 mCloudCenter; |
| 12 |
ci::vec2 mVel; |
| 13 |
float mCloudSize;
|
| 14 |
|
| 15 |
int mAge;
|
| 16 |
int mLifespan;
|
| 17 |
bool mFlyOver;
|
| 18 |
|
| 19 |
}; |
| 20 |
|
| 21 |
static const int kMaxParticles = 150; |
| 22 |
|
| 23 |
std::vector<Particle> mParticles; |
| 24 |
std::vector< ci::vec2 > mParticlePositions; |
| 25 |
|
| 26 |
size_t mNumParticles; |
| 27 |
|
| 28 |
ci::gl::VboRef mParticleVbo; |
| 29 |
ci::gl::BatchRef mParticleBatch; |
| 30 |
|
| 31 |
public:
|
| 32 |
static const int kMaxParticleAdd = 22; |
| 33 |
|
| 34 |
ParticleController(); |
| 35 |
void addParticles(int amount, const ci::vec2 &initialLocation, const float cloudSize); |
| 36 |
|
| 37 |
void updateParticles();
|
| 38 |
|
| 39 |
inline void draw() |
| 40 |
{
|
| 41 |
mParticleBatch->draw(); |
| 42 |
} |
| 43 |
|
| 44 |
}; |
| 45 |
|