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
|
// renderparticles.cpp
#include "cube.h"
const int MAXPARTICLES = 10500;
const int NUMPARTCUTOFF = 20;
struct particle {
vec o, d;
int fade, type;
int millis;
particle *next;
};
particle particles[MAXPARTICLES], *parlist = NULL, *parempty = NULL;
bool parinit = false;
VARP(maxparticles, 100, 2000, MAXPARTICLES - 500);
void
newparticle(vec &o, vec &d, int fade, int type)
{
if (!parinit) {
loopi(MAXPARTICLES)
{
particles[i].next = parempty;
parempty = &particles[i];
};
|
|
|
|
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
|
// renderparticles.cpp
#include "cube.h"
const int MAXPARTICLES = 10500;
const int NUMPARTCUTOFF = 20;
struct particle {
OFVector3D o, d;
int fade, type;
int millis;
particle *next;
};
particle particles[MAXPARTICLES], *parlist = NULL, *parempty = NULL;
bool parinit = false;
VARP(maxparticles, 100, 2000, MAXPARTICLES - 500);
void
newparticle(OFVector3D &o, OFVector3D &d, int fade, int type)
{
if (!parinit) {
loopi(MAXPARTICLES)
{
particles[i].next = parempty;
parempty = &particles[i];
};
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
parlist = p;
};
};
VAR(demotracking, 0, 0, 1);
VARP(particlesize, 20, 100, 500);
vec right, up;
void
setorient(vec &r, vec &u)
{
right = r;
up = u;
};
void
render_particles(int time)
{
if (demoplayback && demotracking) {
vec nom = {0, 0, 0};
newparticle(player1->o, nom, 100000000, 8);
};
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA);
glDisable(GL_FOG);
struct parttype {
|
|
|
<
>
|
<
>
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
parlist = p;
};
};
VAR(demotracking, 0, 0, 1);
VARP(particlesize, 20, 100, 500);
OFVector3D right, up;
void
setorient(OFVector3D &r, OFVector3D &u)
{
right = r;
up = u;
}
void
render_particles(int time)
{
if (demoplayback && demotracking) {
OFVector3D nom = OFMakeVector3D(0, 0, 0);
newparticle(player1->o, nom, 100000000, 8);
}
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA);
glDisable(GL_FOG);
struct parttype {
|
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
*pp = p->next;
p->next = parempty;
parempty = p;
} else {
if (pt->gr)
p->o.z -= ((lastmillis - p->millis) / 3.0f) *
curtime / (pt->gr * 10000);
vec a = p->d;
vmul(a, time);
vdiv(a, 20000.0f);
vadd(p->o, a);
pp = &p->next;
};
};
glEnable(GL_FOG);
glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
};
void
particle_splash(int type, int num, int fade, vec &p)
{
loopi(num)
{
const int radius = type == 5 ? 50 : 150;
int x, y, z;
do {
x = rnd(radius * 2) - radius;
y = rnd(radius * 2) - radius;
z = rnd(radius * 2) - radius;
} while (x * x + y * y + z * z > radius * radius);
vec d = {(float)x, (float)y, (float)z};
newparticle(p, d, rnd(fade * 3), type);
};
};
void
particle_trail(int type, int fade, vec &s, vec &e)
{
vdist(d, v, s, e);
vdiv(v, d * 2 + 0.1f);
vec p = s;
loopi((int)d * 2)
{
vadd(p, v);
vec d = {
float(rnd(11) - 5), float(rnd(11) - 5), float(rnd(11) - 5)};
newparticle(p, d, rnd(fade) + fade, type);
};
};
|
|
<
<
>
>
|
|
<
<
|
>
>
|
|
|
|
<
<
>
>
|
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
*pp = p->next;
p->next = parempty;
parempty = p;
} else {
if (pt->gr)
p->o.z -= ((lastmillis - p->millis) / 3.0f) *
curtime / (pt->gr * 10000);
OFVector3D a = p->d;
vmul(a, time);
vdiv(a, 20000.0f);
vadd(p->o, a);
pp = &p->next;
}
}
glEnable(GL_FOG);
glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
};
void
particle_splash(int type, int num, int fade, OFVector3D &p)
{
loopi(num)
{
const int radius = type == 5 ? 50 : 150;
int x, y, z;
do {
x = rnd(radius * 2) - radius;
y = rnd(radius * 2) - radius;
z = rnd(radius * 2) - radius;
} while (x * x + y * y + z * z > radius * radius);
OFVector3D d = OFMakeVector3D(x, y, z);
newparticle(p, d, rnd(fade * 3), type);
}
}
void
particle_trail(int type, int fade, OFVector3D &s, OFVector3D &e)
{
vdist(d, v, s, e);
vdiv(v, d * 2 + 0.1f);
OFVector3D p = s;
loopi((int)d * 2)
{
vadd(p, v);
OFVector3D d =
OFMakeVector3D(rnd(11) - 5, rnd(11) - 5, rnd(11) - 5);
newparticle(p, d, rnd(fade) + fade, type);
}
}
|