| 1 |
/* |
| 2 |
=========================================================================== |
| 3 |
Copyright (C) 1999-2005 Id Software, Inc. |
| 4 |
|
| 5 |
This file is part of Quake III Arena source code. |
| 6 |
|
| 7 |
Quake III Arena source code is free software; you can redistribute it |
| 8 |
and/or modify it under the terms of the GNU General Public License as |
| 9 |
published by the Free Software Foundation; either version 2 of the License, |
| 10 |
or (at your option) any later version. |
| 11 |
|
| 12 |
Quake III Arena source code is distributed in the hope that it will be |
| 13 |
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with Quake III Arena source code; if not, write to the Free Software |
| 19 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 |
=========================================================================== |
| 21 |
*/ |
| 22 |
// |
| 23 |
// cg_marks.c -- wall marks |
| 24 |
|
| 25 |
#include "cg_local.h" |
| 26 |
|
| 27 |
/* |
| 28 |
=================================================================== |
| 29 |
|
| 30 |
MARK POLYS |
| 31 |
|
| 32 |
=================================================================== |
| 33 |
*/ |
| 34 |
|
| 35 |
|
| 36 |
markPoly_t cg_activeMarkPolys; // double linked list |
| 37 |
markPoly_t *cg_freeMarkPolys; // single linked list |
| 38 |
markPoly_t cg_markPolys[MAX_MARK_POLYS]; |
| 39 |
static int markTotal; |
| 40 |
|
| 41 |
/* |
| 42 |
=================== |
| 43 |
CG_InitMarkPolys |
| 44 |
|
| 45 |
This is called at startup and for tournement restarts |
| 46 |
=================== |
| 47 |
*/ |
| 48 |
void CG_InitMarkPolys( void ) { |
| 49 |
int i; |
| 50 |
|
| 51 |
memset( cg_markPolys, 0, sizeof(cg_markPolys) ); |
| 52 |
|
| 53 |
cg_activeMarkPolys.nextMark = &cg_activeMarkPolys; |
| 54 |
cg_activeMarkPolys.prevMark = &cg_activeMarkPolys; |
| 55 |
cg_freeMarkPolys = cg_markPolys; |
| 56 |
for ( i = 0 ; i < MAX_MARK_POLYS - 1 ; i++ ) { |
| 57 |
cg_markPolys[i].nextMark = &cg_markPolys[i+1]; |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
/* |
| 63 |
================== |
| 64 |
CG_FreeMarkPoly |
| 65 |
================== |
| 66 |
*/ |
| 67 |
void CG_FreeMarkPoly( markPoly_t *le ) { |
| 68 |
if ( !le->prevMark ) { |
| 69 |
CG_Error( "CG_FreeLocalEntity: not active" ); |
| 70 |
} |
| 71 |
|
| 72 |
// remove from the doubly linked active list |
| 73 |
le->prevMark->nextMark = le->nextMark; |
| 74 |
le->nextMark->prevMark = le->prevMark; |
| 75 |
|
| 76 |
// the free list is only singly linked |
| 77 |
le->nextMark = cg_freeMarkPolys; |
| 78 |
cg_freeMarkPolys = le; |
| 79 |
} |
| 80 |
|
| 81 |
/* |
| 82 |
=================== |
| 83 |
CG_AllocMark |
| 84 |
|
| 85 |
Will allways succeed, even if it requires freeing an old active mark |
| 86 |
=================== |
| 87 |
*/ |
| 88 |
markPoly_t *CG_AllocMark( void ) { |
| 89 |
markPoly_t *le; |
| 90 |
int time; |
| 91 |
|
| 92 |
if ( !cg_freeMarkPolys ) { |
| 93 |
// no free entities, so free the one at the end of the chain |
| 94 |
// remove the oldest active entity |
| 95 |
time = cg_activeMarkPolys.prevMark->time; |
| 96 |
while (cg_activeMarkPolys.prevMark && time == cg_activeMarkPolys.prevMark->time) { |
| 97 |
CG_FreeMarkPoly( cg_activeMarkPolys.prevMark ); |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
le = cg_freeMarkPolys; |
| 102 |
cg_freeMarkPolys = cg_freeMarkPolys->nextMark; |
| 103 |
|
| 104 |
memset( le, 0, sizeof( *le ) ); |
| 105 |
|
| 106 |
// link into the active list |
| 107 |
le->nextMark = cg_activeMarkPolys.nextMark; |
| 108 |
le->prevMark = &cg_activeMarkPolys; |
| 109 |
cg_activeMarkPolys.nextMark->prevMark = le; |
| 110 |
cg_activeMarkPolys.nextMark = le; |
| 111 |
return le; |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
/* |
| 117 |
================= |
| 118 |
CG_ImpactMark |
| 119 |
|
| 120 |
origin should be a point within a unit of the plane |
| 121 |
dir should be the plane normal |
| 122 |
|
| 123 |
temporary marks will not be stored or randomly oriented, but immediately |
| 124 |
passed to the renderer. |
| 125 |
================= |
| 126 |
*/ |
| 127 |
#define MAX_MARK_FRAGMENTS 128 |
| 128 |
#define MAX_MARK_POINTS 384 |
| 129 |
|
| 130 |
void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir, |
| 131 |
float orientation, float red, float green, float blue, float alpha, |
| 132 |
qboolean alphaFade, float radius, qboolean temporary ) { |
| 133 |
vec3_t axis[3]; |
| 134 |
float texCoordScale; |
| 135 |
vec3_t originalPoints[4]; |
| 136 |
byte colors[4]; |
| 137 |
int i, j; |
| 138 |
int numFragments; |
| 139 |
markFragment_t markFragments[MAX_MARK_FRAGMENTS], *mf; |
| 140 |
vec3_t markPoints[MAX_MARK_POINTS]; |
| 141 |
vec3_t projection; |
| 142 |
|
| 143 |
if ( !cg_addMarks.integer ) { |
| 144 |
return; |
| 145 |
} |
| 146 |
|
| 147 |
if ( radius <= 0 ) { |
| 148 |
CG_Error( "CG_ImpactMark called with <= 0 radius" ); |
| 149 |
} |
| 150 |
|
| 151 |
//if ( markTotal >= MAX_MARK_POLYS ) { |
| 152 |
// return; |
| 153 |
//} |
| 154 |
|
| 155 |
// create the texture axis |
| 156 |
VectorNormalize2( dir, axis[0] ); |
| 157 |
PerpendicularVector( axis[1], axis[0] ); |
| 158 |
if (cg_leiEnhancement.integer) // LEILEI HACK HACK HACK - don't spin atlas variated particles (for consistent lighting on the texture) |
| 159 |
orientation = 90; |
| 160 |
|
| 161 |
RotatePointAroundVector( axis[2], axis[0], axis[1], orientation ); |
| 162 |
CrossProduct( axis[0], axis[2], axis[1] ); |
| 163 |
|
| 164 |
texCoordScale = 0.5 * 1.0 / radius; |
| 165 |
|
| 166 |
// create the full polygon |
| 167 |
for ( i = 0 ; i < 3 ; i++ ) { |
| 168 |
originalPoints[0][i] = origin[i] - radius * axis[1][i] - radius * axis[2][i]; |
| 169 |
originalPoints[1][i] = origin[i] + radius * axis[1][i] - radius * axis[2][i]; |
| 170 |
originalPoints[2][i] = origin[i] + radius * axis[1][i] + radius * axis[2][i]; |
| 171 |
originalPoints[3][i] = origin[i] - radius * axis[1][i] + radius * axis[2][i]; |
| 172 |
} |
| 173 |
|
| 174 |
// get the fragments |
| 175 |
VectorScale( dir, -20, projection ); |
| 176 |
numFragments = trap_CM_MarkFragments( 4, (void *)originalPoints, |
| 177 |
projection, MAX_MARK_POINTS, markPoints[0], |
| 178 |
MAX_MARK_FRAGMENTS, markFragments ); |
| 179 |
|
| 180 |
colors[0] = red * 255; |
| 181 |
colors[1] = green * 255; |
| 182 |
colors[2] = blue * 255; |
| 183 |
colors[3] = alpha * 255; |
| 184 |
|
| 185 |
for ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ ) { |
| 186 |
polyVert_t *v; |
| 187 |
polyVert_t verts[MAX_VERTS_ON_POLY]; |
| 188 |
markPoly_t *mark; |
| 189 |
|
| 190 |
// we have an upper limit on the complexity of polygons |
| 191 |
// that we store persistantly |
| 192 |
if ( mf->numPoints > MAX_VERTS_ON_POLY ) { |
| 193 |
mf->numPoints = MAX_VERTS_ON_POLY; |
| 194 |
} |
| 195 |
for ( j = 0, v = verts ; j < mf->numPoints ; j++, v++ ) { |
| 196 |
vec3_t delta; |
| 197 |
|
| 198 |
VectorCopy( markPoints[mf->firstPoint + j], v->xyz ); |
| 199 |
|
| 200 |
VectorSubtract( v->xyz, origin, delta ); |
| 201 |
v->st[0] = 0.5 + DotProduct( delta, axis[1] ) * texCoordScale; |
| 202 |
v->st[1] = 0.5 + DotProduct( delta, axis[2] ) * texCoordScale; |
| 203 |
*(int *)v->modulate = *(int *)colors; |
| 204 |
} |
| 205 |
|
| 206 |
// if it is a temporary (shadow) mark, add it immediately and forget about it |
| 207 |
if ( temporary ) { |
| 208 |
trap_R_AddPolyToScene( markShader, mf->numPoints, verts ); |
| 209 |
continue; |
| 210 |
} |
| 211 |
|
| 212 |
// otherwise save it persistantly |
| 213 |
mark = CG_AllocMark(); |
| 214 |
mark->time = cg.time; |
| 215 |
mark->alphaFade = alphaFade; |
| 216 |
mark->markShader = markShader; |
| 217 |
mark->poly.numVerts = mf->numPoints; |
| 218 |
mark->color[0] = red; |
| 219 |
mark->color[1] = green; |
| 220 |
mark->color[2] = blue; |
| 221 |
mark->color[3] = alpha; |
| 222 |
memcpy( mark->verts, verts, mf->numPoints * sizeof( verts[0] ) ); |
| 223 |
markTotal++; |
| 224 |
} |
| 225 |
} |
| 226 |
|
| 227 |
|
| 228 |
/* |
| 229 |
=============== |
| 230 |
CG_AddMarks |
| 231 |
=============== |
| 232 |
*/ |
| 233 |
#define MARK_TOTAL_TIME 10000 |
| 234 |
#define MARK_FADE_TIME 1000 |
| 235 |
|
| 236 |
void CG_AddMarks( void ) { |
| 237 |
int j; |
| 238 |
markPoly_t *mp, *next; |
| 239 |
int t; |
| 240 |
int fade; |
| 241 |
|
| 242 |
if ( !cg_addMarks.integer ) { |
| 243 |
return; |
| 244 |
} |
| 245 |
|
| 246 |
mp = cg_activeMarkPolys.nextMark; |
| 247 |
for ( ; mp != &cg_activeMarkPolys ; mp = next ) { |
| 248 |
// grab next now, so if the local entity is freed we |
| 249 |
// still have it |
| 250 |
next = mp->nextMark; |
| 251 |
|
| 252 |
// see if it is time to completely remove it |
| 253 |
if ( cg.time > mp->time + MARK_TOTAL_TIME ) { |
| 254 |
CG_FreeMarkPoly( mp ); |
| 255 |
continue; |
| 256 |
} |
| 257 |
|
| 258 |
// fade out the energy bursts |
| 259 |
if ( mp->markShader == cgs.media.energyMarkShader ) { |
| 260 |
|
| 261 |
fade = 450 - 450 * ( (cg.time - mp->time ) / 3000.0 ); |
| 262 |
if ( fade < 255 ) { |
| 263 |
if ( fade < 0 ) { |
| 264 |
fade = 0; |
| 265 |
} |
| 266 |
if ( mp->verts[0].modulate[0] != 0 ) { |
| 267 |
for ( j = 0 ; j < mp->poly.numVerts ; j++ ) { |
| 268 |
mp->verts[j].modulate[0] = mp->color[0] * fade; |
| 269 |
mp->verts[j].modulate[1] = mp->color[1] * fade; |
| 270 |
mp->verts[j].modulate[2] = mp->color[2] * fade; |
| 271 |
} |
| 272 |
} |
| 273 |
} |
| 274 |
} |
| 275 |
|
| 276 |
// fade all marks out with time |
| 277 |
t = mp->time + MARK_TOTAL_TIME - cg.time; |
| 278 |
if ( t < MARK_FADE_TIME ) { |
| 279 |
fade = 255 * t / MARK_FADE_TIME; |
| 280 |
if ( mp->alphaFade ) { |
| 281 |
for ( j = 0 ; j < mp->poly.numVerts ; j++ ) { |
| 282 |
mp->verts[j].modulate[3] = fade; |
| 283 |
} |
| 284 |
} else { |
| 285 |
for ( j = 0 ; j < mp->poly.numVerts ; j++ ) { |
| 286 |
mp->verts[j].modulate[0] = mp->color[0] * fade; |
| 287 |
mp->verts[j].modulate[1] = mp->color[1] * fade; |
| 288 |
mp->verts[j].modulate[2] = mp->color[2] * fade; |
| 289 |
} |
| 290 |
} |
| 291 |
} |
| 292 |
|
| 293 |
|
| 294 |
trap_R_AddPolyToScene( mp->markShader, mp->poly.numVerts, mp->verts ); |
| 295 |
} |
| 296 |
} |
| 297 |
|
| 298 |
// cg_particles.c |
| 299 |
|
| 300 |
#define BLOODRED 2 |
| 301 |
#define EMISIVEFADE 3 |
| 302 |
#define GREY75 4 |
| 303 |
|
| 304 |
typedef struct particle_s |
| 305 |
{ |
| 306 |
struct particle_s *next; |
| 307 |
|
| 308 |
float time; |
| 309 |
float endtime; |
| 310 |
|
| 311 |
vec3_t org; |
| 312 |
vec3_t vel; |
| 313 |
vec3_t accel; |
| 314 |
int color; |
| 315 |
float colorvel; |
| 316 |
float alpha; |
| 317 |
float alphavel; |
| 318 |
int type; |
| 319 |
qhandle_t pshader; |
| 320 |
|
| 321 |
float height; |
| 322 |
float width; |
| 323 |
|
| 324 |
float endheight; |
| 325 |
float endwidth; |
| 326 |
|
| 327 |
float start; |
| 328 |
float end; |
| 329 |
|
| 330 |
float startfade; |
| 331 |
qboolean rotate; |
| 332 |
int snum; |
| 333 |
|
| 334 |
qboolean link; |
| 335 |
|
| 336 |
// Ridah |
| 337 |
int shaderAnim; |
| 338 |
int roll; |
| 339 |
|
| 340 |
int accumroll; |
| 341 |
|
| 342 |
} cparticle_t; |
| 343 |
|
| 344 |
typedef enum |
| 345 |
{ |
| 346 |
P_NONE, |
| 347 |
P_WEATHER, |
| 348 |
P_FLAT, |
| 349 |
P_SMOKE, |
| 350 |
P_ROTATE, |
| 351 |
P_WEATHER_TURBULENT, |
| 352 |
P_ANIM, // Ridah |
| 353 |
P_BAT, |
| 354 |
P_BLEED, |
| 355 |
P_FLAT_SCALEUP, |
| 356 |
P_FLAT_SCALEUP_FADE, |
| 357 |
P_WEATHER_FLURRY, |
| 358 |
P_SMOKE_IMPACT, |
| 359 |
P_BUBBLE, |
| 360 |
P_BUBBLE_TURBULENT, |
| 361 |
P_SPRITE |
| 362 |
} particle_type_t; |
| 363 |
|
| 364 |
#define MAX_SHADER_ANIMS 32 |
| 365 |
#define MAX_SHADER_ANIM_FRAMES 64 |
| 366 |
|
| 367 |
static char *shaderAnimNames[MAX_SHADER_ANIMS] = { |
| 368 |
"explode1", |
| 369 |
NULL |
| 370 |
}; |
| 371 |
static qhandle_t shaderAnims[MAX_SHADER_ANIMS][MAX_SHADER_ANIM_FRAMES]; |
| 372 |
static int shaderAnimCounts[MAX_SHADER_ANIMS] = { |
| 373 |
23 |
| 374 |
}; |
| 375 |
static float shaderAnimSTRatio[MAX_SHADER_ANIMS] = { |
| 376 |
1.0f |
| 377 |
}; |
| 378 |
static int numShaderAnims; |
| 379 |
// done. |
| 380 |
|
| 381 |
#define PARTICLE_GRAVITY 40 |
| 382 |
#define MAX_PARTICLES 1024 |
| 383 |
|
| 384 |
cparticle_t *active_particles, *free_particles; |
| 385 |
cparticle_t particles[MAX_PARTICLES]; |
| 386 |
int cl_numparticles = MAX_PARTICLES; |
| 387 |
|
| 388 |
qboolean initparticles = qfalse; |
| 389 |
vec3_t pvforward, pvright, pvup; |
| 390 |
vec3_t rforward, rright, rup; |
| 391 |
|
| 392 |
float oldtime; |
| 393 |
|
| 394 |
/* |
| 395 |
=============== |
| 396 |
CL_ClearParticles |
| 397 |
=============== |
| 398 |
*/ |
| 399 |
void CG_ClearParticles (void) |
| 400 |
{ |
| 401 |
int i; |
| 402 |
|
| 403 |
memset( particles, 0, sizeof(particles) ); |
| 404 |
|
| 405 |
free_particles = &particles[0]; |
| 406 |
active_particles = NULL; |
| 407 |
|
| 408 |
for (i=0 ;i<cl_numparticles ; i++) |
| 409 |
{ |
| 410 |
particles[i].next = &particles[i+1]; |
| 411 |
particles[i].type = 0; |
| 412 |
} |
| 413 |
particles[cl_numparticles-1].next = NULL; |
| 414 |
|
| 415 |
oldtime = cg.time; |
| 416 |
|
| 417 |
// Ridah, init the shaderAnims |
| 418 |
for (i=0; shaderAnimNames[i]; i++) { |
| 419 |
int j; |
| 420 |
|
| 421 |
for (j=0; j<shaderAnimCounts[i]; j++) { |
| 422 |
shaderAnims[i][j] = trap_R_RegisterShader( va("%s%i", shaderAnimNames[i], j+1) ); |
| 423 |
} |
| 424 |
} |
| 425 |
numShaderAnims = i; |
| 426 |
// done. |
| 427 |
|
| 428 |
initparticles = qtrue; |
| 429 |
} |
| 430 |
|
| 431 |
|
| 432 |
/* |
| 433 |
===================== |
| 434 |
CG_AddParticleToScene |
| 435 |
===================== |
| 436 |
*/ |
| 437 |
void CG_AddParticleToScene (cparticle_t *p, vec3_t org, float alpha) |
| 438 |
{ |
| 439 |
|
| 440 |
vec3_t point; |
| 441 |
polyVert_t verts[4]; |
| 442 |
float width; |
| 443 |
float height; |
| 444 |
float time, time2; |
| 445 |
float ratio; |
| 446 |
float invratio; |
| 447 |
vec3_t color; |
| 448 |
polyVert_t TRIverts[3]; |
| 449 |
vec3_t rright2, rup2; |
| 450 |
|
| 451 |
if (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY |
| 452 |
|| p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) |
| 453 |
{// create a front facing polygon |
| 454 |
|
| 455 |
if (p->type != P_WEATHER_FLURRY) |
| 456 |
{ |
| 457 |
if (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) |
| 458 |
{ |
| 459 |
if (org[2] > p->end) |
| 460 |
{ |
| 461 |
p->time = cg.time; |
| 462 |
VectorCopy (org, p->org); // Ridah, fixes rare snow flakes that flicker on the ground |
| 463 |
|
| 464 |
p->org[2] = ( p->start + crandom () * 4 ); |
| 465 |
|
| 466 |
|
| 467 |
if (p->type == P_BUBBLE_TURBULENT) |
| 468 |
{ |
| 469 |
p->vel[0] = crandom() * 4; |
| 470 |
p->vel[1] = crandom() * 4; |
| 471 |
} |
| 472 |
|
| 473 |
} |
| 474 |
} |
| 475 |
else |
| 476 |
{ |
| 477 |
if (org[2] < p->end) |
| 478 |
{ |
| 479 |
p->time = cg.time; |
| 480 |
VectorCopy (org, p->org); // Ridah, fixes rare snow flakes that flicker on the ground |
| 481 |
|
| 482 |
while (p->org[2] < p->end) |
| 483 |
{ |
| 484 |
p->org[2] += (p->start - p->end); |
| 485 |
} |
| 486 |
|
| 487 |
|
| 488 |
if (p->type == P_WEATHER_TURBULENT) |
| 489 |
{ |
| 490 |
p->vel[0] = crandom() * 16; |
| 491 |
p->vel[1] = crandom() * 16; |
| 492 |
} |
| 493 |
|
| 494 |
} |
| 495 |
} |
| 496 |
|
| 497 |
|
| 498 |
// Rafael snow pvs check |
| 499 |
if (!p->link) |
| 500 |
return; |
| 501 |
|
| 502 |
p->alpha = 1; |
| 503 |
} |
| 504 |
|
| 505 |
// Ridah, had to do this or MAX_POLYS is being exceeded in village1.bsp |
| 506 |
if (Distance( cg.snap->ps.origin, org ) > 1024) { |
| 507 |
return; |
| 508 |
} |
| 509 |
// done. |
| 510 |
|
| 511 |
if (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) |
| 512 |
{ |
| 513 |
VectorMA (org, -p->height, pvup, point); |
| 514 |
VectorMA (point, -p->width, pvright, point); |
| 515 |
VectorCopy (point, verts[0].xyz); |
| 516 |
verts[0].st[0] = 0; |
| 517 |
verts[0].st[1] = 0; |
| 518 |
verts[0].modulate[0] = 255; |
| 519 |
verts[0].modulate[1] = 255; |
| 520 |
verts[0].modulate[2] = 255; |
| 521 |
verts[0].modulate[3] = 255 * p->alpha; |
| 522 |
|
| 523 |
VectorMA (org, -p->height, pvup, point); |
| 524 |
VectorMA (point, p->width, pvright, point); |
| 525 |
VectorCopy (point, verts[1].xyz); |
| 526 |
verts[1].st[0] = 0; |
| 527 |
verts[1].st[1] = 1; |
| 528 |
verts[1].modulate[0] = 255; |
| 529 |
verts[1].modulate[1] = 255; |
| 530 |
verts[1].modulate[2] = 255; |
| 531 |
verts[1].modulate[3] = 255 * p->alpha; |
| 532 |
|
| 533 |
VectorMA (org, p->height, pvup, point); |
| 534 |
VectorMA (point, p->width, pvright, point); |
| 535 |
VectorCopy (point, verts[2].xyz); |
| 536 |
verts[2].st[0] = 1; |
| 537 |
verts[2].st[1] = 1; |
| 538 |
verts[2].modulate[0] = 255; |
| 539 |
verts[2].modulate[1] = 255; |
| 540 |
verts[2].modulate[2] = 255; |
| 541 |
verts[2].modulate[3] = 255 * p->alpha; |
| 542 |
|
| 543 |
VectorMA (org, p->height, pvup, point); |
| 544 |
VectorMA (point, -p->width, pvright, point); |
| 545 |
VectorCopy (point, verts[3].xyz); |
| 546 |
verts[3].st[0] = 1; |
| 547 |
verts[3].st[1] = 0; |
| 548 |
verts[3].modulate[0] = 255; |
| 549 |
verts[3].modulate[1] = 255; |
| 550 |
verts[3].modulate[2] = 255; |
| 551 |
verts[3].modulate[3] = 255 * p->alpha; |
| 552 |
} |
| 553 |
else |
| 554 |
{ |
| 555 |
VectorMA (org, -p->height, pvup, point); |
| 556 |
VectorMA (point, -p->width, pvright, point); |
| 557 |
VectorCopy( point, TRIverts[0].xyz ); |
| 558 |
TRIverts[0].st[0] = 1; |
| 559 |
TRIverts[0].st[1] = 0; |
| 560 |
TRIverts[0].modulate[0] = 255; |
| 561 |
TRIverts[0].modulate[1] = 255; |
| 562 |
TRIverts[0].modulate[2] = 255; |
| 563 |
TRIverts[0].modulate[3] = 255 * p->alpha; |
| 564 |
|
| 565 |
VectorMA (org, p->height, pvup, point); |
| 566 |
VectorMA (point, -p->width, pvright, point); |
| 567 |
VectorCopy (point, TRIverts[1].xyz); |
| 568 |
TRIverts[1].st[0] = 0; |
| 569 |
TRIverts[1].st[1] = 0; |
| 570 |
TRIverts[1].modulate[0] = 255; |
| 571 |
TRIverts[1].modulate[1] = 255; |
| 572 |
TRIverts[1].modulate[2] = 255; |
| 573 |
TRIverts[1].modulate[3] = 255 * p->alpha; |
| 574 |
|
| 575 |
VectorMA (org, p->height, pvup, point); |
| 576 |
VectorMA (point, p->width, pvright, point); |
| 577 |
VectorCopy (point, TRIverts[2].xyz); |
| 578 |
TRIverts[2].st[0] = 0; |
| 579 |
TRIverts[2].st[1] = 1; |
| 580 |
TRIverts[2].modulate[0] = 255; |
| 581 |
TRIverts[2].modulate[1] = 255; |
| 582 |
TRIverts[2].modulate[2] = 255; |
| 583 |
TRIverts[2].modulate[3] = 255 * p->alpha; |
| 584 |
} |
| 585 |
|
| 586 |
} |
| 587 |
else if (p->type == P_SPRITE) |
| 588 |
{ |
| 589 |
vec3_t rr, ru; |
| 590 |
vec3_t rotate_ang; |
| 591 |
|
| 592 |
VectorSet (color, 1.0, 1.0, 0.5); |
| 593 |
time = cg.time - p->time; |
| 594 |
time2 = p->endtime - p->time; |
| 595 |
ratio = time / time2; |
| 596 |
|
| 597 |
width = p->width + ( ratio * ( p->endwidth - p->width) ); |
| 598 |
height = p->height + ( ratio * ( p->endheight - p->height) ); |
| 599 |
|
| 600 |
if (p->roll) { |
| 601 |
vectoangles( cg.refdef.viewaxis[0], rotate_ang ); |
| 602 |
rotate_ang[ROLL] += p->roll; |
| 603 |
AngleVectors ( rotate_ang, NULL, rr, ru); |
| 604 |
} |
| 605 |
|
| 606 |
if (p->roll) { |
| 607 |
VectorMA (org, -height, ru, point); |
| 608 |
VectorMA (point, -width, rr, point); |
| 609 |
} else { |
| 610 |
VectorMA (org, -height, pvup, point); |
| 611 |
VectorMA (point, -width, pvright, point); |
| 612 |
} |
| 613 |
VectorCopy (point, verts[0].xyz); |
| 614 |
verts[0].st[0] = 0; |
| 615 |
verts[0].st[1] = 0; |
| 616 |
verts[0].modulate[0] = 255; |
| 617 |
verts[0].modulate[1] = 255; |
| 618 |
verts[0].modulate[2] = 255; |
| 619 |
verts[0].modulate[3] = 255; |
| 620 |
|
| 621 |
if (p->roll) { |
| 622 |
VectorMA (point, 2*height, ru, point); |
| 623 |
} else { |
| 624 |
VectorMA (point, 2*height, pvup, point); |
| 625 |
} |
| 626 |
VectorCopy (point, verts[1].xyz); |
| 627 |
verts[1].st[0] = 0; |
| 628 |
verts[1].st[1] = 1; |
| 629 |
verts[1].modulate[0] = 255; |
| 630 |
verts[1].modulate[1] = 255; |
| 631 |
verts[1].modulate[2] = 255; |
| 632 |
verts[1].modulate[3] = 255; |
| 633 |
|
| 634 |
if (p->roll) { |
| 635 |
VectorMA (point, 2*width, rr, point); |
| 636 |
} else { |
| 637 |
VectorMA (point, 2*width, pvright, point); |
| 638 |
} |
| 639 |
VectorCopy (point, verts[2].xyz); |
| 640 |
verts[2].st[0] = 1; |
| 641 |
verts[2].st[1] = 1; |
| 642 |
verts[2].modulate[0] = 255; |
| 643 |
verts[2].modulate[1] = 255; |
| 644 |
verts[2].modulate[2] = 255; |
| 645 |
verts[2].modulate[3] = 255; |
| 646 |
|
| 647 |
if (p->roll) { |
| 648 |
VectorMA (point, -2*height, ru, point); |
| 649 |
} else { |
| 650 |
VectorMA (point, -2*height, pvup, point); |
| 651 |
} |
| 652 |
VectorCopy (point, verts[3].xyz); |
| 653 |
verts[3].st[0] = 1; |
| 654 |
verts[3].st[1] = 0; |
| 655 |
verts[3].modulate[0] = 255; |
| 656 |
verts[3].modulate[1] = 255; |
| 657 |
verts[3].modulate[2] = 255; |
| 658 |
verts[3].modulate[3] = 255; |
| 659 |
} |
| 660 |
else if (p->type == P_SMOKE || p->type == P_SMOKE_IMPACT) |
| 661 |
{// create a front rotating facing polygon |
| 662 |
|
| 663 |
if ( p->type == P_SMOKE_IMPACT && Distance( cg.snap->ps.origin, org ) > 1024) { |
| 664 |
return; |
| 665 |
} |
| 666 |
|
| 667 |
if (p->color == BLOODRED) |
| 668 |
VectorSet (color, 0.22f, 0.0f, 0.0f); |
| 669 |
else if (p->color == GREY75) |
| 670 |
{ |
| 671 |
float len; |
| 672 |
float greyit; |
| 673 |
float val; |
| 674 |
len = Distance (cg.snap->ps.origin, org); |
| 675 |
if (!len) |
| 676 |
len = 1; |
| 677 |
|
| 678 |
val = 4096/len; |
| 679 |
greyit = 0.25 * val; |
| 680 |
if (greyit > 0.5) |
| 681 |
greyit = 0.5; |
| 682 |
|
| 683 |
VectorSet (color, greyit, greyit, greyit); |
| 684 |
} |
| 685 |
else |
| 686 |
VectorSet (color, 1.0, 1.0, 1.0); |
| 687 |
|
| 688 |
time = cg.time - p->time; |
| 689 |
time2 = p->endtime - p->time; |
| 690 |
ratio = time / time2; |
| 691 |
|
| 692 |
if (cg.time > p->startfade) |
| 693 |
{ |
| 694 |
invratio = 1 - ( (cg.time - p->startfade) / (p->endtime - p->startfade) ); |
| 695 |
|
| 696 |
if (p->color == EMISIVEFADE) |
| 697 |
{ |
| 698 |
float fval; |
| 699 |
fval = (invratio * invratio); |
| 700 |
if (fval < 0) |
| 701 |
fval = 0; |
| 702 |
VectorSet (color, fval , fval , fval ); |
| 703 |
} |
| 704 |
invratio *= p->alpha; |
| 705 |
} |
| 706 |
else |
| 707 |
invratio = 1 * p->alpha; |
| 708 |
|
| 709 |
if ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) |
| 710 |
invratio = 1; |
| 711 |
|
| 712 |
if (invratio > 1) |
| 713 |
invratio = 1; |
| 714 |
|
| 715 |
width = p->width + ( ratio * ( p->endwidth - p->width) ); |
| 716 |
height = p->height + ( ratio * ( p->endheight - p->height) ); |
| 717 |
|
| 718 |
if (p->type != P_SMOKE_IMPACT) |
| 719 |
{ |
| 720 |
vec3_t temp; |
| 721 |
|
| 722 |
vectoangles (rforward, temp); |
| 723 |
p->accumroll += p->roll; |
| 724 |
temp[ROLL] += p->accumroll * 0.1; |
| 725 |
AngleVectors ( temp, NULL, rright2, rup2); |
| 726 |
} |
| 727 |
else |
| 728 |
{ |
| 729 |
VectorCopy (rright, rright2); |
| 730 |
VectorCopy (rup, rup2); |
| 731 |
} |
| 732 |
|
| 733 |
if (p->rotate) |
| 734 |
{ |
| 735 |
VectorMA (org, -height, rup2, point); |
| 736 |
VectorMA (point, -width, rright2, point); |
| 737 |
} |
| 738 |
else |
| 739 |
{ |
| 740 |
VectorMA (org, -p->height, pvup, point); |
| 741 |
VectorMA (point, -p->width, pvright, point); |
| 742 |
} |
| 743 |
VectorCopy (point, verts[0].xyz); |
| 744 |
verts[0].st[0] = 0; |
| 745 |
verts[0].st[1] = 0; |
| 746 |
verts[0].modulate[0] = 255 * color[0]; |
| 747 |
verts[0].modulate[1] = 255 * color[1]; |
| 748 |
verts[0].modulate[2] = 255 * color[2]; |
| 749 |
verts[0].modulate[3] = 255 * invratio; |
| 750 |
|
| 751 |
if (p->rotate) |
| 752 |
{ |
| 753 |
VectorMA (org, -height, rup2, point); |
| 754 |
VectorMA (point, width, rright2, point); |
| 755 |
} |
| 756 |
else |
| 757 |
{ |
| 758 |
VectorMA (org, -p->height, pvup, point); |
| 759 |
VectorMA (point, p->width, pvright, point); |
| 760 |
} |
| 761 |
VectorCopy (point, verts[1].xyz); |
| 762 |
verts[1].st[0] = 0; |
| 763 |
verts[1].st[1] = 1; |
| 764 |
verts[1].modulate[0] = 255 * color[0]; |
| 765 |
verts[1].modulate[1] = 255 * color[1]; |
| 766 |
verts[1].modulate[2] = 255 * color[2]; |
| 767 |
verts[1].modulate[3] = 255 * invratio; |
| 768 |
|
| 769 |
if (p->rotate) |
| 770 |
{ |
| 771 |
VectorMA (org, height, rup2, point); |
| 772 |
VectorMA (point, width, rright2, point); |
| 773 |
} |
| 774 |
else |
| 775 |
{ |
| 776 |
VectorMA (org, p->height, pvup, point); |
| 777 |
VectorMA (point, p->width, pvright, point); |
| 778 |
} |
| 779 |
VectorCopy (point, verts[2].xyz); |
| 780 |
verts[2].st[0] = 1; |
| 781 |
verts[2].st[1] = 1; |
| 782 |
verts[2].modulate[0] = 255 * color[0]; |
| 783 |
verts[2].modulate[1] = 255 * color[1]; |
| 784 |
verts[2].modulate[2] = 255 * color[2]; |
| 785 |
verts[2].modulate[3] = 255 * invratio; |
| 786 |
|
| 787 |
if (p->rotate) |
| 788 |
{ |
| 789 |
VectorMA (org, height, rup2, point); |
| 790 |
VectorMA (point, -width, rright2, point); |
| 791 |
} |
| 792 |
else |
| 793 |
{ |
| 794 |
VectorMA (org, p->height, pvup, point); |
| 795 |
VectorMA (point, -p->width, pvright, point); |
| 796 |
} |
| 797 |
VectorCopy (point, verts[3].xyz); |
| 798 |
verts[3].st[0] = 1; |
| 799 |
verts[3].st[1] = 0; |
| 800 |
verts[3].modulate[0] = 255 * color[0]; |
| 801 |
verts[3].modulate[1] = 255 * color[1]; |
| 802 |
verts[3].modulate[2] = 255 * color[2]; |
| 803 |
verts[3].modulate[3] = 255 * invratio; |
| 804 |
|
| 805 |
} |
| 806 |
else if (p->type == P_BLEED) |
| 807 |
{ |
| 808 |
vec3_t rr, ru; |
| 809 |
vec3_t rotate_ang; |
| 810 |
float alpha; |
| 811 |
|
| 812 |
alpha = p->alpha; |
| 813 |
|
| 814 |
if ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) |
| 815 |
alpha = 1; |
| 816 |
|
| 817 |
if (p->roll) |
| 818 |
{ |
| 819 |
vectoangles( cg.refdef.viewaxis[0], rotate_ang ); |
| 820 |
rotate_ang[ROLL] += p->roll; |
| 821 |
AngleVectors ( rotate_ang, NULL, rr, ru); |
| 822 |
} |
| 823 |
else |
| 824 |
{ |
| 825 |
VectorCopy (pvup, ru); |
| 826 |
VectorCopy (pvright, rr); |
| 827 |
} |
| 828 |
|
| 829 |
VectorMA (org, -p->height, ru, point); |
| 830 |
VectorMA (point, -p->width, rr, point); |
| 831 |
VectorCopy (point, verts[0].xyz); |
| 832 |
verts[0].st[0] = 0; |
| 833 |
verts[0].st[1] = 0; |
| 834 |
verts[0].modulate[0] = 111; |
| 835 |
verts[0].modulate[1] = 19; |
| 836 |
verts[0].modulate[2] = 9; |
| 837 |
verts[0].modulate[3] = 255 * alpha; |
| 838 |
|
| 839 |
VectorMA (org, -p->height, ru, point); |
| 840 |
VectorMA (point, p->width, rr, point); |
| 841 |
VectorCopy (point, verts[1].xyz); |
| 842 |
verts[1].st[0] = 0; |
| 843 |
verts[1].st[1] = 1; |
| 844 |
verts[1].modulate[0] = 111; |
| 845 |
verts[1].modulate[1] = 19; |
| 846 |
verts[1].modulate[2] = 9; |
| 847 |
verts[1].modulate[3] = 255 * alpha; |
| 848 |
|
| 849 |
VectorMA (org, p->height, ru, point); |
| 850 |
VectorMA (point, p->width, rr, point); |
| 851 |
VectorCopy (point, verts[2].xyz); |
| 852 |
verts[2].st[0] = 1; |
| 853 |
verts[2].st[1] = 1; |
| 854 |
verts[2].modulate[0] = 111; |
| 855 |
verts[2].modulate[1] = 19; |
| 856 |
verts[2].modulate[2] = 9; |
| 857 |
verts[2].modulate[3] = 255 * alpha; |
| 858 |
|
| 859 |
VectorMA (org, p->height, ru, point); |
| 860 |
VectorMA (point, -p->width, rr, point); |
| 861 |
VectorCopy (point, verts[3].xyz); |
| 862 |
verts[3].st[0] = 1; |
| 863 |
verts[3].st[1] = 0; |
| 864 |
verts[3].modulate[0] = 111; |
| 865 |
verts[3].modulate[1] = 19; |
| 866 |
verts[3].modulate[2] = 9; |
| 867 |
verts[3].modulate[3] = 255 * alpha; |
| 868 |
|
| 869 |
} |
| 870 |
else if (p->type == P_FLAT_SCALEUP) |
| 871 |
{ |
| 872 |
float width, height; |
| 873 |
float sinR, cosR; |
| 874 |
|
| 875 |
if (p->color == BLOODRED) |
| 876 |
VectorSet (color, 1, 1, 1); |
| 877 |
else |
| 878 |
VectorSet (color, 0.5, 0.5, 0.5); |
| 879 |
|
| 880 |
time = cg.time - p->time; |
| 881 |
time2 = p->endtime - p->time; |
| 882 |
ratio = time / time2; |
| 883 |
|
| 884 |
width = p->width + ( ratio * ( p->endwidth - p->width) ); |
| 885 |
height = p->height + ( ratio * ( p->endheight - p->height) ); |
| 886 |
|
| 887 |
if (width > p->endwidth) |
| 888 |
width = p->endwidth; |
| 889 |
|
| 890 |
if (height > p->endheight) |
| 891 |
height = p->endheight; |
| 892 |
|
| 893 |
sinR = height * sin(DEG2RAD(p->roll)) * sqrt(2); |
| 894 |
cosR = width * cos(DEG2RAD(p->roll)) * sqrt(2); |
| 895 |
|
| 896 |
VectorCopy (org, verts[0].xyz); |
| 897 |
verts[0].xyz[0] -= sinR; |
| 898 |
verts[0].xyz[1] -= cosR; |
| 899 |
verts[0].st[0] = 0; |
| 900 |
verts[0].st[1] = 0; |
| 901 |
verts[0].modulate[0] = 255 * color[0]; |
| 902 |
verts[0].modulate[1] = 255 * color[1]; |
| 903 |
verts[0].modulate[2] = 255 * color[2]; |
| 904 |
verts[0].modulate[3] = 255; |
| 905 |
|
| 906 |
VectorCopy (org, verts[1].xyz); |
| 907 |
verts[1].xyz[0] -= cosR; |
| 908 |
verts[1].xyz[1] += sinR; |
| 909 |
verts[1].st[0] = 0; |
| 910 |
verts[1].st[1] = 1; |
| 911 |
verts[1].modulate[0] = 255 * color[0]; |
| 912 |
verts[1].modulate[1] = 255 * color[1]; |
| 913 |
verts[1].modulate[2] = 255 * color[2]; |
| 914 |
verts[1].modulate[3] = 255; |
| 915 |
|
| 916 |
VectorCopy (org, verts[2].xyz); |
| 917 |
verts[2].xyz[0] += sinR; |
| 918 |
verts[2].xyz[1] += cosR; |
| 919 |
verts[2].st[0] = 1; |
| 920 |
verts[2].st[1] = 1; |
| 921 |
verts[2].modulate[0] = 255 * color[0]; |
| 922 |
verts[2].modulate[1] = 255 * color[1]; |
| 923 |
verts[2].modulate[2] = 255 * color[2]; |
| 924 |
verts[2].modulate[3] = 255; |
| 925 |
|
| 926 |
VectorCopy (org, verts[3].xyz); |
| 927 |
verts[3].xyz[0] += cosR; |
| 928 |
verts[3].xyz[1] -= sinR; |
| 929 |
verts[3].st[0] = 1; |
| 930 |
verts[3].st[1] = 0; |
| 931 |
verts[3].modulate[0] = 255 * color[0]; |
| 932 |
verts[3].modulate[1] = 255 * color[1]; |
| 933 |
verts[3].modulate[2] = 255 * color[2]; |
| 934 |
verts[3].modulate[3] = 255; |
| 935 |
} |
| 936 |
else if (p->type == P_FLAT) |
| 937 |
{ |
| 938 |
|
| 939 |
VectorCopy (org, verts[0].xyz); |
| 940 |
verts[0].xyz[0] -= p->height; |
| 941 |
verts[0].xyz[1] -= p->width; |
| 942 |
verts[0].st[0] = 0; |
| 943 |
verts[0].st[1] = 0; |
| 944 |
verts[0].modulate[0] = 255; |
| 945 |
verts[0].modulate[1] = 255; |
| 946 |
verts[0].modulate[2] = 255; |
| 947 |
verts[0].modulate[3] = 255; |
| 948 |
|
| 949 |
VectorCopy (org, verts[1].xyz); |
| 950 |
verts[1].xyz[0] -= p->height; |
| 951 |
verts[1].xyz[1] += p->width; |
| 952 |
verts[1].st[0] = 0; |
| 953 |
verts[1].st[1] = 1; |
| 954 |
verts[1].modulate[0] = 255; |
| 955 |
verts[1].modulate[1] = 255; |
| 956 |
verts[1].modulate[2] = 255; |
| 957 |
verts[1].modulate[3] = 255; |
| 958 |
|
| 959 |
VectorCopy (org, verts[2].xyz); |
| 960 |
verts[2].xyz[0] += p->height; |
| 961 |
verts[2].xyz[1] += p->width; |
| 962 |
verts[2].st[0] = 1; |
| 963 |
verts[2].st[1] = 1; |
| 964 |
verts[2].modulate[0] = 255; |
| 965 |
verts[2].modulate[1] = 255; |
| 966 |
verts[2].modulate[2] = 255; |
| 967 |
verts[2].modulate[3] = 255; |
| 968 |
|
| 969 |
VectorCopy (org, verts[3].xyz); |
| 970 |
verts[3].xyz[0] += p->height; |
| 971 |
verts[3].xyz[1] -= p->width; |
| 972 |
verts[3].st[0] = 1; |
| 973 |
verts[3].st[1] = 0; |
| 974 |
verts[3].modulate[0] = 255; |
| 975 |
verts[3].modulate[1] = 255; |
| 976 |
verts[3].modulate[2] = 255; |
| 977 |
verts[3].modulate[3] = 255; |
| 978 |
|
| 979 |
} |
| 980 |
// Ridah |
| 981 |
else if (p->type == P_ANIM) { |
| 982 |
vec3_t rr, ru; |
| 983 |
vec3_t rotate_ang; |
| 984 |
int i, j; |
| 985 |
|
| 986 |
time = cg.time - p->time; |
| 987 |
time2 = p->endtime - p->time; |
| 988 |
ratio = time / time2; |
| 989 |
if (ratio >= 1.0f) { |
| 990 |
ratio = 0.9999f; |
| 991 |
} |
| 992 |
|
| 993 |
width = p->width + ( ratio * ( p->endwidth - p->width) ); |
| 994 |
height = p->height + ( ratio * ( p->endheight - p->height) ); |
| 995 |
|
| 996 |
// if we are "inside" this sprite, don't draw |
| 997 |
if (Distance( cg.snap->ps.origin, org ) < width/1.5) { |
| 998 |
return; |
| 999 |
} |
| 1000 |
|
| 1001 |
i = p->shaderAnim; |
| 1002 |
j = (int)floor(ratio * shaderAnimCounts[p->shaderAnim]); |
| 1003 |
p->pshader = shaderAnims[i][j]; |
| 1004 |
|
| 1005 |
if (p->roll) { |
| 1006 |
vectoangles( cg.refdef.viewaxis[0], rotate_ang ); |
| 1007 |
rotate_ang[ROLL] += p->roll; |
| 1008 |
AngleVectors ( rotate_ang, NULL, rr, ru); |
| 1009 |
} |
| 1010 |
|
| 1011 |
if (p->roll) { |
| 1012 |
VectorMA (org, -height, ru, point); |
| 1013 |
VectorMA (point, -width, rr, point); |
| 1014 |
} else { |
| 1015 |
VectorMA (org, -height, pvup, point); |
| 1016 |
VectorMA (point, -width, pvright, point); |
| 1017 |
} |
| 1018 |
VectorCopy (point, verts[0].xyz); |
| 1019 |
verts[0].st[0] = 0; |
| 1020 |
verts[0].st[1] = 0; |
| 1021 |
verts[0].modulate[0] = 255; |
| 1022 |
verts[0].modulate[1] = 255; |
| 1023 |
verts[0].modulate[2] = 255; |
| 1024 |
verts[0].modulate[3] = 255; |
| 1025 |
|
| 1026 |
if (p->roll) { |
| 1027 |
VectorMA (point, 2*height, ru, point); |
| 1028 |
} else { |
| 1029 |
VectorMA (point, 2*height, pvup, point); |
| 1030 |
} |
| 1031 |
VectorCopy (point, verts[1].xyz); |
| 1032 |
verts[1].st[0] = 0; |
| 1033 |
verts[1].st[1] = 1; |
| 1034 |
verts[1].modulate[0] = 255; |
| 1035 |
verts[1].modulate[1] = 255; |
| 1036 |
verts[1].modulate[2] = 255; |
| 1037 |
verts[1].modulate[3] = 255; |
| 1038 |
|
| 1039 |
if (p->roll) { |
| 1040 |
VectorMA (point, 2*width, rr, point); |
| 1041 |
} else { |
| 1042 |
VectorMA (point, 2*width, pvright, point); |
| 1043 |
} |
| 1044 |
VectorCopy (point, verts[2].xyz); |
| 1045 |
verts[2].st[0] = 1; |
| 1046 |
verts[2].st[1] = 1; |
| 1047 |
verts[2].modulate[0] = 255; |
| 1048 |
verts[2].modulate[1] = 255; |
| 1049 |
verts[2].modulate[2] = 255; |
| 1050 |
verts[2].modulate[3] = 255; |
| 1051 |
|
| 1052 |
if (p->roll) { |
| 1053 |
VectorMA (point, -2*height, ru, point); |
| 1054 |
} else { |
| 1055 |
VectorMA (point, -2*height, pvup, point); |
| 1056 |
} |
| 1057 |
VectorCopy (point, verts[3].xyz); |
| 1058 |
verts[3].st[0] = 1; |
| 1059 |
verts[3].st[1] = 0; |
| 1060 |
verts[3].modulate[0] = 255; |
| 1061 |
verts[3].modulate[1] = 255; |
| 1062 |
verts[3].modulate[2] = 255; |
| 1063 |
verts[3].modulate[3] = 255; |
| 1064 |
} |
| 1065 |
// done. |
| 1066 |
|
| 1067 |
if (!p->pshader) { |
| 1068 |
// (SA) temp commented out for DM |
| 1069 |
// CG_Printf ("CG_AddParticleToScene type %d p->pshader == ZERO\n", p->type); |
| 1070 |
return; |
| 1071 |
} |
| 1072 |
|
| 1073 |
if (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY) |
| 1074 |
trap_R_AddPolyToScene( p->pshader, 3, TRIverts ); |
| 1075 |
else |
| 1076 |
trap_R_AddPolyToScene( p->pshader, 4, verts ); |
| 1077 |
|
| 1078 |
} |
| 1079 |
|
| 1080 |
// Ridah, made this static so it doesn't interfere with other files |
| 1081 |
static float roll = 0.0; |
| 1082 |
|
| 1083 |
/* |
| 1084 |
=============== |
| 1085 |
CG_AddParticles |
| 1086 |
=============== |
| 1087 |
*/ |
| 1088 |
void CG_AddParticles (void) |
| 1089 |
{ |
| 1090 |
cparticle_t *p, *next; |
| 1091 |
float alpha; |
| 1092 |
float time, time2; |
| 1093 |
vec3_t org; |
| 1094 |
int color; |
| 1095 |
cparticle_t *active, *tail; |
| 1096 |
int type; |
| 1097 |
vec3_t rotate_ang; |
| 1098 |
|
| 1099 |
if (!initparticles) |
| 1100 |
CG_ClearParticles (); |
| 1101 |
|
| 1102 |
VectorCopy( cg.refdef.viewaxis[0], pvforward ); |
| 1103 |
VectorCopy( cg.refdef.viewaxis[1], pvright ); |
| 1104 |
VectorCopy( cg.refdef.viewaxis[2], pvup ); |
| 1105 |
|
| 1106 |
vectoangles( cg.refdef.viewaxis[0], rotate_ang ); |
| 1107 |
roll += ((cg.time - oldtime) * 0.1) ; |
| 1108 |
rotate_ang[ROLL] += (roll*0.9); |
| 1109 |
AngleVectors ( rotate_ang, rforward, rright, rup); |
| 1110 |
|
| 1111 |
oldtime = cg.time; |
| 1112 |
|
| 1113 |
active = NULL; |
| 1114 |
tail = NULL; |
| 1115 |
|
| 1116 |
for (p=active_particles ; p ; p=next) |
| 1117 |
{ |
| 1118 |
|
| 1119 |
next = p->next; |
| 1120 |
|
| 1121 |
time = (cg.time - p->time)*0.001; |
| 1122 |
|
| 1123 |
alpha = p->alpha + time*p->alphavel; |
| 1124 |
if (alpha <= 0) |
| 1125 |
{ // faded out |
| 1126 |
p->next = free_particles; |
| 1127 |
free_particles = p; |
| 1128 |
p->type = 0; |
| 1129 |
p->color = 0; |
| 1130 |
p->alpha = 0; |
| 1131 |
continue; |
| 1132 |
} |
| 1133 |
|
| 1134 |
if (p->type == P_SMOKE || p->type == P_ANIM || p->type == P_BLEED || p->type == P_SMOKE_IMPACT) |
| 1135 |
{ |
| 1136 |
if (cg.time > p->endtime) |
| 1137 |
{ |
| 1138 |
p->next = free_particles; |
| 1139 |
free_particles = p; |
| 1140 |
p->type = 0; |
| 1141 |
p->color = 0; |
| 1142 |
p->alpha = 0; |
| 1143 |
|
| 1144 |
continue; |
| 1145 |
} |
| 1146 |
|
| 1147 |
} |
| 1148 |
|
| 1149 |
if (p->type == P_WEATHER_FLURRY) |
| 1150 |
{ |
| 1151 |
if (cg.time > p->endtime) |
| 1152 |
{ |
| 1153 |
p->next = free_particles; |
| 1154 |
free_particles = p; |
| 1155 |
p->type = 0; |
| 1156 |
p->color = 0; |
| 1157 |
p->alpha = 0; |
| 1158 |
|
| 1159 |
continue; |
| 1160 |
} |
| 1161 |
} |
| 1162 |
|
| 1163 |
|
| 1164 |
if (p->type == P_FLAT_SCALEUP_FADE) |
| 1165 |
{ |
| 1166 |
if (cg.time > p->endtime) |
| 1167 |
{ |
| 1168 |
p->next = free_particles; |
| 1169 |
free_particles = p; |
| 1170 |
p->type = 0; |
| 1171 |
p->color = 0; |
| 1172 |
p->alpha = 0; |
| 1173 |
continue; |
| 1174 |
} |
| 1175 |
|
| 1176 |
} |
| 1177 |
|
| 1178 |
if ((p->type == P_BAT || p->type == P_SPRITE) && p->endtime < 0) { |
| 1179 |
// temporary sprite |
| 1180 |
CG_AddParticleToScene (p, p->org, alpha); |
| 1181 |
p->next = free_particles; |
| 1182 |
free_particles = p; |
| 1183 |
p->type = 0; |
| 1184 |
p->color = 0; |
| 1185 |
p->alpha = 0; |
| 1186 |
continue; |
| 1187 |
} |
| 1188 |
|
| 1189 |
p->next = NULL; |
| 1190 |
if (!tail) |
| 1191 |
active = tail = p; |
| 1192 |
else |
| 1193 |
{ |
| 1194 |
tail->next = p; |
| 1195 |
tail = p; |
| 1196 |
} |
| 1197 |
|
| 1198 |
if (alpha > 1.0) |
| 1199 |
alpha = 1; |
| 1200 |
|
| 1201 |
color = p->color; |
| 1202 |
|
| 1203 |
time2 = time*time; |
| 1204 |
|
| 1205 |
org[0] = p->org[0] + p->vel[0]*time + p->accel[0]*time2; |
| 1206 |
org[1] = p->org[1] + p->vel[1]*time + p->accel[1]*time2; |
| 1207 |
org[2] = p->org[2] + p->vel[2]*time + p->accel[2]*time2; |
| 1208 |
|
| 1209 |
type = p->type; |
| 1210 |
|
| 1211 |
CG_AddParticleToScene (p, org, alpha); |
| 1212 |
} |
| 1213 |
|
| 1214 |
active_particles = active; |
| 1215 |
} |
| 1216 |
|
| 1217 |
/* |
| 1218 |
====================== |
| 1219 |
CG_AddParticles |
| 1220 |
====================== |
| 1221 |
*/ |
| 1222 |
void CG_ParticleSnowFlurry (qhandle_t pshader, centity_t *cent) |
| 1223 |
{ |
| 1224 |
cparticle_t *p; |
| 1225 |
qboolean turb = qtrue; |
| 1226 |
|
| 1227 |
if (!pshader) |
| 1228 |
CG_Printf ("CG_ParticleSnowFlurry pshader == ZERO!\n"); |
| 1229 |
|
| 1230 |
if (!free_particles) |
| 1231 |
return; |
| 1232 |
p = free_particles; |
| 1233 |
free_particles = p->next; |
| 1234 |
p->next = active_particles; |
| 1235 |
active_particles = p; |
| 1236 |
p->time = cg.time; |
| 1237 |
p->color = 0; |
| 1238 |
p->alpha = 0.90f; |
| 1239 |
p->alphavel = 0; |
| 1240 |
|
| 1241 |
p->start = cent->currentState.origin2[0]; |
| 1242 |
p->end = cent->currentState.origin2[1]; |
| 1243 |
|
| 1244 |
p->endtime = cg.time + cent->currentState.time; |
| 1245 |
p->startfade = cg.time + cent->currentState.time2; |
| 1246 |
|
| 1247 |
p->pshader = pshader; |
| 1248 |
|
| 1249 |
if (rand()%100 > 90) |
| 1250 |
{ |
| 1251 |
p->height = 32; |
| 1252 |
p->width = 32; |
| 1253 |
p->alpha = 0.10f; |
| 1254 |
} |
| 1255 |
else |
| 1256 |
{ |
| 1257 |
p->height = 1; |
| 1258 |
p->width = 1; |
| 1259 |
} |
| 1260 |
|
| 1261 |
p->vel[2] = -20; |
| 1262 |
|
| 1263 |
p->type = P_WEATHER_FLURRY; |
| 1264 |
|
| 1265 |
if (turb) |
| 1266 |
p->vel[2] = -10; |
| 1267 |
|
| 1268 |
VectorCopy(cent->currentState.origin, p->org); |
| 1269 |
|
| 1270 |
p->org[0] = p->org[0]; |
| 1271 |
p->org[1] = p->org[1]; |
| 1272 |
p->org[2] = p->org[2]; |
| 1273 |
|
| 1274 |
p->vel[0] = p->vel[1] = 0; |
| 1275 |
|
| 1276 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 1277 |
|
| 1278 |
p->vel[0] += cent->currentState.angles[0] * 32 + (crandom() * 16); |
| 1279 |
p->vel[1] += cent->currentState.angles[1] * 32 + (crandom() * 16); |
| 1280 |
p->vel[2] += cent->currentState.angles[2]; |
| 1281 |
|
| 1282 |
if (turb) |
| 1283 |
{ |
| 1284 |
p->accel[0] = crandom () * 16; |
| 1285 |
p->accel[1] = crandom () * 16; |
| 1286 |
} |
| 1287 |
|
| 1288 |
} |
| 1289 |
|
| 1290 |
void CG_ParticleSnow (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum) |
| 1291 |
{ |
| 1292 |
cparticle_t *p; |
| 1293 |
|
| 1294 |
if (!pshader) |
| 1295 |
CG_Printf ("CG_ParticleSnow pshader == ZERO!\n"); |
| 1296 |
|
| 1297 |
if (!free_particles) |
| 1298 |
return; |
| 1299 |
p = free_particles; |
| 1300 |
free_particles = p->next; |
| 1301 |
p->next = active_particles; |
| 1302 |
active_particles = p; |
| 1303 |
p->time = cg.time; |
| 1304 |
p->color = 0; |
| 1305 |
p->alpha = 0.40f; |
| 1306 |
p->alphavel = 0; |
| 1307 |
p->start = origin[2]; |
| 1308 |
p->end = origin2[2]; |
| 1309 |
p->pshader = pshader; |
| 1310 |
p->height = 1; |
| 1311 |
p->width = 1; |
| 1312 |
|
| 1313 |
p->vel[2] = -50; |
| 1314 |
|
| 1315 |
if (turb) |
| 1316 |
{ |
| 1317 |
p->type = P_WEATHER_TURBULENT; |
| 1318 |
p->vel[2] = -50 * 1.3; |
| 1319 |
} |
| 1320 |
else |
| 1321 |
{ |
| 1322 |
p->type = P_WEATHER; |
| 1323 |
} |
| 1324 |
|
| 1325 |
VectorCopy(origin, p->org); |
| 1326 |
|
| 1327 |
p->org[0] = p->org[0] + ( crandom() * range); |
| 1328 |
p->org[1] = p->org[1] + ( crandom() * range); |
| 1329 |
p->org[2] = p->org[2] + ( crandom() * (p->start - p->end)); |
| 1330 |
|
| 1331 |
p->vel[0] = p->vel[1] = 0; |
| 1332 |
|
| 1333 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 1334 |
|
| 1335 |
if (turb) |
| 1336 |
{ |
| 1337 |
p->vel[0] = crandom() * 16; |
| 1338 |
p->vel[1] = crandom() * 16; |
| 1339 |
} |
| 1340 |
|
| 1341 |
// Rafael snow pvs check |
| 1342 |
p->snum = snum; |
| 1343 |
p->link = qtrue; |
| 1344 |
|
| 1345 |
} |
| 1346 |
|
| 1347 |
void CG_ParticleBubble (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum) |
| 1348 |
{ |
| 1349 |
cparticle_t *p; |
| 1350 |
float randsize; |
| 1351 |
|
| 1352 |
if (!pshader) |
| 1353 |
CG_Printf ("CG_ParticleSnow pshader == ZERO!\n"); |
| 1354 |
|
| 1355 |
if (!free_particles) |
| 1356 |
return; |
| 1357 |
p = free_particles; |
| 1358 |
free_particles = p->next; |
| 1359 |
p->next = active_particles; |
| 1360 |
active_particles = p; |
| 1361 |
p->time = cg.time; |
| 1362 |
p->color = 0; |
| 1363 |
p->alpha = 0.40f; |
| 1364 |
p->alphavel = 0; |
| 1365 |
p->start = origin[2]; |
| 1366 |
p->end = origin2[2]; |
| 1367 |
p->pshader = pshader; |
| 1368 |
|
| 1369 |
randsize = 1 + (crandom() * 0.5); |
| 1370 |
|
| 1371 |
p->height = randsize; |
| 1372 |
p->width = randsize; |
| 1373 |
|
| 1374 |
p->vel[2] = 50 + ( crandom() * 10 ); |
| 1375 |
|
| 1376 |
if (turb) |
| 1377 |
{ |
| 1378 |
p->type = P_BUBBLE_TURBULENT; |
| 1379 |
p->vel[2] = 50 * 1.3; |
| 1380 |
} |
| 1381 |
else |
| 1382 |
{ |
| 1383 |
p->type = P_BUBBLE; |
| 1384 |
} |
| 1385 |
|
| 1386 |
VectorCopy(origin, p->org); |
| 1387 |
|
| 1388 |
p->org[0] = p->org[0] + ( crandom() * range); |
| 1389 |
p->org[1] = p->org[1] + ( crandom() * range); |
| 1390 |
p->org[2] = p->org[2] + ( crandom() * (p->start - p->end)); |
| 1391 |
|
| 1392 |
p->vel[0] = p->vel[1] = 0; |
| 1393 |
|
| 1394 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 1395 |
|
| 1396 |
if (turb) |
| 1397 |
{ |
| 1398 |
p->vel[0] = crandom() * 4; |
| 1399 |
p->vel[1] = crandom() * 4; |
| 1400 |
} |
| 1401 |
|
| 1402 |
// Rafael snow pvs check |
| 1403 |
p->snum = snum; |
| 1404 |
p->link = qtrue; |
| 1405 |
|
| 1406 |
} |
| 1407 |
|
| 1408 |
void CG_ParticleSmoke (qhandle_t pshader, centity_t *cent) |
| 1409 |
{ |
| 1410 |
|
| 1411 |
// using cent->density = enttime |
| 1412 |
// cent->frame = startfade |
| 1413 |
cparticle_t *p; |
| 1414 |
|
| 1415 |
if (!pshader) |
| 1416 |
CG_Printf ("CG_ParticleSmoke == ZERO!\n"); |
| 1417 |
|
| 1418 |
if (!free_particles) |
| 1419 |
return; |
| 1420 |
p = free_particles; |
| 1421 |
free_particles = p->next; |
| 1422 |
p->next = active_particles; |
| 1423 |
active_particles = p; |
| 1424 |
p->time = cg.time; |
| 1425 |
|
| 1426 |
p->endtime = cg.time + cent->currentState.time; |
| 1427 |
p->startfade = cg.time + cent->currentState.time2; |
| 1428 |
|
| 1429 |
p->color = 0; |
| 1430 |
p->alpha = 1.0; |
| 1431 |
p->alphavel = 0; |
| 1432 |
p->start = cent->currentState.origin[2]; |
| 1433 |
p->end = cent->currentState.origin2[2]; |
| 1434 |
p->pshader = pshader; |
| 1435 |
p->rotate = qfalse; |
| 1436 |
p->height = 8; |
| 1437 |
p->width = 8; |
| 1438 |
p->endheight = 32; |
| 1439 |
p->endwidth = 32; |
| 1440 |
p->type = P_SMOKE; |
| 1441 |
|
| 1442 |
VectorCopy(cent->currentState.origin, p->org); |
| 1443 |
|
| 1444 |
p->vel[0] = p->vel[1] = 0; |
| 1445 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 1446 |
|
| 1447 |
p->vel[2] = 5; |
| 1448 |
|
| 1449 |
if (cent->currentState.frame == 1)// reverse gravity |
| 1450 |
p->vel[2] *= -1; |
| 1451 |
|
| 1452 |
p->roll = 8 + (crandom() * 4); |
| 1453 |
} |
| 1454 |
|
| 1455 |
|
| 1456 |
void CG_ParticleBulletDebris (vec3_t org, vec3_t vel, int duration) |
| 1457 |
{ |
| 1458 |
|
| 1459 |
cparticle_t *p; |
| 1460 |
|
| 1461 |
if (!free_particles) |
| 1462 |
return; |
| 1463 |
p = free_particles; |
| 1464 |
free_particles = p->next; |
| 1465 |
p->next = active_particles; |
| 1466 |
active_particles = p; |
| 1467 |
p->time = cg.time; |
| 1468 |
|
| 1469 |
p->endtime = cg.time + duration; |
| 1470 |
p->startfade = cg.time + duration/2; |
| 1471 |
|
| 1472 |
p->color = EMISIVEFADE; |
| 1473 |
p->alpha = 1.0; |
| 1474 |
p->alphavel = 0; |
| 1475 |
|
| 1476 |
p->height = 0.5; |
| 1477 |
p->width = 0.5; |
| 1478 |
p->endheight = 0.5; |
| 1479 |
p->endwidth = 0.5; |
| 1480 |
|
| 1481 |
p->pshader = cgs.media.tracerShader; |
| 1482 |
|
| 1483 |
p->type = P_SMOKE; |
| 1484 |
|
| 1485 |
VectorCopy(org, p->org); |
| 1486 |
|
| 1487 |
p->vel[0] = vel[0]; |
| 1488 |
p->vel[1] = vel[1]; |
| 1489 |
p->vel[2] = vel[2]; |
| 1490 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 1491 |
|
| 1492 |
p->accel[2] = -60; |
| 1493 |
p->vel[2] += -20; |
| 1494 |
|
| 1495 |
} |
| 1496 |
|
| 1497 |
/* |
| 1498 |
====================== |
| 1499 |
CG_ParticleExplosion |
| 1500 |
====================== |
| 1501 |
*/ |
| 1502 |
|
| 1503 |
void CG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duration, int sizeStart, int sizeEnd) |
| 1504 |
{ |
| 1505 |
cparticle_t *p; |
| 1506 |
int anim; |
| 1507 |
|
| 1508 |
if (animStr < (char *)10) |
| 1509 |
CG_Error( "CG_ParticleExplosion: animStr is probably an index rather than a string" ); |
| 1510 |
|
| 1511 |
// find the animation string |
| 1512 |
for (anim=0; shaderAnimNames[anim]; anim++) { |
| 1513 |
if (!Q_stricmp( animStr, shaderAnimNames[anim] )) |
| 1514 |
break; |
| 1515 |
} |
| 1516 |
if (!shaderAnimNames[anim]) { |
| 1517 |
CG_Error("CG_ParticleExplosion: unknown animation string: %s\n", animStr); |
| 1518 |
return; |
| 1519 |
} |
| 1520 |
|
| 1521 |
if (!free_particles) |
| 1522 |
return; |
| 1523 |
p = free_particles; |
| 1524 |
free_particles = p->next; |
| 1525 |
p->next = active_particles; |
| 1526 |
active_particles = p; |
| 1527 |
p->time = cg.time; |
| 1528 |
p->alpha = 0.5; |
| 1529 |
p->alphavel = 0; |
| 1530 |
|
| 1531 |
if (duration < 0) { |
| 1532 |
duration *= -1; |
| 1533 |
p->roll = 0; |
| 1534 |
} else { |
| 1535 |
p->roll = crandom()*179; |
| 1536 |
} |
| 1537 |
|
| 1538 |
p->shaderAnim = anim; |
| 1539 |
|
| 1540 |
p->width = sizeStart; |
| 1541 |
p->height = sizeStart*shaderAnimSTRatio[anim]; // for sprites that are stretch in either direction |
| 1542 |
|
| 1543 |
p->endheight = sizeEnd; |
| 1544 |
p->endwidth = sizeEnd*shaderAnimSTRatio[anim]; |
| 1545 |
|
| 1546 |
p->endtime = cg.time + duration; |
| 1547 |
|
| 1548 |
p->type = P_ANIM; |
| 1549 |
|
| 1550 |
VectorCopy( origin, p->org ); |
| 1551 |
VectorCopy( vel, p->vel ); |
| 1552 |
VectorClear( p->accel ); |
| 1553 |
|
| 1554 |
} |
| 1555 |
|
| 1556 |
// Rafael Shrapnel |
| 1557 |
void CG_AddParticleShrapnel (localEntity_t *le) |
| 1558 |
{ |
| 1559 |
return; |
| 1560 |
} |
| 1561 |
// done. |
| 1562 |
|
| 1563 |
int CG_NewParticleArea (int num) |
| 1564 |
{ |
| 1565 |
// const char *str; |
| 1566 |
char *str; |
| 1567 |
char *token; |
| 1568 |
int type; |
| 1569 |
vec3_t origin, origin2; |
| 1570 |
int i; |
| 1571 |
float range = 0; |
| 1572 |
int turb; |
| 1573 |
int numparticles; |
| 1574 |
int snum; |
| 1575 |
|
| 1576 |
str = (char *) CG_ConfigString (num); |
| 1577 |
if (!str[0]) |
| 1578 |
return (0); |
| 1579 |
|
| 1580 |
// returns type 128 64 or 32 |
| 1581 |
token = COM_Parse (&str); |
| 1582 |
type = atoi (token); |
| 1583 |
|
| 1584 |
if (type == 1) |
| 1585 |
range = 128; |
| 1586 |
else if (type == 2) |
| 1587 |
range = 64; |
| 1588 |
else if (type == 3) |
| 1589 |
range = 32; |
| 1590 |
else if (type == 0) |
| 1591 |
range = 256; |
| 1592 |
else if (type == 4) |
| 1593 |
range = 8; |
| 1594 |
else if (type == 5) |
| 1595 |
range = 16; |
| 1596 |
else if (type == 6) |
| 1597 |
range = 32; |
| 1598 |
else if (type == 7) |
| 1599 |
range = 64; |
| 1600 |
|
| 1601 |
|
| 1602 |
for (i=0; i<3; i++) |
| 1603 |
{ |
| 1604 |
token = COM_Parse (&str); |
| 1605 |
origin[i] = atof (token); |
| 1606 |
} |
| 1607 |
|
| 1608 |
for (i=0; i<3; i++) |
| 1609 |
{ |
| 1610 |
token = COM_Parse (&str); |
| 1611 |
origin2[i] = atof (token); |
| 1612 |
} |
| 1613 |
|
| 1614 |
token = COM_Parse (&str); |
| 1615 |
numparticles = atoi (token); |
| 1616 |
|
| 1617 |
token = COM_Parse (&str); |
| 1618 |
turb = atoi (token); |
| 1619 |
|
| 1620 |
token = COM_Parse (&str); |
| 1621 |
snum = atoi (token); |
| 1622 |
|
| 1623 |
for (i=0; i<numparticles; i++) |
| 1624 |
{ |
| 1625 |
if (type >= 4) |
| 1626 |
CG_ParticleBubble (cgs.media.waterBubbleShader, origin, origin2, turb, range, snum); |
| 1627 |
else |
| 1628 |
CG_ParticleSnow (cgs.media.waterBubbleShader, origin, origin2, turb, range, snum); |
| 1629 |
} |
| 1630 |
|
| 1631 |
return (1); |
| 1632 |
} |
| 1633 |
|
| 1634 |
void CG_SnowLink (centity_t *cent, qboolean particleOn) |
| 1635 |
{ |
| 1636 |
cparticle_t *p, *next; |
| 1637 |
int id; |
| 1638 |
|
| 1639 |
id = cent->currentState.frame; |
| 1640 |
|
| 1641 |
for (p=active_particles ; p ; p=next) |
| 1642 |
{ |
| 1643 |
next = p->next; |
| 1644 |
|
| 1645 |
if (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT) |
| 1646 |
{ |
| 1647 |
if (p->snum == id) |
| 1648 |
{ |
| 1649 |
if (particleOn) |
| 1650 |
p->link = qtrue; |
| 1651 |
else |
| 1652 |
p->link = qfalse; |
| 1653 |
} |
| 1654 |
} |
| 1655 |
|
| 1656 |
} |
| 1657 |
} |
| 1658 |
|
| 1659 |
void CG_ParticleImpactSmokePuff (qhandle_t pshader, vec3_t origin) |
| 1660 |
{ |
| 1661 |
cparticle_t *p; |
| 1662 |
|
| 1663 |
if (!pshader) |
| 1664 |
CG_Printf ("CG_ParticleImpactSmokePuff pshader == ZERO!\n"); |
| 1665 |
|
| 1666 |
if (!free_particles) |
| 1667 |
return; |
| 1668 |
p = free_particles; |
| 1669 |
free_particles = p->next; |
| 1670 |
p->next = active_particles; |
| 1671 |
active_particles = p; |
| 1672 |
p->time = cg.time; |
| 1673 |
p->alpha = 0.25; |
| 1674 |
p->alphavel = 0; |
| 1675 |
p->roll = crandom()*179; |
| 1676 |
|
| 1677 |
p->pshader = pshader; |
| 1678 |
|
| 1679 |
p->endtime = cg.time + 1000; |
| 1680 |
p->startfade = cg.time + 100; |
| 1681 |
|
| 1682 |
p->width = rand()%4 + 8; |
| 1683 |
p->height = rand()%4 + 8; |
| 1684 |
|
| 1685 |
p->endheight = p->height *2; |
| 1686 |
p->endwidth = p->width * 2; |
| 1687 |
|
| 1688 |
p->endtime = cg.time + 500; |
| 1689 |
|
| 1690 |
p->type = P_SMOKE_IMPACT; |
| 1691 |
|
| 1692 |
VectorCopy( origin, p->org ); |
| 1693 |
VectorSet(p->vel, 0, 0, 20); |
| 1694 |
VectorSet(p->accel, 0, 0, 20); |
| 1695 |
|
| 1696 |
p->rotate = qtrue; |
| 1697 |
} |
| 1698 |
|
| 1699 |
void CG_Particle_Bleed (qhandle_t pshader, vec3_t start, vec3_t dir, int fleshEntityNum, int duration) |
| 1700 |
{ |
| 1701 |
cparticle_t *p; |
| 1702 |
|
| 1703 |
if (!pshader) |
| 1704 |
CG_Printf ("CG_Particle_Bleed pshader == ZERO!\n"); |
| 1705 |
|
| 1706 |
if (!free_particles) |
| 1707 |
return; |
| 1708 |
p = free_particles; |
| 1709 |
free_particles = p->next; |
| 1710 |
p->next = active_particles; |
| 1711 |
active_particles = p; |
| 1712 |
p->time = cg.time; |
| 1713 |
p->alpha = 1.0; |
| 1714 |
p->alphavel = 0; |
| 1715 |
p->roll = 0; |
| 1716 |
|
| 1717 |
p->pshader = pshader; |
| 1718 |
|
| 1719 |
p->endtime = cg.time + duration; |
| 1720 |
|
| 1721 |
if (fleshEntityNum) |
| 1722 |
p->startfade = cg.time; |
| 1723 |
else |
| 1724 |
p->startfade = cg.time + 100; |
| 1725 |
|
| 1726 |
p->width = 4; |
| 1727 |
p->height = 4; |
| 1728 |
|
| 1729 |
p->endheight = 4+rand()%3; |
| 1730 |
p->endwidth = p->endheight; |
| 1731 |
|
| 1732 |
p->type = P_SMOKE; |
| 1733 |
|
| 1734 |
VectorCopy( start, p->org ); |
| 1735 |
p->vel[0] = 0; |
| 1736 |
p->vel[1] = 0; |
| 1737 |
p->vel[2] = -20; |
| 1738 |
VectorClear( p->accel ); |
| 1739 |
|
| 1740 |
p->rotate = qfalse; |
| 1741 |
|
| 1742 |
p->roll = rand()%179; |
| 1743 |
|
| 1744 |
p->color = BLOODRED; |
| 1745 |
p->alpha = 0.75; |
| 1746 |
|
| 1747 |
} |
| 1748 |
|
| 1749 |
void CG_Particle_OilParticle (qhandle_t pshader, centity_t *cent) |
| 1750 |
{ |
| 1751 |
cparticle_t *p; |
| 1752 |
|
| 1753 |
int time; |
| 1754 |
int time2; |
| 1755 |
float ratio; |
| 1756 |
|
| 1757 |
float duration = 1500; |
| 1758 |
|
| 1759 |
time = cg.time; |
| 1760 |
time2 = cg.time + cent->currentState.time; |
| 1761 |
|
| 1762 |
ratio =(float)1 - ((float)time / (float)time2); |
| 1763 |
|
| 1764 |
if (!pshader) |
| 1765 |
CG_Printf ("CG_Particle_OilParticle == ZERO!\n"); |
| 1766 |
|
| 1767 |
if (!free_particles) |
| 1768 |
return; |
| 1769 |
p = free_particles; |
| 1770 |
free_particles = p->next; |
| 1771 |
p->next = active_particles; |
| 1772 |
active_particles = p; |
| 1773 |
p->time = cg.time; |
| 1774 |
p->alpha = 1.0; |
| 1775 |
p->alphavel = 0; |
| 1776 |
p->roll = 0; |
| 1777 |
|
| 1778 |
p->pshader = pshader; |
| 1779 |
|
| 1780 |
p->endtime = cg.time + duration; |
| 1781 |
|
| 1782 |
p->startfade = p->endtime; |
| 1783 |
|
| 1784 |
p->width = 1; |
| 1785 |
p->height = 3; |
| 1786 |
|
| 1787 |
p->endheight = 3; |
| 1788 |
p->endwidth = 1; |
| 1789 |
|
| 1790 |
p->type = P_SMOKE; |
| 1791 |
|
| 1792 |
VectorCopy(cent->currentState.origin, p->org ); |
| 1793 |
|
| 1794 |
p->vel[0] = (cent->currentState.origin2[0] * (16 * ratio)); |
| 1795 |
p->vel[1] = (cent->currentState.origin2[1] * (16 * ratio)); |
| 1796 |
p->vel[2] = (cent->currentState.origin2[2]); |
| 1797 |
|
| 1798 |
p->snum = 1.0f; |
| 1799 |
|
| 1800 |
VectorClear( p->accel ); |
| 1801 |
|
| 1802 |
p->accel[2] = -20; |
| 1803 |
|
| 1804 |
p->rotate = qfalse; |
| 1805 |
|
| 1806 |
p->roll = rand()%179; |
| 1807 |
|
| 1808 |
p->alpha = 0.75; |
| 1809 |
|
| 1810 |
} |
| 1811 |
|
| 1812 |
|
| 1813 |
void CG_Particle_OilSlick (qhandle_t pshader, centity_t *cent) |
| 1814 |
{ |
| 1815 |
cparticle_t *p; |
| 1816 |
|
| 1817 |
if (!pshader) |
| 1818 |
CG_Printf ("CG_Particle_OilSlick == ZERO!\n"); |
| 1819 |
|
| 1820 |
if (!free_particles) |
| 1821 |
return; |
| 1822 |
p = free_particles; |
| 1823 |
free_particles = p->next; |
| 1824 |
p->next = active_particles; |
| 1825 |
active_particles = p; |
| 1826 |
p->time = cg.time; |
| 1827 |
|
| 1828 |
if (cent->currentState.angles2[2]) |
| 1829 |
p->endtime = cg.time + cent->currentState.angles2[2]; |
| 1830 |
else |
| 1831 |
p->endtime = cg.time + 60000; |
| 1832 |
|
| 1833 |
p->startfade = p->endtime; |
| 1834 |
|
| 1835 |
p->alpha = 1.0; |
| 1836 |
p->alphavel = 0; |
| 1837 |
p->roll = 0; |
| 1838 |
|
| 1839 |
p->pshader = pshader; |
| 1840 |
|
| 1841 |
if (cent->currentState.angles2[0] || cent->currentState.angles2[1]) |
| 1842 |
{ |
| 1843 |
p->width = cent->currentState.angles2[0]; |
| 1844 |
p->height = cent->currentState.angles2[0]; |
| 1845 |
|
| 1846 |
p->endheight = cent->currentState.angles2[1]; |
| 1847 |
p->endwidth = cent->currentState.angles2[1]; |
| 1848 |
} |
| 1849 |
else |
| 1850 |
{ |
| 1851 |
p->width = 8; |
| 1852 |
p->height = 8; |
| 1853 |
|
| 1854 |
p->endheight = 16; |
| 1855 |
p->endwidth = 16; |
| 1856 |
} |
| 1857 |
|
| 1858 |
p->type = P_FLAT_SCALEUP; |
| 1859 |
|
| 1860 |
p->snum = 1.0; |
| 1861 |
|
| 1862 |
VectorCopy(cent->currentState.origin, p->org ); |
| 1863 |
|
| 1864 |
p->org[2]+= 0.55 + (crandom() * 0.5); |
| 1865 |
|
| 1866 |
p->vel[0] = 0; |
| 1867 |
p->vel[1] = 0; |
| 1868 |
p->vel[2] = 0; |
| 1869 |
VectorClear( p->accel ); |
| 1870 |
|
| 1871 |
p->rotate = qfalse; |
| 1872 |
|
| 1873 |
p->roll = rand()%179; |
| 1874 |
|
| 1875 |
p->alpha = 0.75; |
| 1876 |
|
| 1877 |
} |
| 1878 |
|
| 1879 |
void CG_OilSlickRemove (centity_t *cent) |
| 1880 |
{ |
| 1881 |
cparticle_t *p, *next; |
| 1882 |
int id; |
| 1883 |
|
| 1884 |
id = 1.0f; |
| 1885 |
|
| 1886 |
if (!id) |
| 1887 |
CG_Printf ("CG_OilSlickRevove NULL id\n"); |
| 1888 |
|
| 1889 |
for (p=active_particles ; p ; p=next) |
| 1890 |
{ |
| 1891 |
next = p->next; |
| 1892 |
|
| 1893 |
if (p->type == P_FLAT_SCALEUP) |
| 1894 |
{ |
| 1895 |
if (p->snum == id) |
| 1896 |
{ |
| 1897 |
p->endtime = cg.time + 100; |
| 1898 |
p->startfade = p->endtime; |
| 1899 |
p->type = P_FLAT_SCALEUP_FADE; |
| 1900 |
|
| 1901 |
} |
| 1902 |
} |
| 1903 |
|
| 1904 |
} |
| 1905 |
} |
| 1906 |
|
| 1907 |
qboolean ValidBloodPool (vec3_t start) |
| 1908 |
{ |
| 1909 |
#define EXTRUDE_DIST 0.5 |
| 1910 |
|
| 1911 |
vec3_t angles; |
| 1912 |
vec3_t right, up; |
| 1913 |
vec3_t this_pos, x_pos, center_pos, end_pos; |
| 1914 |
float x, y; |
| 1915 |
float fwidth, fheight; |
| 1916 |
trace_t trace; |
| 1917 |
vec3_t normal; |
| 1918 |
|
| 1919 |
fwidth = 16; |
| 1920 |
fheight = 16; |
| 1921 |
|
| 1922 |
VectorSet (normal, 0, 0, 1); |
| 1923 |
|
| 1924 |
vectoangles (normal, angles); |
| 1925 |
AngleVectors (angles, NULL, right, up); |
| 1926 |
|
| 1927 |
VectorMA (start, EXTRUDE_DIST, normal, center_pos); |
| 1928 |
|
| 1929 |
for (x= -fwidth/2; x<fwidth; x+= fwidth) |
| 1930 |
{ |
| 1931 |
VectorMA (center_pos, x, right, x_pos); |
| 1932 |
|
| 1933 |
for (y= -fheight/2; y<fheight; y+= fheight) |
| 1934 |
{ |
| 1935 |
VectorMA (x_pos, y, up, this_pos); |
| 1936 |
VectorMA (this_pos, -EXTRUDE_DIST*2, normal, end_pos); |
| 1937 |
|
| 1938 |
CG_Trace (&trace, this_pos, NULL, NULL, end_pos, -1, CONTENTS_SOLID); |
| 1939 |
|
| 1940 |
|
| 1941 |
if (trace.entityNum < (MAX_ENTITIES - 1)) // may only land on world |
| 1942 |
return qfalse; |
| 1943 |
|
| 1944 |
if (!(!trace.startsolid && trace.fraction < 1)) |
| 1945 |
return qfalse; |
| 1946 |
|
| 1947 |
} |
| 1948 |
} |
| 1949 |
|
| 1950 |
return qtrue; |
| 1951 |
} |
| 1952 |
|
| 1953 |
void CG_BloodPool (localEntity_t *le, qhandle_t pshader, trace_t *tr) |
| 1954 |
{ |
| 1955 |
cparticle_t *p; |
| 1956 |
qboolean legit; |
| 1957 |
vec3_t start; |
| 1958 |
float rndSize; |
| 1959 |
|
| 1960 |
if (!pshader) |
| 1961 |
CG_Printf ("CG_BloodPool pshader == ZERO!\n"); |
| 1962 |
|
| 1963 |
if (!free_particles) |
| 1964 |
return; |
| 1965 |
|
| 1966 |
VectorCopy (tr->endpos, start); |
| 1967 |
legit = ValidBloodPool (start); |
| 1968 |
|
| 1969 |
if (!legit) |
| 1970 |
return; |
| 1971 |
|
| 1972 |
p = free_particles; |
| 1973 |
free_particles = p->next; |
| 1974 |
p->next = active_particles; |
| 1975 |
active_particles = p; |
| 1976 |
p->time = cg.time; |
| 1977 |
|
| 1978 |
p->endtime = cg.time + 3000; |
| 1979 |
p->startfade = p->endtime; |
| 1980 |
|
| 1981 |
p->alpha = 1.0; |
| 1982 |
p->alphavel = 0; |
| 1983 |
p->roll = 0; |
| 1984 |
|
| 1985 |
p->pshader = pshader; |
| 1986 |
|
| 1987 |
rndSize = 0.4 + random()*0.6; |
| 1988 |
|
| 1989 |
p->width = 8*rndSize; |
| 1990 |
p->height = 8*rndSize; |
| 1991 |
|
| 1992 |
p->endheight = 16*rndSize; |
| 1993 |
p->endwidth = 16*rndSize; |
| 1994 |
|
| 1995 |
p->type = P_FLAT_SCALEUP; |
| 1996 |
|
| 1997 |
VectorCopy(start, p->org ); |
| 1998 |
|
| 1999 |
p->vel[0] = 0; |
| 2000 |
p->vel[1] = 0; |
| 2001 |
p->vel[2] = 0; |
| 2002 |
VectorClear( p->accel ); |
| 2003 |
|
| 2004 |
p->rotate = qfalse; |
| 2005 |
|
| 2006 |
p->roll = rand()%179; |
| 2007 |
|
| 2008 |
p->alpha = 0.75; |
| 2009 |
|
| 2010 |
p->color = BLOODRED; |
| 2011 |
} |
| 2012 |
|
| 2013 |
#define NORMALSIZE 16 |
| 2014 |
#define LARGESIZE 32 |
| 2015 |
|
| 2016 |
void CG_ParticleBloodCloud (centity_t *cent, vec3_t origin, vec3_t dir) |
| 2017 |
{ |
| 2018 |
float length; |
| 2019 |
float dist; |
| 2020 |
float crittersize; |
| 2021 |
vec3_t angles, forward; |
| 2022 |
vec3_t point; |
| 2023 |
cparticle_t *p; |
| 2024 |
int i; |
| 2025 |
|
| 2026 |
dist = 0; |
| 2027 |
|
| 2028 |
length = VectorLength (dir); |
| 2029 |
vectoangles (dir, angles); |
| 2030 |
AngleVectors (angles, forward, NULL, NULL); |
| 2031 |
|
| 2032 |
crittersize = LARGESIZE; |
| 2033 |
|
| 2034 |
if (length) |
| 2035 |
dist = length / crittersize; |
| 2036 |
|
| 2037 |
if (dist < 1) |
| 2038 |
dist = 1; |
| 2039 |
|
| 2040 |
VectorCopy (origin, point); |
| 2041 |
|
| 2042 |
for (i=0; i<dist; i++) |
| 2043 |
{ |
| 2044 |
VectorMA (point, crittersize, forward, point); |
| 2045 |
|
| 2046 |
if (!free_particles) |
| 2047 |
return; |
| 2048 |
|
| 2049 |
p = free_particles; |
| 2050 |
free_particles = p->next; |
| 2051 |
p->next = active_particles; |
| 2052 |
active_particles = p; |
| 2053 |
|
| 2054 |
p->time = cg.time; |
| 2055 |
p->alpha = 1.0; |
| 2056 |
p->alphavel = 0; |
| 2057 |
p->roll = 0; |
| 2058 |
|
| 2059 |
p->pshader = cgs.media.smokePuffShader; |
| 2060 |
|
| 2061 |
p->endtime = cg.time + 350 + (crandom() * 100); |
| 2062 |
|
| 2063 |
p->startfade = cg.time; |
| 2064 |
|
| 2065 |
p->width = LARGESIZE; |
| 2066 |
p->height = LARGESIZE; |
| 2067 |
p->endheight = LARGESIZE; |
| 2068 |
p->endwidth = LARGESIZE; |
| 2069 |
|
| 2070 |
p->type = P_SMOKE; |
| 2071 |
|
| 2072 |
VectorCopy( origin, p->org ); |
| 2073 |
|
| 2074 |
p->vel[0] = 0; |
| 2075 |
p->vel[1] = 0; |
| 2076 |
p->vel[2] = -1; |
| 2077 |
|
| 2078 |
VectorClear( p->accel ); |
| 2079 |
|
| 2080 |
p->rotate = qfalse; |
| 2081 |
|
| 2082 |
p->roll = rand()%179; |
| 2083 |
|
| 2084 |
p->color = BLOODRED; |
| 2085 |
|
| 2086 |
p->alpha = 0.75; |
| 2087 |
|
| 2088 |
} |
| 2089 |
|
| 2090 |
|
| 2091 |
} |
| 2092 |
|
| 2093 |
void CG_ParticleSparks (vec3_t org, vec3_t vel, int duration, float x, float y, float speed) |
| 2094 |
{ |
| 2095 |
cparticle_t *p; |
| 2096 |
|
| 2097 |
if (!free_particles) |
| 2098 |
return; |
| 2099 |
p = free_particles; |
| 2100 |
free_particles = p->next; |
| 2101 |
p->next = active_particles; |
| 2102 |
active_particles = p; |
| 2103 |
p->time = cg.time; |
| 2104 |
|
| 2105 |
p->endtime = cg.time + duration; |
| 2106 |
p->startfade = cg.time + duration/2; |
| 2107 |
|
| 2108 |
p->color = EMISIVEFADE; |
| 2109 |
p->alpha = 0.4f; |
| 2110 |
p->alphavel = 0; |
| 2111 |
|
| 2112 |
p->height = 0.5; |
| 2113 |
p->width = 0.5; |
| 2114 |
p->endheight = 0.5; |
| 2115 |
p->endwidth = 0.5; |
| 2116 |
|
| 2117 |
p->pshader = cgs.media.tracerShader; |
| 2118 |
|
| 2119 |
p->type = P_SMOKE; |
| 2120 |
|
| 2121 |
VectorCopy(org, p->org); |
| 2122 |
|
| 2123 |
p->org[0] += (crandom() * x); |
| 2124 |
p->org[1] += (crandom() * y); |
| 2125 |
|
| 2126 |
p->vel[0] = vel[0]; |
| 2127 |
p->vel[1] = vel[1]; |
| 2128 |
p->vel[2] = vel[2]; |
| 2129 |
|
| 2130 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 2131 |
|
| 2132 |
p->vel[0] += (crandom() * 4); |
| 2133 |
p->vel[1] += (crandom() * 4); |
| 2134 |
p->vel[2] += (20 + (crandom() * 10)) * speed; |
| 2135 |
|
| 2136 |
p->accel[0] = crandom () * 4; |
| 2137 |
p->accel[1] = crandom () * 4; |
| 2138 |
|
| 2139 |
} |
| 2140 |
|
| 2141 |
void CG_ParticleDust (centity_t *cent, vec3_t origin, vec3_t dir) |
| 2142 |
{ |
| 2143 |
float length; |
| 2144 |
float dist; |
| 2145 |
float crittersize; |
| 2146 |
vec3_t angles, forward; |
| 2147 |
vec3_t point; |
| 2148 |
cparticle_t *p; |
| 2149 |
int i; |
| 2150 |
|
| 2151 |
dist = 0; |
| 2152 |
|
| 2153 |
VectorNegate (dir, dir); |
| 2154 |
length = VectorLength (dir); |
| 2155 |
vectoangles (dir, angles); |
| 2156 |
AngleVectors (angles, forward, NULL, NULL); |
| 2157 |
|
| 2158 |
crittersize = LARGESIZE; |
| 2159 |
|
| 2160 |
if (length) |
| 2161 |
dist = length / crittersize; |
| 2162 |
|
| 2163 |
if (dist < 1) |
| 2164 |
dist = 1; |
| 2165 |
|
| 2166 |
VectorCopy (origin, point); |
| 2167 |
|
| 2168 |
for (i=0; i<dist; i++) |
| 2169 |
{ |
| 2170 |
VectorMA (point, crittersize, forward, point); |
| 2171 |
|
| 2172 |
if (!free_particles) |
| 2173 |
return; |
| 2174 |
|
| 2175 |
p = free_particles; |
| 2176 |
free_particles = p->next; |
| 2177 |
p->next = active_particles; |
| 2178 |
active_particles = p; |
| 2179 |
|
| 2180 |
p->time = cg.time; |
| 2181 |
p->alpha = 5.0; |
| 2182 |
p->alphavel = 0; |
| 2183 |
p->roll = 0; |
| 2184 |
|
| 2185 |
p->pshader = cgs.media.smokePuffShader; |
| 2186 |
|
| 2187 |
// RF, stay around for long enough to expand and dissipate naturally |
| 2188 |
if (length) |
| 2189 |
p->endtime = cg.time + 4500 + (crandom() * 3500); |
| 2190 |
else |
| 2191 |
p->endtime = cg.time + 750 + (crandom() * 500); |
| 2192 |
|
| 2193 |
p->startfade = cg.time; |
| 2194 |
|
| 2195 |
p->width = LARGESIZE; |
| 2196 |
p->height = LARGESIZE; |
| 2197 |
|
| 2198 |
// RF, expand while falling |
| 2199 |
p->endheight = LARGESIZE*3.0; |
| 2200 |
p->endwidth = LARGESIZE*3.0; |
| 2201 |
|
| 2202 |
if (!length) |
| 2203 |
{ |
| 2204 |
p->width *= 0.2f; |
| 2205 |
p->height *= 0.2f; |
| 2206 |
|
| 2207 |
p->endheight = NORMALSIZE; |
| 2208 |
p->endwidth = NORMALSIZE; |
| 2209 |
} |
| 2210 |
|
| 2211 |
p->type = P_SMOKE; |
| 2212 |
|
| 2213 |
VectorCopy( point, p->org ); |
| 2214 |
|
| 2215 |
p->vel[0] = crandom()*6; |
| 2216 |
p->vel[1] = crandom()*6; |
| 2217 |
p->vel[2] = random()*20; |
| 2218 |
|
| 2219 |
// RF, add some gravity/randomness |
| 2220 |
p->accel[0] = crandom()*3; |
| 2221 |
p->accel[1] = crandom()*3; |
| 2222 |
p->accel[2] = -PARTICLE_GRAVITY*0.4; |
| 2223 |
|
| 2224 |
VectorClear( p->accel ); |
| 2225 |
|
| 2226 |
p->rotate = qfalse; |
| 2227 |
|
| 2228 |
p->roll = rand()%179; |
| 2229 |
|
| 2230 |
p->alpha = 0.75; |
| 2231 |
|
| 2232 |
} |
| 2233 |
|
| 2234 |
|
| 2235 |
} |
| 2236 |
|
| 2237 |
void CG_ParticleMisc (qhandle_t pshader, vec3_t origin, int size, int duration, float alpha) |
| 2238 |
{ |
| 2239 |
cparticle_t *p; |
| 2240 |
|
| 2241 |
if (!pshader) |
| 2242 |
CG_Printf ("CG_ParticleImpactSmokePuff pshader == ZERO!\n"); |
| 2243 |
|
| 2244 |
if (!free_particles) |
| 2245 |
return; |
| 2246 |
|
| 2247 |
p = free_particles; |
| 2248 |
free_particles = p->next; |
| 2249 |
p->next = active_particles; |
| 2250 |
active_particles = p; |
| 2251 |
p->time = cg.time; |
| 2252 |
p->alpha = 1.0; |
| 2253 |
p->alphavel = 0; |
| 2254 |
p->roll = rand()%179; |
| 2255 |
|
| 2256 |
p->pshader = pshader; |
| 2257 |
|
| 2258 |
if (duration > 0) |
| 2259 |
p->endtime = cg.time + duration; |
| 2260 |
else |
| 2261 |
p->endtime = duration; |
| 2262 |
|
| 2263 |
p->startfade = cg.time; |
| 2264 |
|
| 2265 |
p->width = size; |
| 2266 |
p->height = size; |
| 2267 |
|
| 2268 |
p->endheight = size; |
| 2269 |
p->endwidth = size; |
| 2270 |
|
| 2271 |
p->type = P_SPRITE; |
| 2272 |
|
| 2273 |
VectorCopy( origin, p->org ); |
| 2274 |
|
| 2275 |
p->rotate = qfalse; |
| 2276 |
} |
| 2277 |
|
| 2278 |
|
| 2279 |
|
| 2280 |
|
| 2281 |
|
| 2282 |
// LEILEI ENHANCEMENT PARTICLE EFFECTS |
| 2283 |
|
| 2284 |
|
| 2285 |
// sparks! |
| 2286 |
// for small arms |
| 2287 |
|
| 2288 |
void CG_LeiSparks (vec3_t org, vec3_t vel, int duration, float x, float y, float speed) |
| 2289 |
{ |
| 2290 |
cparticle_t *p; |
| 2291 |
|
| 2292 |
if (!free_particles) |
| 2293 |
return; |
| 2294 |
p = free_particles; |
| 2295 |
free_particles = p->next; |
| 2296 |
p->next = active_particles; |
| 2297 |
active_particles = p; |
| 2298 |
p->time = cg.time; |
| 2299 |
|
| 2300 |
p->endtime = cg.time + duration; |
| 2301 |
p->startfade = cg.time + duration/2; |
| 2302 |
|
| 2303 |
p->color = EMISIVEFADE; |
| 2304 |
p->alpha = 0.8f; |
| 2305 |
p->alphavel = 0.8f; |
| 2306 |
|
| 2307 |
p->height = 4; |
| 2308 |
p->width = 4; |
| 2309 |
p->endheight = 4; |
| 2310 |
p->endwidth = 4; |
| 2311 |
|
| 2312 |
p->pshader = cgs.media.lspkShader1; |
| 2313 |
|
| 2314 |
p->type = P_SMOKE; |
| 2315 |
|
| 2316 |
VectorCopy(org, p->org); |
| 2317 |
|
| 2318 |
p->org[0] += (crandom() * x); |
| 2319 |
p->org[1] += (crandom() * y); |
| 2320 |
|
| 2321 |
p->vel[0] = vel[0] * 75; |
| 2322 |
p->vel[1] = vel[1] * 75; |
| 2323 |
p->vel[2] = vel[2] * 75; |
| 2324 |
|
| 2325 |
|
| 2326 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 2327 |
|
| 2328 |
p->vel[0] += (crandom() * speed); |
| 2329 |
p->vel[1] += (crandom() * speed); |
| 2330 |
p->vel[2] += speed + (crandom() * speed); |
| 2331 |
|
| 2332 |
p->vel[0] += (crandom() * 24); |
| 2333 |
p->vel[1] += (crandom() * 24); |
| 2334 |
p->vel[2] += (20 + (crandom() * 180)); |
| 2335 |
|
| 2336 |
p->accel[0] = crandom()*6; |
| 2337 |
p->accel[1] = crandom()*6; |
| 2338 |
p->accel[2] = -PARTICLE_GRAVITY*7.2; |
| 2339 |
|
| 2340 |
} |
| 2341 |
|
| 2342 |
// a different sort of puff |
| 2343 |
|
| 2344 |
void CG_LeiPuff (vec3_t org, vec3_t vel, int duration, float x, float y, float speed, float size) |
| 2345 |
{ |
| 2346 |
cparticle_t *p; |
| 2347 |
|
| 2348 |
if (!free_particles) |
| 2349 |
return; |
| 2350 |
p = free_particles; |
| 2351 |
free_particles = p->next; |
| 2352 |
p->next = active_particles; |
| 2353 |
active_particles = p; |
| 2354 |
p->time = cg.time; |
| 2355 |
|
| 2356 |
p->endtime = cg.time + duration; |
| 2357 |
p->startfade = cg.time + duration/2; |
| 2358 |
|
| 2359 |
p->color = EMISIVEFADE; |
| 2360 |
p->alpha = 0.8f; |
| 2361 |
p->alphavel = 0.8f; |
| 2362 |
|
| 2363 |
p->height = size; |
| 2364 |
p->width = size; |
| 2365 |
p->endheight = size * 1.8; |
| 2366 |
p->endwidth = size * 1.8; |
| 2367 |
|
| 2368 |
p->pshader = cgs.media.lspkShader1; |
| 2369 |
|
| 2370 |
p->type = P_SMOKE; |
| 2371 |
|
| 2372 |
VectorCopy(org, p->org); |
| 2373 |
|
| 2374 |
p->org[0] += (crandom() * x); |
| 2375 |
p->org[1] += (crandom() * y); |
| 2376 |
|
| 2377 |
p->vel[0] = vel[0] * speed; |
| 2378 |
p->vel[1] = vel[1] * speed; |
| 2379 |
p->vel[2] = vel[2] * speed; |
| 2380 |
|
| 2381 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 2382 |
|
| 2383 |
p->vel[0] += (crandom() * 44); |
| 2384 |
p->vel[1] += (crandom() * 44); |
| 2385 |
p->vel[2] += (crandom() * 44); |
| 2386 |
p->roll = (crandom() * 256 - 128); |
| 2387 |
|
| 2388 |
|
| 2389 |
// p->vel[0] += (crandom() * 24); |
| 2390 |
//p->vel[1] += (crandom() * 24); |
| 2391 |
//p->vel[2] += (20 + (crandom() * 180)) * speed; |
| 2392 |
|
| 2393 |
p->accel[0] = -2; |
| 2394 |
p->accel[1] = -2; |
| 2395 |
p->accel[2] = -2; |
| 2396 |
|
| 2397 |
} |
| 2398 |
|
| 2399 |
// a violent blast puff |
| 2400 |
|
| 2401 |
void CG_LeiBlast (vec3_t org, vec3_t vel, int duration, float x, float y, float speed, float size) |
| 2402 |
{ |
| 2403 |
cparticle_t *p; |
| 2404 |
|
| 2405 |
if (!free_particles) |
| 2406 |
return; |
| 2407 |
p = free_particles; |
| 2408 |
free_particles = p->next; |
| 2409 |
p->next = active_particles; |
| 2410 |
active_particles = p; |
| 2411 |
p->time = cg.time; |
| 2412 |
|
| 2413 |
p->endtime = cg.time + duration; |
| 2414 |
p->startfade = cg.time + duration/2; |
| 2415 |
|
| 2416 |
p->color = EMISIVEFADE; |
| 2417 |
p->alpha = 1.0f; |
| 2418 |
p->alphavel = 0.72f; |
| 2419 |
|
| 2420 |
p->height = size; |
| 2421 |
p->width = size; |
| 2422 |
p->endheight = size * 6; |
| 2423 |
p->endwidth = size * 6; |
| 2424 |
|
| 2425 |
p->pshader = cgs.media.lbumShader1; |
| 2426 |
|
| 2427 |
p->type = P_SMOKE; |
| 2428 |
|
| 2429 |
VectorCopy(org, p->org); |
| 2430 |
|
| 2431 |
p->org[0] += (crandom() * x); |
| 2432 |
p->org[1] += (crandom() * y); |
| 2433 |
|
| 2434 |
p->vel[0] = vel[0] * speed; |
| 2435 |
p->vel[1] = vel[1] * speed; |
| 2436 |
p->vel[2] = vel[2] * speed; |
| 2437 |
|
| 2438 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 2439 |
|
| 2440 |
p->vel[0] += (crandom() * 84); |
| 2441 |
p->vel[1] += (crandom() * 84); |
| 2442 |
p->vel[2] += (crandom() * 84); |
| 2443 |
p->roll = (crandom() * 256 - 128); |
| 2444 |
|
| 2445 |
|
| 2446 |
// p->vel[0] += (crandom() * 24); |
| 2447 |
//p->vel[1] += (crandom() * 24); |
| 2448 |
//p->vel[2] += (20 + (crandom() * 180)) * speed; |
| 2449 |
|
| 2450 |
p->accel[0] = -2; |
| 2451 |
p->accel[1] = -2; |
| 2452 |
p->accel[2] = -2; |
| 2453 |
|
| 2454 |
} |
| 2455 |
|
| 2456 |
// for explosions |
| 2457 |
|
| 2458 |
void CG_LeiSparks2 (vec3_t org, vec3_t vel, int duration, float x, float y, float speed) |
| 2459 |
{ |
| 2460 |
cparticle_t *p; |
| 2461 |
|
| 2462 |
if (!free_particles) |
| 2463 |
return; |
| 2464 |
p = free_particles; |
| 2465 |
free_particles = p->next; |
| 2466 |
p->next = active_particles; |
| 2467 |
active_particles = p; |
| 2468 |
p->time = cg.time; |
| 2469 |
|
| 2470 |
p->endtime = cg.time + duration; |
| 2471 |
p->startfade = cg.time + duration/2; |
| 2472 |
|
| 2473 |
p->color = EMISIVEFADE; |
| 2474 |
p->alpha = 0.8f; |
| 2475 |
p->alphavel = 0; |
| 2476 |
|
| 2477 |
p->height = 9; |
| 2478 |
p->width = 9; |
| 2479 |
p->endheight = 32; |
| 2480 |
p->endwidth = 32; |
| 2481 |
|
| 2482 |
p->pshader = cgs.media.lspkShader1; |
| 2483 |
|
| 2484 |
p->type = P_SMOKE; |
| 2485 |
|
| 2486 |
VectorCopy(org, p->org); |
| 2487 |
|
| 2488 |
p->org[0] += (crandom() * x); |
| 2489 |
p->org[1] += (crandom() * y); |
| 2490 |
|
| 2491 |
p->vel[0] = vel[0] * 15; |
| 2492 |
p->vel[1] = vel[1] * 15; |
| 2493 |
p->vel[2] = vel[2] * 15; |
| 2494 |
|
| 2495 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 2496 |
|
| 2497 |
p->vel[0] += (crandom() * 524); |
| 2498 |
p->vel[1] += (crandom() * 524); |
| 2499 |
p->vel[2] += (120 + (crandom() * 780)) * speed; |
| 2500 |
|
| 2501 |
// p->accel[0] = crandom()*76; |
| 2502 |
// p->accel[1] = crandom()*76; |
| 2503 |
// p->accel[2] = crandom()*76; |
| 2504 |
|
| 2505 |
|
| 2506 |
// VectorCopy( origin, p->org ); |
| 2507 |
// VectorCopy( vel, p->vel ); |
| 2508 |
// VectorClear( p->accel ); |
| 2509 |
|
| 2510 |
|
| 2511 |
|
| 2512 |
} |
| 2513 |
|
| 2514 |
// not so friendly water splash |
| 2515 |
void CG_LeiSplash2 (vec3_t org, vec3_t vel, int duration, float x, float y, float speed) |
| 2516 |
{ |
| 2517 |
cparticle_t *p; |
| 2518 |
|
| 2519 |
if (!free_particles) |
| 2520 |
return; |
| 2521 |
p = free_particles; |
| 2522 |
free_particles = p->next; |
| 2523 |
p->next = active_particles; |
| 2524 |
active_particles = p; |
| 2525 |
p->time = cg.time; |
| 2526 |
|
| 2527 |
p->endtime = cg.time + duration; |
| 2528 |
p->startfade = cg.time + duration/2; |
| 2529 |
|
| 2530 |
p->color = EMISIVEFADE; |
| 2531 |
p->alpha = 0.9f; |
| 2532 |
p->alphavel = 0; |
| 2533 |
|
| 2534 |
p->height = 4; |
| 2535 |
p->width = 4; |
| 2536 |
p->endheight = 2; |
| 2537 |
p->endwidth = 2; |
| 2538 |
|
| 2539 |
p->pshader = cgs.media.lsplShader; |
| 2540 |
|
| 2541 |
p->type = P_SMOKE; |
| 2542 |
|
| 2543 |
VectorCopy(org, p->org); |
| 2544 |
|
| 2545 |
p->org[0] += (crandom() * x); |
| 2546 |
p->org[1] += (crandom() * y); |
| 2547 |
|
| 2548 |
p->vel[0] = vel[0] * 44; |
| 2549 |
p->vel[1] = vel[1] * 44; |
| 2550 |
p->vel[2] = vel[2] * 872; |
| 2551 |
|
| 2552 |
p->accel[0] = p->accel[1] = p->accel[2] = 0; |
| 2553 |
|
| 2554 |
p->vel[0] += (crandom() * 4); |
| 2555 |
p->vel[1] += (crandom() * 4); |
| 2556 |
p->vel[2] += (20 + (crandom() * 10)) * speed; |
| 2557 |
|
| 2558 |
p->accel[0] = crandom()*3; |
| 2559 |
p->accel[1] = crandom()*3; |
| 2560 |
p->accel[2] = -PARTICLE_GRAVITY*4.2; |
| 2561 |
|
| 2562 |
} |
| 2563 |
|