summaryrefslogtreecommitdiff
path: root/particle.h
diff options
context:
space:
mode:
Diffstat (limited to 'particle.h')
-rw-r--r--particle.h66
1 files changed, 66 insertions, 0 deletions
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 <list>
+
+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 T>
+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