#ifndef PARTICLE_H #define PARTICLE_H #include "vector.h" #include struct vec4f { float x, y, z, w; }; class SelectionParticle { public: Vector3 pos; float alpha; float decay; static float t; float pt; float speed; Vector3 vel; SelectionParticle(); SelectionParticle(const SelectionParticle& p); void init(float seed); void update(unsigned int steps, vec4f *v); }; template class ParticleGroup { public: T *particles; vec4f *vertices; unsigned int num; unsigned int count; Vector3 src; Vector3 dir; ParticleGroup(Vector3 src, Vector3 dir, unsigned int count) { srand(time(NULL)); this->src = src; this->dir = dir; this->num = count; this->count = 0; T::t = 0; particles = new T[count]; vertices = new vec4f[count]; }; ~ParticleGroup() { delete[] particles; delete[] vertices; } void update(unsigned int steps) { if(count < num) { particles[count].init(T::t += 0.1); count++; } for(unsigned int i = 0; i < count; i++) { T *p = &particles[i]; p->update(steps, &vertices[i]); } } }; #endif