From 611f07a2e6dbfa64c5467022949c7ce938fc09f4 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sat, 16 Apr 2011 17:04:18 +0200 Subject: wip --- particle.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 particle.h (limited to 'particle.h') diff --git a/particle.h b/particle.h new file mode 100644 index 0000000..433b557 --- /dev/null +++ b/particle.h @@ -0,0 +1,66 @@ +#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 -- cgit v1.2.3