#include "particle.h" #include float SelectionParticle::t = 0; SelectionParticle::SelectionParticle() { init(t += .1); } SelectionParticle::SelectionParticle(const SelectionParticle& p) { pos = p.pos; vel = p.vel; alpha = p.alpha; decay = p.decay; } void SelectionParticle::init(float seed) { pt = seed; speed = .0005 + fmodf(seed, .001); speed = .001 + fmodf(seed, .002); alpha = 1.0; decay = 0.001 * ((rand() % 5 + 5) / 20.0); pos = Vector3(cosf(rand()), 0, sinf(rand())); //pos = Vector3(cosf(seed), 0, sinf(seed)); //p.pos = src; //p.pos.x *= ((rand() % 20 + 10) / vel = Vector3(cosf(rand()), 10, sinf(rand())); vel /= vel.length();// * ((rand() % 10 + 5) / 10); } void SelectionParticle::update(unsigned int steps, vec4f *v) { pt += speed * steps; alpha -= decay * steps; if(alpha <= 0) { init(t += 0.1); return; } else { pos += vel * (steps / 1000.0); pos.y += vel.y * (steps / 1000.0); //it->vel += Vector3(0, -.1, 0) * (steps / 1000.0); } //update(steps); //vec4f *v = &vertices[i]; //v->x = pos.x * cosf(t * (i+1) / 800); v->x = pos.x * cosf(pt); v->y = pos.y; //v->z = pos.z * sinf(t * (i+1) / 800); v->z = pos.z * sinf(pt); v->w = alpha; }