blob: 9e0b130d4fe5310d051c11ee95445b6b3d739dde (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include "particle.h"
#include <cmath>
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;
}
|