| 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 |
#include "cg_local.h" |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
#define BLOODRED 2 |
| 30 |
#define EMISIVEFADE 3 |
| 31 |
#define GREY75 4 |
| 32 |
|
| 33 |
typedef struct particle_s |
| 34 |
{ |
| 35 |
struct particle_s *next; |
| 36 |
|
| 37 |
float time; |
| 38 |
float endtime; |
| 39 |
|
| 40 |
vec3_t org; |
| 41 |
vec3_t vel; |
| 42 |
vec3_t accel; |
| 43 |
int color; |
| 44 |
float colorvel; |
| 45 |
float alpha; |
| 46 |
float alphavel; |
| 47 |
int type; |
| 48 |
qhandle_t pshader; |
| 49 |
|
| 50 |
float height; |
| 51 |
float width; |
| 52 |
|
| 53 |
float endheight; |
| 54 |
float endwidth; |
| 55 |
|
| 56 |
float start; |
| 57 |
float end; |
| 58 |
|
| 59 |
float startfade; |
| 60 |
qboolean rotate; |
| 61 |
int snum; |
| 62 |
|
| 63 |
qboolean link; |
| 64 |
|
| 65 |
|
| 66 |
int shaderAnim; |
| 67 |
int roll; |
| 68 |
|
| 69 |
int accumroll; |
| 70 |
|
| 71 |
} cparticle_t; |
| 72 |
|
| 73 |
typedef enum |
| 74 |
{ |
| 75 |
P_NONE, |
| 76 |
P_WEATHER, |
| 77 |
P_FLAT, |
| 78 |
P_SMOKE, |
| 79 |
P_ROTATE, |
| 80 |
P_WEATHER_TURBULENT, |
| 81 |
P_ANIM, |
| 82 |
P_BAT, |
| 83 |
P_BLEED, |
| 84 |
P_FLAT_SCALEUP, |
| 85 |
P_FLAT_SCALEUP_FADE, |
| 86 |
P_WEATHER_FLURRY, |
| 87 |
P_SMOKE_IMPACT, |
| 88 |
P_BUBBLE, |
| 89 |
P_BUBBLE_TURBULENT, |
| 90 |
P_SPRITE |
| 91 |
} particle_type_t; |
| 92 |
|
| 93 |
#define MAX_SHADER_ANIMS 32 |
| 94 |
#define MAX_SHADER_ANIM_FRAMES 64 |
| 95 |
|
| 96 |
#ifndef WOLF_PARTICLES |
| 97 |
static char *shaderAnimNames[MAX_SHADER_ANIMS] = { |
| 98 |
"explode1", |
| 99 |
NULL |
| 100 |
}; |
| 101 |
static qhandle_t shaderAnims[MAX_SHADER_ANIMS][MAX_SHADER_ANIM_FRAMES]; |
| 102 |
static int shaderAnimCounts[MAX_SHADER_ANIMS] = { |
| 103 |
23 |
| 104 |
}; |
| 105 |
static float shaderAnimSTRatio[MAX_SHADER_ANIMS] = { |
| 106 |
1.0f |
| 107 |
}; |
| 108 |
static int numShaderAnims; |
| 109 |
|
| 110 |
#else |
| 111 |
static char *shaderAnimNames[MAX_SHADER_ANIMS] = { |
| 112 |
"explode1", |
| 113 |
"blacksmokeanim", |
| 114 |
"twiltb2", |
| 115 |
"expblue", |
| 116 |
"blacksmokeanimb", |
| 117 |
"blood", |
| 118 |
NULL |
| 119 |
}; |
| 120 |
static qhandle_t shaderAnims[MAX_SHADER_ANIMS][MAX_SHADER_ANIM_FRAMES]; |
| 121 |
static int shaderAnimCounts[MAX_SHADER_ANIMS] = { |
| 122 |
23, |
| 123 |
25, |
| 124 |
45, |
| 125 |
25, |
| 126 |
23, |
| 127 |
5, |
| 128 |
}; |
| 129 |
static float shaderAnimSTRatio[MAX_SHADER_ANIMS] = { |
| 130 |
1.405f, |
| 131 |
1.0f, |
| 132 |
1.0f, |
| 133 |
1.0f, |
| 134 |
1.0f, |
| 135 |
1.0f, |
| 136 |
}; |
| 137 |
#endif |
| 138 |
|
| 139 |
#define PARTICLE_GRAVITY 40 |
| 140 |
|
| 141 |
#ifdef WOLF_PARTICLES |
| 142 |
#define MAX_PARTICLES 1024 * 8 |
| 143 |
#else |
| 144 |
#define MAX_PARTICLES 1024 |
| 145 |
#endif |
| 146 |
|
| 147 |
cparticle_t *active_particles, *free_particles; |
| 148 |
cparticle_t particles[MAX_PARTICLES]; |
| 149 |
int cl_numparticles = MAX_PARTICLES; |
| 150 |
|
| 151 |
qboolean initparticles = qfalse; |
| 152 |
vec3_t vforward, vright, vup; |
| 153 |
vec3_t rforward, rright, rup; |
| 154 |
|
| 155 |
float oldtime; |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
void CG_ClearParticles (void) |
| 163 |
{ |
| 164 |
int i; |
| 165 |
|
| 166 |
memset( particles, 0, sizeof(particles) ); |
| 167 |
|
| 168 |
free_particles = &particles[0]; |
| 169 |
active_particles = NULL; |
| 170 |
|
| 171 |
for (i=0 ;i<cl_numparticles ; i++) |
| 172 |
{ |
| 173 |
particles[i].next = &particles[i+1]; |
| 174 |
particles[i].type = 0; |
| 175 |
} |
| 176 |
particles[cl_numparticles-1].next = NULL; |
| 177 |
|
| 178 |
oldtime = cg.time; |
| 179 |
|
| 180 |
|
| 181 |
for (i=0; shaderAnimNames[i]; i++) { |
| 182 |
int j; |
| 183 |
|
| 184 |
for (j=0; j<shaderAnimCounts[i]; j++) { |
| 185 |
shaderAnims[i][j] = trap_R_RegisterShader( va("%s%i", shaderAnimNames[i], j+1) ); |
| 186 |
} |
| 187 |
} |
| 188 |
numShaderAnims = i; |
| 189 |
|
| 190 |
|
| 191 |
initparticles = qtrue; |
| 192 |
} |
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
void CG_AddParticleToScene (cparticle_t *p, vec3_t org, float alpha) |
| 201 |
{ |
| 202 |
|
| 203 |
vec3_t point; |
| 204 |
polyVert_t verts[4]; |
| 205 |
float width; |
| 206 |
float height; |
| 207 |
float time, time2; |
| 208 |
float ratio; |
| 209 |
float invratio; |
| 210 |
vec3_t color; |
| 211 |
polyVert_t TRIverts[3]; |
| 212 |
vec3_t rright2, rup2; |
| 213 |
|
| 214 |
if (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY |
| 215 |
|| p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) |
| 216 |
{ |
| 217 |
|
| 218 |
if (p->type != P_WEATHER_FLURRY) |
| 219 |
{ |
| 220 |
if (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) |
| 221 |
{ |
| 222 |
if (org[2] > p->end) |
| 223 |
{ |
| 224 |
p->time = cg.time; |
| 225 |
VectorCopy (org, p->org); |
| 226 |
|
| 227 |
p->org[2] = ( p->start + crandom () * 4 ); |
| 228 |
|
| 229 |
|
| 230 |
if (p->type == P_BUBBLE_TURBULENT) |
| 231 |
{ |
| 232 |
p->vel[0] = crandom() * 4; |
| 233 |
p->vel[1] = crandom() * 4; |
| 234 |
} |
| 235 |
|
| 236 |
} |
| 237 |
} |
| 238 |
else |
| 239 |
{ |
| 240 |
if (org[2] < p->end) |
| 241 |
{ |
| 242 |
p->time = cg.time; |
| 243 |
VectorCopy (org, p->org); |
| 244 |
|
| 245 |
while (p->org[2] < p->end) |
| 246 |
{ |
| 247 |
p->org[2] += (p->start - p->end); |
| 248 |
} |
| 249 |
|
| 250 |
|
| 251 |
if (p->type == P_WEATHER_TURBULENT) |
| 252 |
{ |
| 253 |
p->vel[0] = crandom() * 16; |
| 254 |
p->vel[1] = crandom() * 16; |
| 255 |
} |
| 256 |
|
| 257 |
} |
| 258 |
} |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
if (!p->link) |
| 263 |
return; |
| 264 |
|
| 265 |
p->alpha = 1; |
| 266 |
} |
| 267 |
|
| 268 |
|
| 269 |
if (Distance( cg.snap->ps.origin, org ) > 1024) { |
| 270 |
return; |
| 271 |
} |
| 272 |
|
| 273 |
|
| 274 |
if (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) |
| 275 |
{ |
| 276 |
VectorMA (org, -p->height, vup, point); |
| 277 |
VectorMA (point, -p->width, vright, point); |
| 278 |
VectorCopy (point, verts[0].xyz); |
| 279 |
verts[0].st[0] = 0; |
| 280 |
verts[0].st[1] = 0; |
| 281 |
verts[0].modulate[0] = 255; |
| 282 |
verts[0].modulate[1] = 255; |
| 283 |
verts[0].modulate[2] = 255; |
| 284 |
verts[0].modulate[3] = 255 * p->alpha; |
| 285 |
|
| 286 |
VectorMA (org, -p->height, vup, point); |
| 287 |
VectorMA (point, p->width, vright, point); |
| 288 |
VectorCopy (point, verts[1].xyz); |
| 289 |
verts[1].st[0] = 0; |
| 290 |
verts[1].st[1] = 1; |
| 291 |
verts[1].modulate[0] = 255; |
| 292 |
verts[1].modulate[1] = 255; |
| 293 |
verts[1].modulate[2] = 255; |
| 294 |
verts[1].modulate[3] = 255 * p->alpha; |
| 295 |
|
| 296 |
VectorMA (org, p->height, vup, point); |
| 297 |
VectorMA (point, p->width, vright, point); |
| 298 |
VectorCopy (point, verts[2].xyz); |
| 299 |
verts[2].st[0] = 1; |
| 300 |
verts[2].st[1] = 1; |
| 301 |
verts[2].modulate[0] = 255; |
| 302 |
verts[2].modulate[1] = 255; |
| 303 |
verts[2].modulate[2] = 255; |
| 304 |
verts[2].modulate[3] = 255 * p->alpha; |
| 305 |
|
| 306 |
VectorMA (org, p->height, vup, point); |
| 307 |
VectorMA (point, -p->width, vright, point); |
| 308 |
VectorCopy (point, verts[3].xyz); |
| 309 |
verts[3].st[0] = 1; |
| 310 |
verts[3].st[1] = 0; |
| 311 |
verts[3].modulate[0] = 255; |
| 312 |
verts[3].modulate[1] = 255; |
| 313 |
verts[3].modulate[2] = 255; |
| 314 |
verts[3].modulate[3] = 255 * p->alpha; |
| 315 |
} |
| 316 |
else |
| 317 |
{ |
| 318 |
VectorMA (org, -p->height, vup, point); |
| 319 |
VectorMA (point, -p->width, vright, point); |
| 320 |
VectorCopy( point, TRIverts[0].xyz ); |
| 321 |
TRIverts[0].st[0] = 1; |
| 322 |
TRIverts[0].st[1] = 0; |
| 323 |
TRIverts[0].modulate[0] = 255; |
| 324 |
TRIverts[0].modulate[1] = 255; |
| 325 |
TRIverts[0].modulate[2] = 255; |
| 326 |
TRIverts[0].modulate[3] = 255 * p->alpha; |
| 327 |
|
| 328 |
VectorMA (org, p->height, vup, point); |
| 329 |
VectorMA (point, -p->width, vright, point); |
| 330 |
VectorCopy (point, TRIverts[1].xyz); |
| 331 |
TRIverts[1].st[0] = 0; |
| 332 |
TRIverts[1].st[1] = 0; |
| 333 |
TRIverts[1].modulate[0] = 255; |
| 334 |
TRIverts[1].modulate[1] = 255; |
| 335 |
TRIverts[1].modulate[2] = 255; |
| 336 |
TRIverts[1].modulate[3] = 255 * p->alpha; |
| 337 |
|
| 338 |
VectorMA (org, p->height, vup, point); |
| 339 |
VectorMA (point, p->width, vright, point); |
| 340 |
VectorCopy (point, TRIverts[2].xyz); |
| 341 |
TRIverts[2].st[0] = 0; |
| 342 |
TRIverts[2].st[1] = 1; |
| 343 |
TRIverts[2].modulate[0] = 255; |
| 344 |
TRIverts[2].modulate[1] = 255; |
| 345 |
TRIverts[2].modulate[2] = 255; |
| 346 |
TRIverts[2].modulate[3] = 255 * p->alpha; |
| 347 |
} |
| 348 |
|
| 349 |
} |
| 350 |
else if (p->type == P_SPRITE) |
| 351 |
{ |
| 352 |
vec3_t rr, ru; |
| 353 |
vec3_t rotate_ang; |
| 354 |
|
| 355 |
#ifdef WOLF_PARTICLES |
| 356 |
VectorSet (color, 1.0, 1.0, 1.0); |
| 357 |
#else |
| 358 |
VectorSet (color, 1.0, 1.0, 0.5); |
| 359 |
#endif |
| 360 |
time = cg.time - p->time; |
| 361 |
time2 = p->endtime - p->time; |
| 362 |
ratio = time / time2; |
| 363 |
|
| 364 |
width = p->width + ( ratio * ( p->endwidth - p->width) ); |
| 365 |
height = p->height + ( ratio * ( p->endheight - p->height) ); |
| 366 |
|
| 367 |
if (p->roll) { |
| 368 |
vectoangles( cg.refdef.viewaxis[0], rotate_ang ); |
| 369 |
rotate_ang[ROLL] += p->roll; |
| 370 |
AngleVectors ( rotate_ang, NULL, rr, ru); |
| 371 |
} |
| 372 |
|
| 373 |
if (p->roll) { |
| 374 |
VectorMA (org, -height, ru, point); |
| 375 |
VectorMA (point, -width, rr, point); |
| 376 |
} else { |
| 377 |
VectorMA (org, -height, vup, point); |
| 378 |
VectorMA (point, -width, vright, point); |
| 379 |
} |
| 380 |
VectorCopy (point, verts[0].xyz); |
| 381 |
verts[0].st[0] = 0; |
| 382 |
verts[0].st[1] = 0; |
| 383 |
verts[0].modulate[0] = 255; |
| 384 |
verts[0].modulate[1] = 255; |
| 385 |
verts[0].modulate[2] = 255; |
| 386 |
verts[0].modulate[3] = 255; |
| 387 |
|
| 388 |
if (p->roll) { |
| 389 |
VectorMA (point, 2*height, ru, point); |
| 390 |
} else { |
| 391 |
VectorMA (point, 2*height, vup, point); |
| 392 |
} |
| 393 |
VectorCopy (point, verts[1].xyz); |
| 394 |
verts[1].st[0] = 0; |
| 395 |
verts[1].st[1] = 1; |
| 396 |
verts[1].modulate[0] = 255; |
| 397 |
verts[1].modulate[1] = 255; |
| 398 |
verts[1].modulate[2] = 255; |
| 399 |
verts[1].modulate[3] = 255; |
| 400 |
|
| 401 |
if (p->roll) { |
| 402 |
VectorMA (point, 2*width, rr, point); |
| 403 |
} else { |
| 404 |
VectorMA (point, 2*width, vright, point); |
| 405 |
} |
| 406 |
VectorCopy (point, verts[2].xyz); |
| 407 |
verts[2].st[0] = 1; |
| 408 |
verts[2].st[1] = 1; |
| 409 |
verts[2].modulate[0] = 255; |
| 410 |
verts[2].modulate[1] = 255; |
| 411 |
verts[2].modulate[2] = 255; |
| 412 |
verts[2].modulate[3] = 255; |
| 413 |
|
| 414 |
if (p->roll) { |
| 415 |
VectorMA (point, -2*height, ru, point); |
| 416 |
} else { |
| 417 |
VectorMA (point, -2*height, vup, point); |
| 418 |
} |
| 419 |
VectorCopy (point, verts[3].xyz); |
| 420 |
verts[3].st[0] = 1; |
| 421 |
verts[3].st[1] = 0; |
| 422 |
verts[3].modulate[0] = 255; |
| 423 |
verts[3].modulate[1] = 255; |
| 424 |
verts[3].modulate[2] = 255; |
| 425 |
verts[3].modulate[3] = 255; |
| 426 |
} |
| 427 |
else if (p->type == P_SMOKE || p->type == P_SMOKE_IMPACT) |
| 428 |
{ |
| 429 |
|
| 430 |
if ( p->type == P_SMOKE_IMPACT && Distance( cg.snap->ps.origin, org ) > 1024) { |
| 431 |
return; |
| 432 |
} |
| 433 |
|
| 434 |
if (p->color == BLOODRED) |
| 435 |
VectorSet (color, 0.22f, 0.0f, 0.0f); |
| 436 |
else if (p->color == GREY75) |
| 437 |
{ |
| 438 |
float len; |
| 439 |
float greyit; |
| 440 |
float val; |
| 441 |
len = Distance (cg.snap->ps.origin, org); |
| 442 |
if (!len) |
| 443 |
len = 1; |
| 444 |
|
| 445 |
val = 4096/len; |
| 446 |
greyit = 0.25 * val; |
| 447 |
if (greyit > 0.5) |
| 448 |
greyit = 0.5; |
| 449 |
|
| 450 |
VectorSet (color, greyit, greyit, greyit); |
| 451 |
} |
| 452 |
else |
| 453 |
VectorSet (color, 1.0, 1.0, 1.0); |
| 454 |
|
| 455 |
time = cg.time - p->time; |
| 456 |
time2 = p->endtime - p->time; |
| 457 |
ratio = time / time2; |
| 458 |
|
| 459 |
if (cg.time > p->startfade) |
| 460 |
{ |
| 461 |
invratio = 1 - ( (cg.time - p->startfade) / (p->endtime - p->startfade) ); |
| 462 |
|
| 463 |
if (p->color == EMISIVEFADE) |
| 464 |
{ |
| 465 |
float fval; |
| 466 |
fval = (invratio * invratio); |
| 467 |
if (fval < 0) |
| 468 |
fval = 0; |
| 469 |
VectorSet (color, fval , fval , fval ); |
| 470 |
} |
| 471 |
invratio *= p->alpha; |
| 472 |
} |
| 473 |
else |
| 474 |
invratio = 1 * p->alpha; |
| 475 |
|
| 476 |
if ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) |
| 477 |
invratio = 1; |
| 478 |
|
| 479 |
if (invratio > 1) |
| 480 |
invratio = 1; |
| 481 |
|
| 482 |
width = p->width + ( ratio * ( p->endwidth - p->width) ); |
| 483 |
height = p->height + ( ratio * ( p->endheight - p->height) ); |
| 484 |
|
| 485 |
if (p->type != P_SMOKE_IMPACT) |
| 486 |
{ |
| 487 |
vec3_t temp; |
| 488 |
|
| 489 |
vectoangles (rforward, temp); |
| 490 |
p->accumroll += p->roll; |
| 491 |
temp[ROLL] += p->accumroll * 0.1; |
| 492 |
AngleVectors ( temp, NULL, rright2, rup2); |
| 493 |
} |
| 494 |
else |
| 495 |
{ |
| 496 |
VectorCopy (rright, rright2); |
| 497 |
VectorCopy (rup, rup2); |
| 498 |
} |
| 499 |
|
| 500 |
if (p->rotate) |
| 501 |
{ |
| 502 |
VectorMA (org, -height, rup2, point); |
| 503 |
VectorMA (point, -width, rright2, point); |
| 504 |
} |
| 505 |
else |
| 506 |
{ |
| 507 |
VectorMA (org, -p->height, vup, point); |
| 508 |
VectorMA (point, -p->width, vright, point); |
| 509 |
} |
| 510 |
VectorCopy (point, verts[0].xyz); |
| 511 |
verts[0].st[0] = 0; |
| 512 |
verts[0].st[1] = 0; |
| 513 |
verts[0].modulate[0] = 255 * color[0]; |
| 514 |
verts[0].modulate[1] = 255 * color[1]; |
| 515 |
verts[0].modulate[2] = 255 * color[2]; |
| 516 |
verts[0].modulate[3] = 255 * invratio; |
| 517 |
|
| 518 |
if (p->rotate) |
| 519 |
{ |
| 520 |
VectorMA (org, -height, rup2, point); |
| 521 |
VectorMA (point, width, rright2, point); |
| 522 |
} |
| 523 |
else |
| 524 |
{ |
| 525 |
VectorMA (org, -p->height, vup, point); |
| 526 |
VectorMA (point, p->width, vright, point); |
| 527 |
} |
| 528 |
VectorCopy (point, verts[1].xyz); |
| 529 |
verts[1].st[0] = 0; |
| 530 |
verts[1].st[1] = 1; |
| 531 |
verts[1].modulate[0] = 255 * color[0]; |
| 532 |
verts[1].modulate[1] = 255 * color[1]; |
| 533 |
verts[1].modulate[2] = 255 * color[2]; |
| 534 |
verts[1].modulate[3] = 255 * invratio; |
| 535 |
|
| 536 |
if (p->rotate) |
| 537 |
{ |
| 538 |
VectorMA (org, height, rup2, point); |
| 539 |
VectorMA (point, width, rright2, point); |
| 540 |
} |
| 541 |
else |
| 542 |
{ |
| 543 |
VectorMA (org, p->height, vup, point); |
| 544 |
VectorMA (point, p->width, vright, point); |
| 545 |
} |
| 546 |
VectorCopy (point, verts[2].xyz); |
| 547 |
verts[2].st[0] = 1; |
| 548 |
verts[2].st[1] = 1; |
| 549 |
verts[2].modulate[0] = 255 * color[0]; |
| 550 |
verts[2].modulate[1] = 255 * color[1]; |
| 551 |
verts[2].modulate[2] = 255 * color[2]; |
| 552 |
verts[2].modulate[3] = 255 * invratio; |
| 553 |
|
| 554 |
if (p->rotate) |
| 555 |
{ |
| 556 |
VectorMA (org, height, rup2, point); |
| 557 |
VectorMA (point, -width, rright2, point); |
| 558 |
} |
| 559 |
else |
| 560 |
{ |
| 561 |
VectorMA (org, p->height, vup, point); |
| 562 |
VectorMA (point, -p->width, vright, point); |
| 563 |
} |
| 564 |
VectorCopy (point, verts[3].xyz); |
| 565 |
verts[3].st[0] = 1; |
| 566 |
verts[3].st[1] = 0; |
| 567 |
verts[3].modulate[0] = 255 * color[0]; |
| 568 |
verts[3].modulate[1] = 255 * color[1]; |
| 569 |
verts[3].modulate[2] = 255 * color[2]; |
| 570 |
verts[3].modulate[3] = 255 * invratio; |
| 571 |
|
| 572 |
} |
| 573 |
else if (p->type == P_BLEED) |
| 574 |
{ |
| 575 |
vec3_t rr, ru; |
| 576 |
vec3_t rotate_ang; |
| 577 |
float pAlpha; |
| 578 |
|
| 579 |
pAlpha = p->alpha; |
| 580 |
|
| 581 |
if ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) |
| 582 |
pAlpha = 1; |
| 583 |
|
| 584 |
if (p->roll) |
| 585 |
{ |
| 586 |
vectoangles( cg.refdef.viewaxis[0], rotate_ang ); |
| 587 |
rotate_ang[ROLL] += p->roll; |
| 588 |
AngleVectors ( rotate_ang, NULL, rr, ru); |
| 589 |
} |
| 590 |
else |
| 591 |
{ |
| 592 |
VectorCopy (vup, ru); |
| 593 |
VectorCopy (vright, rr); |
| 594 |
} |
| 595 |
|
| 596 |
VectorMA (org, -p->height, ru, point); |
| 597 |
VectorMA (point, -p->width, rr, point); |
| 598 |
VectorCopy (point, verts[0].xyz); |
| 599 |
verts[0].st[0] = 0; |
| 600 |
verts[0].st[1] = 0; |
| 601 |
verts[0].modulate[0] = 111; |
| 602 |
verts[0].modulate[1] = 19; |
| 603 |
verts[0].modulate[2] = 9; |
| 604 |
verts[0].modulate[3] = 255 * pAlpha; |
| 605 |
|
| 606 |
VectorMA (org, -p->height, ru, point); |
| 607 |
VectorMA (point, p->width, rr, point); |
| 608 |
VectorCopy (point, verts[1].xyz); |
| 609 |
verts[1].st[0] = 0; |
| 610 |
verts[1].st[1] = 1; |
| 611 |
verts[1].modulate[0] = 111; |
| 612 |
verts[1].modulate[1] = 19; |
| 613 |
verts[1].modulate[2] = 9; |
| 614 |
verts[1].modulate[3] = 255 * pAlpha; |
| 615 |
|
| 616 |
VectorMA (org, p->height, ru, point); |
| 617 |
VectorMA (point, p->width, rr, point); |
| 618 |
VectorCopy (point, verts[2].xyz); |
| 619 |
verts[2].st[0] = 1; |
| 620 |
verts[2].st[1] = 1; |
| 621 |
verts[2].modulate[0] = 111; |
| 622 |
verts[2].modulate[1] = 19; |
| 623 |
verts[2].modulate[2] = 9; |
| 624 |
verts[2].modulate[3] = 255 * pAlpha; |
| 625 |
|
| 626 |
VectorMA (org, p->height, ru, point); |
| 627 |
VectorMA (point, -p->width, rr, point); |
| 628 |
VectorCopy (point, verts[3].xyz); |
| 629 |
verts[3].st[0] = 1; |
| 630 |
verts[3].st[1] = 0; |
| 631 |
verts[3].modulate[0] = 111; |
| 632 |
verts[3].modulate[1] = 19; |
| 633 |
verts[3].modulate[2] = 9; |
| 634 |
verts[3].modulate[3] = 255 * pAlpha; |
| 635 |
|
| 636 |
} |
| 637 |
else if (p->type == P_FLAT_SCALEUP) |
| 638 |
{ |
| 639 |
float sinR, cosR; |
| 640 |
|
| 641 |
if (p->color == BLOODRED) |
| 642 |
VectorSet (color, 1, 1, 1); |
| 643 |
else |
| 644 |
VectorSet (color, 0.5, 0.5, 0.5); |
| 645 |
|
| 646 |
time = cg.time - p->time; |
| 647 |
time2 = p->endtime - p->time; |
| 648 |
ratio = time / time2; |
| 649 |
|
| 650 |
width = p->width + ( ratio * ( p->endwidth - p->width) ); |
| 651 |
height = p->height + ( ratio * ( p->endheight - p->height) ); |
| 652 |
|
| 653 |
if (width > p->endwidth) |
| 654 |
width = p->endwidth; |
| 655 |
|
| 656 |
if (height > p->endheight) |
| 657 |
height = p->endheight; |
| 658 |
|
| 659 |
sinR = height * sin(DEG2RAD(p->roll)) * sqrt(2); |
| 660 |
cosR = width * cos(DEG2RAD(p->roll)) * sqrt(2); |
| 661 |
|
| 662 |
VectorCopy (org, verts[0].xyz); |
| 663 |
verts[0].xyz[0] -= sinR; |
| 664 |
verts[0].xyz[1] -= cosR; |
| 665 |
verts[0].st[0] = 0; |
| 666 |
verts[0].st[1] = 0; |
| 667 |
verts[0].modulate[0] = 255 * color[0]; |
| 668 |
verts[0].modulate[1] = 255 * color[1]; |
| 669 |
verts[0].modulate[2] = 255 * color[2]; |
| 670 |
verts[0].modulate[3] = 255; |
| 671 |
|
| 672 |
VectorCopy (org, verts[1].xyz); |
| 673 |
verts[1].xyz[0] -= cosR; |
| 674 |
verts[1].xyz[1] += sinR; |
| 675 |
verts[1].st[0] = 0; |
| 676 |
verts[1].st[1] = 1; |
| 677 |
verts[1].modulate[0] = 255 * color[0]; |
| 678 |
verts[1].modulate[1] = 255 * color[1]; |
| 679 |
verts[1].modulate[2] = 255 * color[2]; |
| 680 |
verts[1].modulate[3] = 255; |
| 681 |
|
| 682 |
VectorCopy (org, verts[2].xyz); |
| 683 |
verts[2].xyz[0] += sinR; |
| 684 |
verts[2].xyz[1] += cosR; |
| 685 |
verts[2].st[0] = 1; |
| 686 |
verts[2].st[1] = 1; |
| 687 |
verts[2].modulate[0] = 255 * color[0]; |
| 688 |
verts[2].modulate[1] = 255 * color[1]; |
| 689 |
verts[2].modulate[2] = 255 * color[2]; |
| 690 |
verts[2].modulate[3] = 255; |
| 691 |
|
| 692 |
VectorCopy (org, verts[3].xyz); |
| 693 |
verts[3].xyz[0] += cosR; |
| 694 |
verts[3].xyz[1] -= sinR; |
| 695 |
verts[3].st[0] = 1; |
| 696 |
verts[3].st[1] = 0; |
| 697 |
verts[3].modulate[0] = 255 * color[0]; |
| 698 |
verts[3].modulate[1] = 255 * color[1]; |
| 699 |
verts[3].modulate[2] = 255 * color[2]; |
| 700 |
verts[3].modulate[3] = 255; |
| 701 |
} |
| 702 |
else if (p->type == P_FLAT) |
| 703 |
{ |
| 704 |
|
| 705 |
VectorCopy (org, verts[0].xyz); |
| 706 |
verts[0].xyz[0] -= p->height; |
| 707 |
verts[0].xyz[1] -= p->width; |
| 708 |
verts[0].st[0] = 0; |
| 709 |
verts[0].st[1] = 0; |
| 710 |
verts[0].modulate[0] = 255; |
| 711 |
verts[0].modulate[1] = 255; |
| 712 |
verts[0].modulate[2] = 255; |
| 713 |
verts[0].modulate[3] = 255; |
| 714 |
|
| 715 |
VectorCopy (org, verts[1].xyz); |
| 716 |
verts[1].xyz[0] -= p->height; |
| 717 |
verts[1].xyz[1] += p->width; |
| 718 |
verts[1].st[0] = 0; |
| 719 |
verts[1].st[1] = 1; |
| 720 |
verts[1].modulate[0] = 255; |
| 721 |
verts[1].modulate[1] = 255; |
| 722 |
verts[1].modulate[2] = 255; |
| 723 |
verts[1].modulate[3] = 255; |
| 724 |
|
| 725 |
VectorCopy (org, verts[2].xyz); |
| 726 |
verts[2].xyz[0] += p->height; |
| 727 |
verts[2].xyz[1] += p->width; |
| 728 |
verts[2].st[0] = 1; |
| 729 |
verts[2].st[1] = 1; |
| 730 |
verts[2].modulate[0] = 255; |
| 731 |
verts[2].modulate[1] = 255; |
| 732 |
verts[2].modulate[2] = 255; |
| 733 |
verts[2].modulate[3] = 255; |
| 734 |
|
| 735 |
VectorCopy (org, verts[3].xyz); |
| 736 |
verts[3].xyz[0] += p->height; |
| 737 |
verts[3].xyz[1] -= p->width; |
| 738 |
verts[3].st[0] = 1; |
| 739 |
verts[3].st[1] = 0; |
| 740 |
verts[3].modulate[0] = 255; |
| 741 |
verts[3].modulate[1] = 255; |
| 742 |
verts[3].modulate[2] = 255; |
| 743 |
verts[3].modulate[3] = 255; |
| 744 |
|
| 745 |
} |
| 746 |
|
| 747 |
else if (p->type == P_ANIM) { |
| 748 |
vec3_t rr, ru; |
| 749 |
vec3_t rotate_ang; |
| 750 |
int i, j; |
| 751 |
|
| 752 |
time = cg.time - p->time; |
| 753 |
time2 = p->endtime - p->time; |
| 754 |
ratio = time / time2; |
| 755 |
if (ratio >= 1.0f) { |
| 756 |
ratio = 0.9999f; |
| 757 |
} |
| 758 |
|
| 759 |
width = p->width + ( ratio * ( p->endwidth - p->width) ); |
| 760 |
height = p->height + ( ratio * ( p->endheight - p->height) ); |
| 761 |
|
| 762 |
|
| 763 |
if (Distance( cg.snap->ps.origin, org ) < width/1.5) { |
| 764 |
return; |
| 765 |
} |
| 766 |
|
| 767 |
i = p->shaderAnim; |
| 768 |
j = (int)floor(ratio * shaderAnimCounts[p->shaderAnim]); |
| 769 |
p->pshader = shaderAnims[i][j]; |
| 770 |
|
| 771 |
if (p->roll) { |
| 772 |
vectoangles( cg.refdef.viewaxis[0], rotate_ang ); |
| 773 |
rotate_ang[ROLL] += p->roll; |
| 774 |
AngleVectors ( rotate_ang, NULL, rr, ru); |
| 775 |
} |
| 776 |
|
| 777 |
if (p->roll) { |
| 778 |
VectorMA (org, -height, ru, point); |
| 779 |
VectorMA (point, -width, rr, point); |
| 780 |
} else { |
| 781 |
VectorMA (org, -height, vup, point); |
| 782 |
VectorMA (point, -width, vright, point); |
| 783 |
} |
| 784 |
VectorCopy (point, verts[0].xyz); |
| 785 |
verts[0].st[0] = 0; |
| 786 |
verts[0].st[1] = 0; |
| 787 |
verts[0].modulate[0] = 255; |
| 788 |
verts[0].modulate[1] = 255; |
| 789 |
verts[0].modulate[2] = 255; |
| 790 |
verts[0].modulate[3] = 255; |
| 791 |
|
| 792 |
if (p->roll) { |
| 793 |
VectorMA (point, 2*height, ru, point); |
| 794 |
} else { |
| 795 |
VectorMA (point, 2*height, vup, point); |
| 796 |
} |
| 797 |
VectorCopy (point, verts[1].xyz); |
| 798 |
verts[1].st[0] = 0; |
| 799 |
verts[1].st[1] = 1; |
| 800 |
verts[1].modulate[0] = 255; |
| 801 |
verts[1].modulate[1] = 255; |
| 802 |
verts[1].modulate[2] = 255; |
| 803 |
verts[1].modulate[3] = 255; |
| 804 |
|
| 805 |
if (p->roll) { |
| 806 |
VectorMA (point, 2*width, rr, point); |
| 807 |
} else { |
| 808 |
VectorMA (point, 2*width, vright, point); |
| 809 |
} |
| 810 |
VectorCopy (point, verts[2].xyz); |
| 811 |
verts[2].st[0] = 1; |
| 812 |
verts[2].st[1] = 1; |
| 813 |
verts[2].modulate[0] = 255; |
| 814 |
verts[2].modulate[1] = 255; |
| 815 |
verts[2].modulate[2] = 255; |
| 816 |
verts[2].modulate[3] = 255; |
| 817 |
|
| 818 |
if (p->roll) { |
| 819 |
VectorMA (point, -2*height, ru, point); |
| 820 |
} else { |
| 821 |
VectorMA (point, -2*height, vup, point); |
| 822 |
} |
| 823 |
VectorCopy (point, verts[3].xyz); |
| 824 |
verts[3].st[0] = 1; |
| 825 |
verts[3].st[1] = 0; |
| 826 |
verts[3].modulate[0] = 255; |
| 827 |
verts[3].modulate[1] = 255; |
| 828 |
verts[3].modulate[2] = 255; |
| 829 |
verts[3].modulate[3] = 255; |
| 830 |
} |
| 831 |
|
| 832 |
|
| 833 |
if (!p->pshader) { |
| 834 |
|
| 835 |
|
| 836 |
return; |
| 837 |
} |
| 838 |
|
| 839 |
if (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY) |
| 840 |
trap_R_AddPolyToScene( p->pshader, 3, TRIverts ); |
| 841 |
else |
| 842 |
trap_R_AddPolyToScene( p->pshader, 4, verts ); |
| 843 |
|
| 844 |
} |
| 845 |
|
| 846 |
|
| 847 |
static float roll = 0.0; |
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
void CG_AddParticles (void) |
| 855 |
{ |
| 856 |
cparticle_t *p, *next; |
| 857 |
float alpha; |
| 858 |
float time, time2; |
| 859 |
vec3_t org; |
| 860 |
cparticle_t *active, *tail; |
| 861 |
vec3_t rotate_ang; |
| 862 |
|
| 863 |
if (!initparticles) |
| 864 |
CG_ClearParticles (); |
| 865 |
|
| 866 |
VectorCopy( cg.refdef.viewaxis[0], vforward ); |
| 867 |
VectorCopy( cg.refdef.viewaxis[1], vright ); |
| 868 |
VectorCopy( cg.refdef.viewaxis[2], vup ); |
| 869 |
|
| 870 |
vectoangles( cg.refdef.viewaxis[0], rotate_ang ); |
| 871 |
roll += ((cg.time - oldtime) * 0.1) ; |
| 872 |
rotate_ang[ROLL] += (roll*0.9); |
| 873 |
AngleVectors ( rotate_ang, rforward, rright, rup); |
| 874 |
|
| 875 |
oldtime = cg.time; |
| 876 |
|
| 877 |
active = NULL; |
| 878 |
tail = NULL; |
| 879 |
|
| 880 |
for (p=active_particles ; p ; p=next) |
| 881 |
{ |
| 882 |
|
| 883 |
next = p->next; |
| 884 |
|
| 885 |
time = (cg.time - p->time)*0.001; |
| 886 |
|
| 887 |
alpha = p->alpha + time*p->alphavel; |
| 888 |
if (alpha <= 0) |
| 889 |
{ |
| 890 |
p->next = free_particles; |
| 891 |
free_particles = p; |
| 892 |
p->type = 0; |
| 893 |
p->color = 0; |
| 894 |
p->alpha = 0; |
| 895 |
continue; |
| 896 |
} |
| 897 |
|
| 898 |
if (p->type == P_SMOKE || p->type == P_ANIM || p->type == P_BLEED || p->type == P_SMOKE_IMPACT) |
| 899 |
{ |
| 900 |
if (cg.time > p->endtime) |
| 901 |
{ |
| 902 |
p->next = free_particles; |
| 903 |
free_particles = p; |
| 904 |
p->type = 0; |
| 905 |
p->color = 0; |
| 906 |
p->alpha = 0; |
| 907 |
|
| 908 |
continue; |
| 909 |
} |
| 910 |
|
| 911 |
} |
| 912 |
|
| 913 |
if (p->type == P_WEATHER_FLURRY) |
| 914 |
{ |
| 915 |
if (cg.time > p->endtime) |
| 916 |
{ |
| 917 |
p->next = free_particles; |
| 918 |
free_particles = p; |
| 919 |
p->type = 0; |
| 920 |
p->color = 0; |
| 921 |
p->alpha = 0; |
| 922 |
|
| 923 |
continue; |
| 924 |
} |
| 925 |
} |
| 926 |
|
| 927 |
|
| 928 |
if (p->type == P_FLAT_SCALEUP_FADE) |
| 929 |
{ |
| 930 |
if (cg.time > p->endtime) |
| 931 |
{ |
| 932 |
p->next = free_particles; |
| 933 |
free_particles = p; |
| 934 |
p->type = 0; |
| 935 |
p->color = 0; |
| 936 |
p->alpha = 0; |
| 937 |
continue; |
| 938 |
} |
| 939 |
|
| 940 |
} |
| 941 |
|
| 942 |
if ((p->type == P_BAT || p->type == P_SPRITE) && p->endtime < 0) { |
| 943 |
|
| 944 |
CG_AddParticleToScene (p, p->org, alpha); |
| 945 |
p->next = free_particles; |
| 946 |
free_particles = p; |
| 947 |
p->type = 0; |
| 948 |
p->color = 0; |
| 949 |
p->alpha = 0; |
| 950 |
continue; |
| 951 |
} |
| 952 |
|
| 953 |
p->next = NULL; |
| 954 |
if (!tail) |
| 955 |
active = tail = p; |
| 956 |
else |
| 957 |
{ |
| 958 |
tail->next = p; |
| 959 |
tail = p; |
| 960 |
} |
| 961 |
|
| 962 |
if (alpha > 1.0) |
| 963 |
alpha = 1; |
| 964 |
|
| 965 |
time2 = time*time; |
| 966 |
|
| 967 |
org[0] = p->org[0] + p->vel[0]*time + p->accel[0]*time2; |
| 968 |
org[1] = p->org[1] + p->vel[1]*time + p->accel[1]*time2; |
| 969 |
org[2] = p->org[2] + p->vel[2]*time + p->accel[2]*time2; |
| 970 |
|
| 971 |
CG_AddParticleToScene (p, org, alpha); |
| 972 |
} |
| 973 |
|
| 974 |
active_particles = active; |
| 975 |
} |
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
void CG_ParticleSnowFlurry (qhandle_t pshader, centity_t *cent) |
| 983 |
{ |
| 984 |
cparticle_t *p; |
| 985 |
qboolean turb = qtrue; |
| 986 |
|
| 987 |
if (!pshader) |
| 988 |
CG_Printf ("CG_ParticleSnowFlurry pshader == ZERO!\n"); |
| 989 |
|
| 990 |
if (!free_particles) |
| 991 |
return; |
| 992 |
p = free_particles; |
| 993 |
free_particles = p->next; |
| 994 |
p->next = active_particles; |
| 995 |
active_particles = p; |
| 996 |
p->time = cg.time; |
| 997 |
p->color = 0; |
| 998 |
p->alpha = 0.90f; |
| 999 |
p->alphavel = 0; |
| 1000 |
|
| 1001 |
p->start = cent->currentState.origin2[0]; |
| 1002 |
p->end = cent->currentState.origin2[1]; |
| 1003 |
|
| 1004 |
p->endtime = cg.time + cent->currentState.time; |
| 1005 |
p->startfade = cg.time + cent->currentState.time2; |
| 1006 |
|
| 1007 |
p->pshader = pshader; |
| 1008 |
|
| 1009 |
if (rand()%100 > 90) |
| 1010 |
{ |
| 1011 |
p->height = 32; |
| 1012 |
p->width = 32; |
| 1013 |
p->alpha = 0.10f; |
| 1014 |
} |
| 1015 |
else |
| 1016 |
{ |
| 1017 |
p->height = 1; |
| 1018 |
p->width = 1; |
| 1019 |
} |
| 1020 |
|
| 1021 |
p->vel[2] = -20; |
| 1022 |
|
| 1023 |
p->type = P_WEATHER_FLURRY; |
| 1024 |
|
| 1025 |
if (turb) |
| 1026 |
p->vel[2] = -10; |
| 1027 |
|
| 1028 |
VectorCopy(cent->currentState.origin, p->org); |
| 1029 |
|
| 1030 |
p->vel[0] = p->vel[1] = 0; |
| 1031 |
|
| 1032 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 1033 |
|
| 1034 |
p->vel[0] += cent->currentState.angles[0] * 32 + (crandom() * 16); |
| 1035 |
p->vel[1] += cent->currentState.angles[1] * 32 + (crandom() * 16); |
| 1036 |
p->vel[2] += cent->currentState.angles[2]; |
| 1037 |
|
| 1038 |
if (turb) |
| 1039 |
{ |
| 1040 |
p->accel[0] = crandom () * 16; |
| 1041 |
p->accel[1] = crandom () * 16; |
| 1042 |
} |
| 1043 |
|
| 1044 |
} |
| 1045 |
|
| 1046 |
void CG_ParticleSnow (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum) |
| 1047 |
{ |
| 1048 |
cparticle_t *p; |
| 1049 |
|
| 1050 |
if (!pshader) |
| 1051 |
CG_Printf ("CG_ParticleSnow pshader == ZERO!\n"); |
| 1052 |
|
| 1053 |
if (!free_particles) |
| 1054 |
return; |
| 1055 |
p = free_particles; |
| 1056 |
free_particles = p->next; |
| 1057 |
p->next = active_particles; |
| 1058 |
active_particles = p; |
| 1059 |
p->time = cg.time; |
| 1060 |
p->color = 0; |
| 1061 |
p->alpha = 0.40f; |
| 1062 |
p->alphavel = 0; |
| 1063 |
p->start = origin[2]; |
| 1064 |
p->end = origin2[2]; |
| 1065 |
p->pshader = pshader; |
| 1066 |
p->height = 1; |
| 1067 |
p->width = 1; |
| 1068 |
|
| 1069 |
p->vel[2] = -50; |
| 1070 |
|
| 1071 |
if (turb) |
| 1072 |
{ |
| 1073 |
p->type = P_WEATHER_TURBULENT; |
| 1074 |
p->vel[2] = -50 * 1.3; |
| 1075 |
} |
| 1076 |
else |
| 1077 |
{ |
| 1078 |
p->type = P_WEATHER; |
| 1079 |
} |
| 1080 |
|
| 1081 |
VectorCopy(origin, p->org); |
| 1082 |
|
| 1083 |
p->org[0] = p->org[0] + ( crandom() * range); |
| 1084 |
p->org[1] = p->org[1] + ( crandom() * range); |
| 1085 |
p->org[2] = p->org[2] + ( crandom() * (p->start - p->end)); |
| 1086 |
|
| 1087 |
p->vel[0] = p->vel[1] = 0; |
| 1088 |
|
| 1089 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 1090 |
|
| 1091 |
if (turb) |
| 1092 |
{ |
| 1093 |
p->vel[0] = crandom() * 16; |
| 1094 |
p->vel[1] = crandom() * 16; |
| 1095 |
} |
| 1096 |
|
| 1097 |
|
| 1098 |
p->snum = snum; |
| 1099 |
p->link = qtrue; |
| 1100 |
|
| 1101 |
} |
| 1102 |
|
| 1103 |
void CG_ParticleBubble (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum) |
| 1104 |
{ |
| 1105 |
cparticle_t *p; |
| 1106 |
float randsize; |
| 1107 |
|
| 1108 |
if (!pshader) |
| 1109 |
CG_Printf ("CG_ParticleSnow pshader == ZERO!\n"); |
| 1110 |
|
| 1111 |
if (!free_particles) |
| 1112 |
return; |
| 1113 |
p = free_particles; |
| 1114 |
free_particles = p->next; |
| 1115 |
p->next = active_particles; |
| 1116 |
active_particles = p; |
| 1117 |
p->time = cg.time; |
| 1118 |
p->color = 0; |
| 1119 |
p->alpha = 0.40f; |
| 1120 |
p->alphavel = 0; |
| 1121 |
p->start = origin[2]; |
| 1122 |
p->end = origin2[2]; |
| 1123 |
p->pshader = pshader; |
| 1124 |
|
| 1125 |
randsize = 1 + (crandom() * 0.5); |
| 1126 |
|
| 1127 |
p->height = randsize; |
| 1128 |
p->width = randsize; |
| 1129 |
|
| 1130 |
p->vel[2] = 50 + ( crandom() * 10 ); |
| 1131 |
|
| 1132 |
if (turb) |
| 1133 |
{ |
| 1134 |
p->type = P_BUBBLE_TURBULENT; |
| 1135 |
p->vel[2] = 50 * 1.3; |
| 1136 |
} |
| 1137 |
else |
| 1138 |
{ |
| 1139 |
p->type = P_BUBBLE; |
| 1140 |
} |
| 1141 |
|
| 1142 |
VectorCopy(origin, p->org); |
| 1143 |
|
| 1144 |
p->org[0] = p->org[0] + ( crandom() * range); |
| 1145 |
p->org[1] = p->org[1] + ( crandom() * range); |
| 1146 |
p->org[2] = p->org[2] + ( crandom() * (p->start - p->end)); |
| 1147 |
|
| 1148 |
p->vel[0] = p->vel[1] = 0; |
| 1149 |
|
| 1150 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 1151 |
|
| 1152 |
if (turb) |
| 1153 |
{ |
| 1154 |
p->vel[0] = crandom() * 4; |
| 1155 |
p->vel[1] = crandom() * 4; |
| 1156 |
} |
| 1157 |
|
| 1158 |
|
| 1159 |
p->snum = snum; |
| 1160 |
p->link = qtrue; |
| 1161 |
|
| 1162 |
} |
| 1163 |
|
| 1164 |
void CG_ParticleSmoke (qhandle_t pshader, centity_t *cent) |
| 1165 |
{ |
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
cparticle_t *p; |
| 1170 |
|
| 1171 |
if (!pshader) |
| 1172 |
CG_Printf ("CG_ParticleSmoke == ZERO!\n"); |
| 1173 |
|
| 1174 |
if (!free_particles) |
| 1175 |
return; |
| 1176 |
p = free_particles; |
| 1177 |
free_particles = p->next; |
| 1178 |
p->next = active_particles; |
| 1179 |
active_particles = p; |
| 1180 |
p->time = cg.time; |
| 1181 |
|
| 1182 |
p->endtime = cg.time + cent->currentState.time; |
| 1183 |
p->startfade = cg.time + cent->currentState.time2; |
| 1184 |
|
| 1185 |
p->color = 0; |
| 1186 |
p->alpha = 1.0; |
| 1187 |
p->alphavel = 0; |
| 1188 |
p->start = cent->currentState.origin[2]; |
| 1189 |
p->end = cent->currentState.origin2[2]; |
| 1190 |
p->pshader = pshader; |
| 1191 |
p->rotate = qfalse; |
| 1192 |
p->height = 8; |
| 1193 |
p->width = 8; |
| 1194 |
p->endheight = 32; |
| 1195 |
p->endwidth = 32; |
| 1196 |
p->type = P_SMOKE; |
| 1197 |
|
| 1198 |
VectorCopy(cent->currentState.origin, p->org); |
| 1199 |
|
| 1200 |
p->vel[0] = p->vel[1] = 0; |
| 1201 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 1202 |
|
| 1203 |
p->vel[2] = 5; |
| 1204 |
|
| 1205 |
if (cent->currentState.frame == 1) |
| 1206 |
p->vel[2] *= -1; |
| 1207 |
|
| 1208 |
p->roll = 8 + (crandom() * 4); |
| 1209 |
} |
| 1210 |
|
| 1211 |
|
| 1212 |
void CG_ParticleBulletDebris (vec3_t org, vec3_t vel, int duration) |
| 1213 |
{ |
| 1214 |
|
| 1215 |
cparticle_t *p; |
| 1216 |
|
| 1217 |
if (!free_particles) |
| 1218 |
return; |
| 1219 |
p = free_particles; |
| 1220 |
free_particles = p->next; |
| 1221 |
p->next = active_particles; |
| 1222 |
active_particles = p; |
| 1223 |
p->time = cg.time; |
| 1224 |
|
| 1225 |
p->endtime = cg.time + duration; |
| 1226 |
p->startfade = cg.time + duration/2; |
| 1227 |
|
| 1228 |
p->color = EMISIVEFADE; |
| 1229 |
p->alpha = 1.0; |
| 1230 |
p->alphavel = 0; |
| 1231 |
|
| 1232 |
p->height = 0.5; |
| 1233 |
p->width = 0.5; |
| 1234 |
p->endheight = 0.5; |
| 1235 |
p->endwidth = 0.5; |
| 1236 |
|
| 1237 |
p->pshader = cgs.media.tracerShader; |
| 1238 |
|
| 1239 |
p->type = P_SMOKE; |
| 1240 |
|
| 1241 |
VectorCopy(org, p->org); |
| 1242 |
|
| 1243 |
p->vel[0] = vel[0]; |
| 1244 |
p->vel[1] = vel[1]; |
| 1245 |
p->vel[2] = vel[2]; |
| 1246 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 1247 |
|
| 1248 |
p->accel[2] = -60; |
| 1249 |
p->vel[2] += -20; |
| 1250 |
|
| 1251 |
} |
| 1252 |
|
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
|
| 1259 |
void CG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duration, int sizeStart, int sizeEnd) |
| 1260 |
{ |
| 1261 |
cparticle_t *p; |
| 1262 |
int anim; |
| 1263 |
|
| 1264 |
if (animStr < (char *)10) |
| 1265 |
CG_Error( "CG_ParticleExplosion: animStr is probably an index rather than a string" ); |
| 1266 |
|
| 1267 |
|
| 1268 |
for (anim=0; shaderAnimNames[anim]; anim++) { |
| 1269 |
if (!Q_stricmp( animStr, shaderAnimNames[anim] )) |
| 1270 |
break; |
| 1271 |
} |
| 1272 |
if (!shaderAnimNames[anim]) { |
| 1273 |
CG_Error("CG_ParticleExplosion: unknown animation string: %s", animStr); |
| 1274 |
return; |
| 1275 |
} |
| 1276 |
|
| 1277 |
if (!free_particles) |
| 1278 |
return; |
| 1279 |
p = free_particles; |
| 1280 |
free_particles = p->next; |
| 1281 |
p->next = active_particles; |
| 1282 |
active_particles = p; |
| 1283 |
p->time = cg.time; |
| 1284 |
#ifdef WOLF_PARTICLES |
| 1285 |
p->alpha = 1.0; |
| 1286 |
#else |
| 1287 |
p->alpha = 0.5; |
| 1288 |
#endif |
| 1289 |
p->alphavel = 0; |
| 1290 |
|
| 1291 |
if (duration < 0) { |
| 1292 |
duration *= -1; |
| 1293 |
p->roll = 0; |
| 1294 |
} else { |
| 1295 |
p->roll = crandom()*179; |
| 1296 |
} |
| 1297 |
|
| 1298 |
p->shaderAnim = anim; |
| 1299 |
|
| 1300 |
p->width = sizeStart; |
| 1301 |
p->height = sizeStart*shaderAnimSTRatio[anim]; |
| 1302 |
|
| 1303 |
p->endheight = sizeEnd; |
| 1304 |
p->endwidth = sizeEnd*shaderAnimSTRatio[anim]; |
| 1305 |
|
| 1306 |
p->endtime = cg.time + duration; |
| 1307 |
|
| 1308 |
p->type = P_ANIM; |
| 1309 |
|
| 1310 |
VectorCopy( origin, p->org ); |
| 1311 |
VectorCopy( vel, p->vel ); |
| 1312 |
VectorClear( p->accel ); |
| 1313 |
|
| 1314 |
} |
| 1315 |
|
| 1316 |
|
| 1317 |
void CG_AddParticleShrapnel (localEntity_t *le) |
| 1318 |
{ |
| 1319 |
} |
| 1320 |
|
| 1321 |
|
| 1322 |
int CG_NewParticleArea (int num) |
| 1323 |
{ |
| 1324 |
|
| 1325 |
char *str; |
| 1326 |
char *token; |
| 1327 |
int type; |
| 1328 |
vec3_t origin, origin2; |
| 1329 |
int i; |
| 1330 |
float range = 0; |
| 1331 |
int turb; |
| 1332 |
int numparticles; |
| 1333 |
int snum; |
| 1334 |
|
| 1335 |
str = (char *) CG_ConfigString (num); |
| 1336 |
if (!str[0]) |
| 1337 |
return (0); |
| 1338 |
|
| 1339 |
|
| 1340 |
token = COM_Parse (&str); |
| 1341 |
type = atoi (token); |
| 1342 |
|
| 1343 |
if (type == 1) |
| 1344 |
range = 128; |
| 1345 |
else if (type == 2) |
| 1346 |
range = 64; |
| 1347 |
else if (type == 3) |
| 1348 |
range = 32; |
| 1349 |
else if (type == 0) |
| 1350 |
range = 256; |
| 1351 |
else if (type == 4) |
| 1352 |
range = 8; |
| 1353 |
else if (type == 5) |
| 1354 |
range = 16; |
| 1355 |
else if (type == 6) |
| 1356 |
range = 32; |
| 1357 |
else if (type == 7) |
| 1358 |
range = 64; |
| 1359 |
|
| 1360 |
|
| 1361 |
for (i=0; i<3; i++) |
| 1362 |
{ |
| 1363 |
token = COM_Parse (&str); |
| 1364 |
origin[i] = atof (token); |
| 1365 |
} |
| 1366 |
|
| 1367 |
for (i=0; i<3; i++) |
| 1368 |
{ |
| 1369 |
token = COM_Parse (&str); |
| 1370 |
origin2[i] = atof (token); |
| 1371 |
} |
| 1372 |
|
| 1373 |
token = COM_Parse (&str); |
| 1374 |
numparticles = atoi (token); |
| 1375 |
|
| 1376 |
token = COM_Parse (&str); |
| 1377 |
turb = atoi (token); |
| 1378 |
|
| 1379 |
token = COM_Parse (&str); |
| 1380 |
snum = atoi (token); |
| 1381 |
|
| 1382 |
for (i=0; i<numparticles; i++) |
| 1383 |
{ |
| 1384 |
if (type >= 4) |
| 1385 |
CG_ParticleBubble (cgs.media.waterBubbleShader, origin, origin2, turb, range, snum); |
| 1386 |
else |
| 1387 |
CG_ParticleSnow (cgs.media.waterBubbleShader, origin, origin2, turb, range, snum); |
| 1388 |
} |
| 1389 |
|
| 1390 |
return (1); |
| 1391 |
} |
| 1392 |
|
| 1393 |
void CG_SnowLink (centity_t *cent, qboolean particleOn) |
| 1394 |
{ |
| 1395 |
cparticle_t *p, *next; |
| 1396 |
int id; |
| 1397 |
|
| 1398 |
id = cent->currentState.frame; |
| 1399 |
|
| 1400 |
for (p=active_particles ; p ; p=next) |
| 1401 |
{ |
| 1402 |
next = p->next; |
| 1403 |
|
| 1404 |
if (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT) |
| 1405 |
{ |
| 1406 |
if (p->snum == id) |
| 1407 |
{ |
| 1408 |
if (particleOn) |
| 1409 |
p->link = qtrue; |
| 1410 |
else |
| 1411 |
p->link = qfalse; |
| 1412 |
} |
| 1413 |
} |
| 1414 |
|
| 1415 |
} |
| 1416 |
} |
| 1417 |
|
| 1418 |
void CG_ParticleImpactSmokePuff (qhandle_t pshader, vec3_t origin) |
| 1419 |
{ |
| 1420 |
cparticle_t *p; |
| 1421 |
|
| 1422 |
if (!pshader) |
| 1423 |
CG_Printf ("CG_ParticleImpactSmokePuff pshader == ZERO!\n"); |
| 1424 |
|
| 1425 |
if (!free_particles) |
| 1426 |
return; |
| 1427 |
p = free_particles; |
| 1428 |
free_particles = p->next; |
| 1429 |
p->next = active_particles; |
| 1430 |
active_particles = p; |
| 1431 |
p->time = cg.time; |
| 1432 |
p->alpha = 0.25; |
| 1433 |
p->alphavel = 0; |
| 1434 |
p->roll = crandom()*179; |
| 1435 |
|
| 1436 |
p->pshader = pshader; |
| 1437 |
|
| 1438 |
p->endtime = cg.time + 1000; |
| 1439 |
p->startfade = cg.time + 100; |
| 1440 |
|
| 1441 |
p->width = rand()%4 + 8; |
| 1442 |
p->height = rand()%4 + 8; |
| 1443 |
|
| 1444 |
p->endheight = p->height *2; |
| 1445 |
p->endwidth = p->width * 2; |
| 1446 |
|
| 1447 |
p->endtime = cg.time + 500; |
| 1448 |
|
| 1449 |
p->type = P_SMOKE_IMPACT; |
| 1450 |
|
| 1451 |
VectorCopy( origin, p->org ); |
| 1452 |
VectorSet(p->vel, 0, 0, 20); |
| 1453 |
VectorSet(p->accel, 0, 0, 20); |
| 1454 |
|
| 1455 |
p->rotate = qtrue; |
| 1456 |
} |
| 1457 |
|
| 1458 |
void CG_Particle_Bleed (qhandle_t pshader, vec3_t start, vec3_t dir, int fleshEntityNum, int duration) |
| 1459 |
{ |
| 1460 |
cparticle_t *p; |
| 1461 |
|
| 1462 |
if (!pshader) |
| 1463 |
CG_Printf ("CG_Particle_Bleed pshader == ZERO!\n"); |
| 1464 |
|
| 1465 |
if (!free_particles) |
| 1466 |
return; |
| 1467 |
p = free_particles; |
| 1468 |
free_particles = p->next; |
| 1469 |
p->next = active_particles; |
| 1470 |
active_particles = p; |
| 1471 |
p->time = cg.time; |
| 1472 |
p->alpha = 1.0; |
| 1473 |
p->alphavel = 0; |
| 1474 |
p->roll = 0; |
| 1475 |
|
| 1476 |
p->pshader = pshader; |
| 1477 |
|
| 1478 |
p->endtime = cg.time + duration; |
| 1479 |
|
| 1480 |
if (fleshEntityNum) |
| 1481 |
p->startfade = cg.time; |
| 1482 |
else |
| 1483 |
p->startfade = cg.time + 100; |
| 1484 |
|
| 1485 |
p->width = 4; |
| 1486 |
p->height = 4; |
| 1487 |
|
| 1488 |
p->endheight = 4+rand()%3; |
| 1489 |
p->endwidth = p->endheight; |
| 1490 |
|
| 1491 |
p->type = P_SMOKE; |
| 1492 |
|
| 1493 |
VectorCopy( start, p->org ); |
| 1494 |
p->vel[0] = 0; |
| 1495 |
p->vel[1] = 0; |
| 1496 |
p->vel[2] = -20; |
| 1497 |
VectorClear( p->accel ); |
| 1498 |
|
| 1499 |
p->rotate = qfalse; |
| 1500 |
|
| 1501 |
p->roll = rand()%179; |
| 1502 |
|
| 1503 |
p->color = BLOODRED; |
| 1504 |
p->alpha = 0.75; |
| 1505 |
|
| 1506 |
} |
| 1507 |
|
| 1508 |
void CG_Particle_OilParticle (qhandle_t pshader, centity_t *cent) |
| 1509 |
{ |
| 1510 |
cparticle_t *p; |
| 1511 |
|
| 1512 |
int time; |
| 1513 |
int time2; |
| 1514 |
float ratio; |
| 1515 |
|
| 1516 |
float duration = 1500; |
| 1517 |
|
| 1518 |
time = cg.time; |
| 1519 |
time2 = cg.time + cent->currentState.time; |
| 1520 |
|
| 1521 |
ratio =(float)1 - ((float)time / (float)time2); |
| 1522 |
|
| 1523 |
if (!pshader) |
| 1524 |
CG_Printf ("CG_Particle_OilParticle == ZERO!\n"); |
| 1525 |
|
| 1526 |
if (!free_particles) |
| 1527 |
return; |
| 1528 |
p = free_particles; |
| 1529 |
free_particles = p->next; |
| 1530 |
p->next = active_particles; |
| 1531 |
active_particles = p; |
| 1532 |
p->time = cg.time; |
| 1533 |
p->alpha = 1.0; |
| 1534 |
p->alphavel = 0; |
| 1535 |
p->roll = 0; |
| 1536 |
|
| 1537 |
p->pshader = pshader; |
| 1538 |
|
| 1539 |
p->endtime = cg.time + duration; |
| 1540 |
|
| 1541 |
p->startfade = p->endtime; |
| 1542 |
|
| 1543 |
p->width = 1; |
| 1544 |
p->height = 3; |
| 1545 |
|
| 1546 |
p->endheight = 3; |
| 1547 |
p->endwidth = 1; |
| 1548 |
|
| 1549 |
p->type = P_SMOKE; |
| 1550 |
|
| 1551 |
VectorCopy(cent->currentState.origin, p->org ); |
| 1552 |
|
| 1553 |
p->vel[0] = (cent->currentState.origin2[0] * (16 * ratio)); |
| 1554 |
p->vel[1] = (cent->currentState.origin2[1] * (16 * ratio)); |
| 1555 |
p->vel[2] = (cent->currentState.origin2[2]); |
| 1556 |
|
| 1557 |
p->snum = 1.0f; |
| 1558 |
|
| 1559 |
VectorClear( p->accel ); |
| 1560 |
|
| 1561 |
p->accel[2] = -20; |
| 1562 |
|
| 1563 |
p->rotate = qfalse; |
| 1564 |
|
| 1565 |
p->roll = rand()%179; |
| 1566 |
|
| 1567 |
p->alpha = 0.75; |
| 1568 |
|
| 1569 |
} |
| 1570 |
|
| 1571 |
|
| 1572 |
void CG_Particle_OilSlick (qhandle_t pshader, centity_t *cent) |
| 1573 |
{ |
| 1574 |
cparticle_t *p; |
| 1575 |
|
| 1576 |
if (!pshader) |
| 1577 |
CG_Printf ("CG_Particle_OilSlick == ZERO!\n"); |
| 1578 |
|
| 1579 |
if (!free_particles) |
| 1580 |
return; |
| 1581 |
p = free_particles; |
| 1582 |
free_particles = p->next; |
| 1583 |
p->next = active_particles; |
| 1584 |
active_particles = p; |
| 1585 |
p->time = cg.time; |
| 1586 |
|
| 1587 |
if (cent->currentState.angles2[2]) |
| 1588 |
p->endtime = cg.time + cent->currentState.angles2[2]; |
| 1589 |
else |
| 1590 |
p->endtime = cg.time + 60000; |
| 1591 |
|
| 1592 |
p->startfade = p->endtime; |
| 1593 |
|
| 1594 |
p->alpha = 1.0; |
| 1595 |
p->alphavel = 0; |
| 1596 |
p->roll = 0; |
| 1597 |
|
| 1598 |
p->pshader = pshader; |
| 1599 |
|
| 1600 |
if (cent->currentState.angles2[0] || cent->currentState.angles2[1]) |
| 1601 |
{ |
| 1602 |
p->width = cent->currentState.angles2[0]; |
| 1603 |
p->height = cent->currentState.angles2[0]; |
| 1604 |
|
| 1605 |
p->endheight = cent->currentState.angles2[1]; |
| 1606 |
p->endwidth = cent->currentState.angles2[1]; |
| 1607 |
} |
| 1608 |
else |
| 1609 |
{ |
| 1610 |
p->width = 8; |
| 1611 |
p->height = 8; |
| 1612 |
|
| 1613 |
p->endheight = 16; |
| 1614 |
p->endwidth = 16; |
| 1615 |
} |
| 1616 |
|
| 1617 |
p->type = P_FLAT_SCALEUP; |
| 1618 |
|
| 1619 |
p->snum = 1.0; |
| 1620 |
|
| 1621 |
VectorCopy(cent->currentState.origin, p->org ); |
| 1622 |
|
| 1623 |
p->org[2]+= 0.55 + (crandom() * 0.5); |
| 1624 |
|
| 1625 |
p->vel[0] = 0; |
| 1626 |
p->vel[1] = 0; |
| 1627 |
p->vel[2] = 0; |
| 1628 |
VectorClear( p->accel ); |
| 1629 |
|
| 1630 |
p->rotate = qfalse; |
| 1631 |
|
| 1632 |
p->roll = rand()%179; |
| 1633 |
|
| 1634 |
p->alpha = 0.75; |
| 1635 |
|
| 1636 |
} |
| 1637 |
|
| 1638 |
void CG_OilSlickRemove (centity_t *cent) |
| 1639 |
{ |
| 1640 |
cparticle_t *p, *next; |
| 1641 |
int id; |
| 1642 |
|
| 1643 |
id = 1.0f; |
| 1644 |
|
| 1645 |
if (!id) |
| 1646 |
CG_Printf ("CG_OilSlickRevove NULL id\n"); |
| 1647 |
|
| 1648 |
for (p=active_particles ; p ; p=next) |
| 1649 |
{ |
| 1650 |
next = p->next; |
| 1651 |
|
| 1652 |
if (p->type == P_FLAT_SCALEUP) |
| 1653 |
{ |
| 1654 |
if (p->snum == id) |
| 1655 |
{ |
| 1656 |
p->endtime = cg.time + 100; |
| 1657 |
p->startfade = p->endtime; |
| 1658 |
p->type = P_FLAT_SCALEUP_FADE; |
| 1659 |
|
| 1660 |
} |
| 1661 |
} |
| 1662 |
|
| 1663 |
} |
| 1664 |
} |
| 1665 |
|
| 1666 |
qboolean ValidBloodPool (vec3_t start) |
| 1667 |
{ |
| 1668 |
#define EXTRUDE_DIST 0.5 |
| 1669 |
|
| 1670 |
vec3_t angles; |
| 1671 |
vec3_t right, up; |
| 1672 |
vec3_t this_pos, x_pos, center_pos, end_pos; |
| 1673 |
int x, y; |
| 1674 |
int fwidth, fheight; |
| 1675 |
trace_t trace; |
| 1676 |
vec3_t normal; |
| 1677 |
|
| 1678 |
fwidth = 16; |
| 1679 |
fheight = 16; |
| 1680 |
|
| 1681 |
VectorSet (normal, 0, 0, 1); |
| 1682 |
|
| 1683 |
vectoangles (normal, angles); |
| 1684 |
AngleVectors (angles, NULL, right, up); |
| 1685 |
|
| 1686 |
VectorMA (start, EXTRUDE_DIST, normal, center_pos); |
| 1687 |
|
| 1688 |
for (x= -fwidth/2; x<fwidth; x+= fwidth) |
| 1689 |
{ |
| 1690 |
VectorMA (center_pos, x, right, x_pos); |
| 1691 |
|
| 1692 |
for (y= -fheight/2; y<fheight; y+= fheight) |
| 1693 |
{ |
| 1694 |
VectorMA (x_pos, y, up, this_pos); |
| 1695 |
VectorMA (this_pos, -EXTRUDE_DIST*2, normal, end_pos); |
| 1696 |
|
| 1697 |
CG_Trace (&trace, this_pos, NULL, NULL, end_pos, -1, CONTENTS_SOLID); |
| 1698 |
|
| 1699 |
|
| 1700 |
if (trace.entityNum < ENTITYNUM_WORLD) |
| 1701 |
return qfalse; |
| 1702 |
|
| 1703 |
if (!(!trace.startsolid && trace.fraction < 1)) |
| 1704 |
return qfalse; |
| 1705 |
|
| 1706 |
} |
| 1707 |
} |
| 1708 |
|
| 1709 |
return qtrue; |
| 1710 |
} |
| 1711 |
|
| 1712 |
void CG_BloodPool (localEntity_t *le, qhandle_t pshader, trace_t *tr) |
| 1713 |
{ |
| 1714 |
cparticle_t *p; |
| 1715 |
qboolean legit; |
| 1716 |
vec3_t start; |
| 1717 |
float rndSize; |
| 1718 |
|
| 1719 |
if (!pshader) |
| 1720 |
CG_Printf ("CG_BloodPool pshader == ZERO!\n"); |
| 1721 |
|
| 1722 |
if (!free_particles) |
| 1723 |
return; |
| 1724 |
|
| 1725 |
VectorCopy (tr->endpos, start); |
| 1726 |
legit = ValidBloodPool (start); |
| 1727 |
|
| 1728 |
if (!legit) |
| 1729 |
return; |
| 1730 |
|
| 1731 |
p = free_particles; |
| 1732 |
free_particles = p->next; |
| 1733 |
p->next = active_particles; |
| 1734 |
active_particles = p; |
| 1735 |
p->time = cg.time; |
| 1736 |
|
| 1737 |
p->endtime = cg.time + 3000; |
| 1738 |
p->startfade = p->endtime; |
| 1739 |
|
| 1740 |
p->alpha = 1.0; |
| 1741 |
p->alphavel = 0; |
| 1742 |
p->roll = 0; |
| 1743 |
|
| 1744 |
p->pshader = pshader; |
| 1745 |
|
| 1746 |
rndSize = 0.4 + random()*0.6; |
| 1747 |
|
| 1748 |
p->width = 8*rndSize; |
| 1749 |
p->height = 8*rndSize; |
| 1750 |
|
| 1751 |
p->endheight = 16*rndSize; |
| 1752 |
p->endwidth = 16*rndSize; |
| 1753 |
|
| 1754 |
p->type = P_FLAT_SCALEUP; |
| 1755 |
|
| 1756 |
VectorCopy(start, p->org ); |
| 1757 |
|
| 1758 |
p->vel[0] = 0; |
| 1759 |
p->vel[1] = 0; |
| 1760 |
p->vel[2] = 0; |
| 1761 |
VectorClear( p->accel ); |
| 1762 |
|
| 1763 |
p->rotate = qfalse; |
| 1764 |
|
| 1765 |
p->roll = rand()%179; |
| 1766 |
|
| 1767 |
p->alpha = 0.75; |
| 1768 |
|
| 1769 |
p->color = BLOODRED; |
| 1770 |
} |
| 1771 |
|
| 1772 |
#define NORMALSIZE 16 |
| 1773 |
#define LARGESIZE 32 |
| 1774 |
|
| 1775 |
void CG_ParticleBloodCloud (centity_t *cent, vec3_t origin, vec3_t dir) |
| 1776 |
{ |
| 1777 |
float length; |
| 1778 |
float dist; |
| 1779 |
float crittersize; |
| 1780 |
vec3_t angles, forward; |
| 1781 |
vec3_t point; |
| 1782 |
cparticle_t *p; |
| 1783 |
int i; |
| 1784 |
|
| 1785 |
dist = 0; |
| 1786 |
|
| 1787 |
length = VectorLength (dir); |
| 1788 |
vectoangles (dir, angles); |
| 1789 |
AngleVectors (angles, forward, NULL, NULL); |
| 1790 |
|
| 1791 |
crittersize = LARGESIZE; |
| 1792 |
|
| 1793 |
if (length) |
| 1794 |
dist = length / crittersize; |
| 1795 |
|
| 1796 |
if (dist < 1) |
| 1797 |
dist = 1; |
| 1798 |
|
| 1799 |
VectorCopy (origin, point); |
| 1800 |
|
| 1801 |
for (i=0; i<dist; i++) |
| 1802 |
{ |
| 1803 |
VectorMA (point, crittersize, forward, point); |
| 1804 |
|
| 1805 |
if (!free_particles) |
| 1806 |
return; |
| 1807 |
|
| 1808 |
p = free_particles; |
| 1809 |
free_particles = p->next; |
| 1810 |
p->next = active_particles; |
| 1811 |
active_particles = p; |
| 1812 |
|
| 1813 |
p->time = cg.time; |
| 1814 |
p->alpha = 1.0; |
| 1815 |
p->alphavel = 0; |
| 1816 |
p->roll = 0; |
| 1817 |
|
| 1818 |
p->pshader = cgs.media.smokePuffShader; |
| 1819 |
|
| 1820 |
p->endtime = cg.time + 350 + (crandom() * 100); |
| 1821 |
|
| 1822 |
p->startfade = cg.time; |
| 1823 |
|
| 1824 |
p->width = LARGESIZE; |
| 1825 |
p->height = LARGESIZE; |
| 1826 |
p->endheight = LARGESIZE; |
| 1827 |
p->endwidth = LARGESIZE; |
| 1828 |
|
| 1829 |
p->type = P_SMOKE; |
| 1830 |
|
| 1831 |
VectorCopy( origin, p->org ); |
| 1832 |
|
| 1833 |
p->vel[0] = 0; |
| 1834 |
p->vel[1] = 0; |
| 1835 |
p->vel[2] = -1; |
| 1836 |
|
| 1837 |
VectorClear( p->accel ); |
| 1838 |
|
| 1839 |
p->rotate = qfalse; |
| 1840 |
|
| 1841 |
p->roll = rand()%179; |
| 1842 |
|
| 1843 |
p->color = BLOODRED; |
| 1844 |
|
| 1845 |
p->alpha = 0.75; |
| 1846 |
|
| 1847 |
} |
| 1848 |
|
| 1849 |
|
| 1850 |
} |
| 1851 |
|
| 1852 |
void CG_ParticleSparks (vec3_t org, vec3_t vel, int duration, float x, float y, float speed) |
| 1853 |
{ |
| 1854 |
cparticle_t *p; |
| 1855 |
|
| 1856 |
if (!free_particles) |
| 1857 |
return; |
| 1858 |
p = free_particles; |
| 1859 |
free_particles = p->next; |
| 1860 |
p->next = active_particles; |
| 1861 |
active_particles = p; |
| 1862 |
p->time = cg.time; |
| 1863 |
|
| 1864 |
p->endtime = cg.time + duration; |
| 1865 |
p->startfade = cg.time + duration/2; |
| 1866 |
|
| 1867 |
p->color = EMISIVEFADE; |
| 1868 |
p->alpha = 0.4f; |
| 1869 |
p->alphavel = 0; |
| 1870 |
|
| 1871 |
p->height = 0.5; |
| 1872 |
p->width = 0.5; |
| 1873 |
p->endheight = 0.5; |
| 1874 |
p->endwidth = 0.5; |
| 1875 |
|
| 1876 |
p->pshader = cgs.media.tracerShader; |
| 1877 |
|
| 1878 |
p->type = P_SMOKE; |
| 1879 |
|
| 1880 |
VectorCopy(org, p->org); |
| 1881 |
|
| 1882 |
p->org[0] += (crandom() * x); |
| 1883 |
p->org[1] += (crandom() * y); |
| 1884 |
|
| 1885 |
p->vel[0] = vel[0]; |
| 1886 |
p->vel[1] = vel[1]; |
| 1887 |
p->vel[2] = vel[2]; |
| 1888 |
|
| 1889 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 1890 |
|
| 1891 |
p->vel[0] += (crandom() * 4); |
| 1892 |
p->vel[1] += (crandom() * 4); |
| 1893 |
p->vel[2] += (20 + (crandom() * 10)) * speed; |
| 1894 |
|
| 1895 |
p->accel[0] = crandom () * 4; |
| 1896 |
p->accel[1] = crandom () * 4; |
| 1897 |
|
| 1898 |
} |
| 1899 |
|
| 1900 |
void CG_ParticleDust (centity_t *cent, vec3_t origin, vec3_t dir) |
| 1901 |
{ |
| 1902 |
float length; |
| 1903 |
float dist; |
| 1904 |
float crittersize; |
| 1905 |
vec3_t angles, forward; |
| 1906 |
vec3_t point; |
| 1907 |
cparticle_t *p; |
| 1908 |
int i; |
| 1909 |
|
| 1910 |
dist = 0; |
| 1911 |
|
| 1912 |
VectorNegate (dir, dir); |
| 1913 |
length = VectorLength (dir); |
| 1914 |
vectoangles (dir, angles); |
| 1915 |
AngleVectors (angles, forward, NULL, NULL); |
| 1916 |
|
| 1917 |
crittersize = LARGESIZE; |
| 1918 |
|
| 1919 |
if (length) |
| 1920 |
dist = length / crittersize; |
| 1921 |
|
| 1922 |
if (dist < 1) |
| 1923 |
dist = 1; |
| 1924 |
|
| 1925 |
VectorCopy (origin, point); |
| 1926 |
|
| 1927 |
for (i=0; i<dist; i++) |
| 1928 |
{ |
| 1929 |
VectorMA (point, crittersize, forward, point); |
| 1930 |
|
| 1931 |
if (!free_particles) |
| 1932 |
return; |
| 1933 |
|
| 1934 |
p = free_particles; |
| 1935 |
free_particles = p->next; |
| 1936 |
p->next = active_particles; |
| 1937 |
active_particles = p; |
| 1938 |
|
| 1939 |
p->time = cg.time; |
| 1940 |
p->alpha = 5.0; |
| 1941 |
p->alphavel = 0; |
| 1942 |
p->roll = 0; |
| 1943 |
|
| 1944 |
p->pshader = cgs.media.smokePuffShader; |
| 1945 |
|
| 1946 |
|
| 1947 |
if (length) |
| 1948 |
p->endtime = cg.time + 4500 + (crandom() * 3500); |
| 1949 |
else |
| 1950 |
p->endtime = cg.time + 750 + (crandom() * 500); |
| 1951 |
|
| 1952 |
p->startfade = cg.time; |
| 1953 |
|
| 1954 |
p->width = LARGESIZE; |
| 1955 |
p->height = LARGESIZE; |
| 1956 |
|
| 1957 |
|
| 1958 |
p->endheight = LARGESIZE*3.0; |
| 1959 |
p->endwidth = LARGESIZE*3.0; |
| 1960 |
|
| 1961 |
if (!length) |
| 1962 |
{ |
| 1963 |
p->width *= 0.2f; |
| 1964 |
p->height *= 0.2f; |
| 1965 |
|
| 1966 |
p->endheight = NORMALSIZE; |
| 1967 |
p->endwidth = NORMALSIZE; |
| 1968 |
} |
| 1969 |
|
| 1970 |
p->type = P_SMOKE; |
| 1971 |
|
| 1972 |
VectorCopy( point, p->org ); |
| 1973 |
|
| 1974 |
p->vel[0] = crandom()*6; |
| 1975 |
p->vel[1] = crandom()*6; |
| 1976 |
p->vel[2] = random()*20; |
| 1977 |
|
| 1978 |
|
| 1979 |
p->accel[0] = crandom()*3; |
| 1980 |
p->accel[1] = crandom()*3; |
| 1981 |
p->accel[2] = -PARTICLE_GRAVITY*0.4; |
| 1982 |
|
| 1983 |
VectorClear( p->accel ); |
| 1984 |
|
| 1985 |
p->rotate = qfalse; |
| 1986 |
|
| 1987 |
p->roll = rand()%179; |
| 1988 |
|
| 1989 |
p->alpha = 0.75; |
| 1990 |
|
| 1991 |
} |
| 1992 |
|
| 1993 |
|
| 1994 |
} |
| 1995 |
|
| 1996 |
void CG_ParticleMisc (qhandle_t pshader, vec3_t origin, int size, int duration, float alpha) |
| 1997 |
{ |
| 1998 |
cparticle_t *p; |
| 1999 |
|
| 2000 |
if (!pshader) |
| 2001 |
CG_Printf ("CG_ParticleImpactSmokePuff pshader == ZERO!\n"); |
| 2002 |
|
| 2003 |
if (!free_particles) |
| 2004 |
return; |
| 2005 |
|
| 2006 |
p = free_particles; |
| 2007 |
free_particles = p->next; |
| 2008 |
p->next = active_particles; |
| 2009 |
active_particles = p; |
| 2010 |
p->time = cg.time; |
| 2011 |
p->alpha = 1.0; |
| 2012 |
p->alphavel = 0; |
| 2013 |
p->roll = rand()%179; |
| 2014 |
|
| 2015 |
p->pshader = pshader; |
| 2016 |
|
| 2017 |
if (duration > 0) |
| 2018 |
p->endtime = cg.time + duration; |
| 2019 |
else |
| 2020 |
p->endtime = duration; |
| 2021 |
|
| 2022 |
p->startfade = cg.time; |
| 2023 |
|
| 2024 |
p->width = size; |
| 2025 |
p->height = size; |
| 2026 |
|
| 2027 |
p->endheight = size; |
| 2028 |
p->endwidth = size; |
| 2029 |
|
| 2030 |
p->type = P_SPRITE; |
| 2031 |
|
| 2032 |
VectorCopy( origin, p->org ); |
| 2033 |
|
| 2034 |
p->rotate = qfalse; |
| 2035 |
} |