codemp/cgame/cg_marks.c File Reference

#include "cg_local.h"

Go to the source code of this file.

Data Structures

struct  particle_s

Defines

#define MAX_MARK_FRAGMENTS   128
#define MAX_MARK_POINTS   384
#define MARK_TOTAL_TIME   10000
#define MARK_FADE_TIME   1000
#define BLOODRED   2
#define EMISIVEFADE   3
#define GREY75   4
#define MAX_SHADER_ANIMS   32
#define MAX_SHADER_ANIM_FRAMES   64
#define PARTICLE_GRAVITY   40
#define MAX_PARTICLES   1024
#define EXTRUDE_DIST   0.5
#define NORMALSIZE   16
#define LARGESIZE   32

Typedefs

typedef particle_s cparticle_t

Enumerations

enum  particle_type_t {
  P_NONE, P_WEATHER, P_FLAT, P_SMOKE,
  P_ROTATE, P_WEATHER_TURBULENT, P_ANIM, P_BAT,
  P_BLEED, P_FLAT_SCALEUP, P_FLAT_SCALEUP_FADE, P_WEATHER_FLURRY,
  P_SMOKE_IMPACT, P_BUBBLE, P_BUBBLE_TURBULENT, P_SPRITE
}

Functions

void CG_InitMarkPolys (void)
void CG_FreeMarkPoly (markPoly_t *le)
markPoly_tCG_AllocMark (void)
void CG_ImpactMark (qhandle_t markShader, const vec3_t origin, const vec3_t dir, float orientation, float red, float green, float blue, float alpha, qboolean alphaFade, float radius, qboolean temporary)
void CG_AddMarks (void)
void CG_ClearParticles (void)
void CG_AddParticleToScene (cparticle_t *p, vec3_t org, float alpha)
void CG_AddParticles (void)
void CG_ParticleSnowFlurry (qhandle_t pshader, centity_t *cent)
void CG_ParticleSnow (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum)
void CG_ParticleBubble (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum)
void CG_ParticleSmoke (qhandle_t pshader, centity_t *cent)
void CG_ParticleBulletDebris (vec3_t org, vec3_t vel, int duration)
void CG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duration, int sizeStart, int sizeEnd)
void CG_AddParticleShrapnel (localEntity_t *le)
int CG_NewParticleArea (int num)
void CG_SnowLink (centity_t *cent, qboolean particleOn)
void CG_ParticleImpactSmokePuff (qhandle_t pshader, vec3_t origin)
void CG_Particle_Bleed (qhandle_t pshader, vec3_t start, vec3_t dir, int fleshEntityNum, int duration)
void CG_Particle_OilParticle (qhandle_t pshader, centity_t *cent)
void CG_Particle_OilSlick (qhandle_t pshader, centity_t *cent)
void CG_OilSlickRemove (centity_t *cent)
qboolean ValidBloodPool (vec3_t start)
void CG_BloodPool (localEntity_t *le, qhandle_t pshader, trace_t *tr)
void CG_ParticleBloodCloud (centity_t *cent, vec3_t origin, vec3_t dir)
void CG_ParticleSparks (vec3_t org, vec3_t vel, int duration, float x, float y, float speed)
void CG_ParticleDust (centity_t *cent, vec3_t origin, vec3_t dir)
void CG_ParticleMisc (qhandle_t pshader, vec3_t origin, int size, int duration, float alpha)

Variables

markPoly_t cg_activeMarkPolys
markPoly_tcg_freeMarkPolys
markPoly_t cg_markPolys [MAX_MARK_POLYS]
cparticle_tactive_particles
cparticle_tfree_particles
cparticle_t particles [MAX_PARTICLES]
int cl_numparticles = MAX_PARTICLES
qboolean initparticles = qfalse
vec3_t pvforward
vec3_t pvright
vec3_t pvup
vec3_t rforward
vec3_t rright
vec3_t rup
float oldtime


Define Documentation

#define BLOODRED   2
 

Definition at line 296 of file cg_marks.c.

Referenced by CG_AddParticleToScene(), CG_BloodPool(), CG_Particle_Bleed(), and CG_ParticleBloodCloud().

#define EMISIVEFADE   3
 

Definition at line 297 of file cg_marks.c.

Referenced by CG_AddParticleToScene(), CG_ParticleBulletDebris(), and CG_ParticleSparks().

#define EXTRUDE_DIST   0.5
 

Referenced by ValidBloodPool().

#define GREY75   4
 

Definition at line 298 of file cg_marks.c.

Referenced by CG_AddParticleToScene().

#define LARGESIZE   32
 

Definition at line 2009 of file cg_marks.c.

Referenced by CG_ParticleBloodCloud(), and CG_ParticleDust().

#define MARK_FADE_TIME   1000
 

Definition at line 219 of file cg_marks.c.

Referenced by CG_AddMarks().

#define MARK_TOTAL_TIME   10000
 

Definition at line 218 of file cg_marks.c.

Referenced by CG_AddMarks().

#define MAX_MARK_FRAGMENTS   128
 

Definition at line 107 of file cg_marks.c.

Referenced by CG_CreateSaberMarks(), and CG_ImpactMark().

#define MAX_MARK_POINTS   384
 

Definition at line 108 of file cg_marks.c.

Referenced by CG_CreateSaberMarks(), and CG_ImpactMark().

#define MAX_PARTICLES   1024
 

Definition at line 378 of file cg_marks.c.

#define MAX_SHADER_ANIM_FRAMES   64
 

Definition at line 361 of file cg_marks.c.

#define MAX_SHADER_ANIMS   32
 

Definition at line 360 of file cg_marks.c.

#define NORMALSIZE   16
 

Definition at line 2008 of file cg_marks.c.

Referenced by CG_ParticleDust().

#define PARTICLE_GRAVITY   40
 

Definition at line 377 of file cg_marks.c.

Referenced by CG_ParticleDust().


Typedef Documentation

typedef struct particle_s cparticle_t
 

Referenced by CG_AddParticles(), CG_AddParticleToScene(), CG_BloodPool(), CG_OilSlickRemove(), CG_Particle_Bleed(), CG_Particle_OilParticle(), CG_Particle_OilSlick(), CG_ParticleBloodCloud(), CG_ParticleBubble(), CG_ParticleBulletDebris(), CG_ParticleDust(), CG_ParticleExplosion(), CG_ParticleImpactSmokePuff(), CG_ParticleMisc(), CG_ParticleSmoke(), CG_ParticleSnow(), CG_ParticleSnowFlurry(), CG_ParticleSparks(), and CG_SnowLink().


Enumeration Type Documentation

enum particle_type_t
 

Enumeration values:
P_NONE 
P_WEATHER 
P_FLAT 
P_SMOKE 
P_ROTATE 
P_WEATHER_TURBULENT 
P_ANIM 
P_BAT 
P_BLEED 
P_FLAT_SCALEUP 
P_FLAT_SCALEUP_FADE 
P_WEATHER_FLURRY 
P_SMOKE_IMPACT 
P_BUBBLE 
P_BUBBLE_TURBULENT 
P_SPRITE 

Definition at line 340 of file cg_marks.c.

00341 {
00342         P_NONE,
00343         P_WEATHER,
00344         P_FLAT,
00345         P_SMOKE,
00346         P_ROTATE,
00347         P_WEATHER_TURBULENT,
00348         P_ANIM, // Ridah
00349         P_BAT,
00350         P_BLEED,
00351         P_FLAT_SCALEUP,
00352         P_FLAT_SCALEUP_FADE,
00353         P_WEATHER_FLURRY,
00354         P_SMOKE_IMPACT,
00355         P_BUBBLE,
00356         P_BUBBLE_TURBULENT,
00357         P_SPRITE
00358 } particle_type_t;


Function Documentation

void CG_AddMarks void   ) 
 

Definition at line 221 of file cg_marks.c.

References markPoly_s::alphaFade, cg, cg_activeMarkPolys, cg_addMarks, CG_FreeMarkPoly(), markPoly_s::color, vmCvar_t::integer, MARK_FADE_TIME, MARK_TOTAL_TIME, markPoly_t, markPoly_s::markShader, polyVert_t::modulate, markPoly_s::nextMark, poly_s::numVerts, markPoly_s::poly, markPoly_s::time, cg_t::time, trap_R_AddPolyToScene(), and markPoly_s::verts.

Referenced by CG_DrawActiveFrame().

00221                          {
00222         int                     j;
00223         markPoly_t      *mp, *next;
00224         int                     t;
00225         int                     fade;
00226 
00227         if ( !cg_addMarks.integer ) {
00228                 return;
00229         }
00230 
00231         mp = cg_activeMarkPolys.nextMark;
00232         for ( ; mp != &cg_activeMarkPolys ; mp = next ) {
00233                 // grab next now, so if the local entity is freed we
00234                 // still have it
00235                 next = mp->nextMark;
00236 
00237                 // see if it is time to completely remove it
00238                 if ( cg.time > mp->time + MARK_TOTAL_TIME ) {
00239                         CG_FreeMarkPoly( mp );
00240                         continue;
00241                 }
00242 
00243                 // fade out the energy bursts
00244                 //if ( mp->markShader == cgs.media.energyMarkShader ) {
00245                 if (0) {
00246 
00247                         fade = 450 - 450 * ( (cg.time - mp->time ) / 3000.0 );
00248                         if ( fade < 255 ) {
00249                                 if ( fade < 0 ) {
00250                                         fade = 0;
00251                                 }
00252                                 if ( mp->verts[0].modulate[0] != 0 ) {
00253                                         for ( j = 0 ; j < mp->poly.numVerts ; j++ ) {
00254                                                 mp->verts[j].modulate[0] = mp->color[0] * fade;
00255                                                 mp->verts[j].modulate[1] = mp->color[1] * fade;
00256                                                 mp->verts[j].modulate[2] = mp->color[2] * fade;
00257                                         }
00258                                 }
00259                         }
00260                 }
00261 
00262                 // fade all marks out with time
00263                 t = mp->time + MARK_TOTAL_TIME - cg.time;
00264                 if ( t < MARK_FADE_TIME ) {
00265                         fade = 255 * t / MARK_FADE_TIME;
00266                         if ( mp->alphaFade ) {
00267                                 for ( j = 0 ; j < mp->poly.numVerts ; j++ ) {
00268                                         mp->verts[j].modulate[3] = fade;
00269                                 }
00270                         }
00271                         else 
00272                         {
00273                                 float f = (float)t / MARK_FADE_TIME;
00274                                 for ( j = 0 ; j < mp->poly.numVerts ; j++ ) {
00275                                         mp->verts[j].modulate[0] = mp->color[0] * f;
00276                                         mp->verts[j].modulate[1] = mp->color[1] * f;
00277                                         mp->verts[j].modulate[2] = mp->color[2] * f;
00278                                 }
00279                         }
00280                 }
00281                 else
00282                 {
00283                         for ( j = 0 ; j < mp->poly.numVerts ; j++ ) {
00284                                 mp->verts[j].modulate[0] = mp->color[0];
00285                                 mp->verts[j].modulate[1] = mp->color[1];
00286                                 mp->verts[j].modulate[2] = mp->color[2];
00287                         }
00288                 }
00289 
00290                 trap_R_AddPolyToScene( mp->markShader, mp->poly.numVerts, mp->verts );
00291         }
00292 }

void CG_AddParticles void   ) 
 

Definition at line 1081 of file cg_marks.c.

References active_particles, particle_s::alpha, particle_s::alphavel, AngleVectors(), cg, CG_AddParticleToScene(), CG_ClearParticles(), cparticle_t, particle_s::endtime, free_particles, initparticles, particle_s::next, NULL, oldtime, particle_s::org, P_ANIM, P_BAT, P_BLEED, P_FLAT_SCALEUP_FADE, P_SMOKE, P_SMOKE_IMPACT, P_SPRITE, P_WEATHER_FLURRY, pvforward, pvright, pvup, cg_t::refdef, rforward, ROLL, rright, rup, particle_s::time, cg_t::time, particle_s::type, vec3_t, vectoangles(), VectorCopy, and refdef_t::viewaxis.

Referenced by CG_DrawActiveFrame().

01082 {
01083         cparticle_t             *p, *next;
01084         float                   alpha;
01085         float                   time, time2;
01086         vec3_t                  org;
01087         int                             color;
01088         cparticle_t             *active, *tail;
01089         int                             type;
01090         vec3_t                  rotate_ang;
01091 
01092         if (!initparticles)
01093                 CG_ClearParticles ();
01094 
01095         VectorCopy( cg.refdef.viewaxis[0], pvforward );
01096         VectorCopy( cg.refdef.viewaxis[1], pvright );
01097         VectorCopy( cg.refdef.viewaxis[2], pvup );
01098 
01099         vectoangles( cg.refdef.viewaxis[0], rotate_ang );
01100         roll += ((cg.time - oldtime) * 0.1) ;
01101         rotate_ang[ROLL] += (roll*0.9);
01102         AngleVectors ( rotate_ang, rforward, rright, rup);
01103         
01104         oldtime = cg.time;
01105 
01106         active = NULL;
01107         tail = NULL;
01108 
01109         for (p=active_particles ; p ; p=next)
01110         {
01111 
01112                 next = p->next;
01113 
01114                 time = (cg.time - p->time)*0.001;
01115 
01116                 alpha = p->alpha + time*p->alphavel;
01117                 if (alpha <= 0)
01118                 {       // faded out
01119                         p->next = free_particles;
01120                         free_particles = p;
01121                         p->type = 0;
01122                         p->color = 0;
01123                         p->alpha = 0;
01124                         continue;
01125                 }
01126 
01127                 if (p->type == P_SMOKE || p->type == P_ANIM || p->type == P_BLEED || p->type == P_SMOKE_IMPACT)
01128                 {
01129                         if (cg.time > p->endtime)
01130                         {
01131                                 p->next = free_particles;
01132                                 free_particles = p;
01133                                 p->type = 0;
01134                                 p->color = 0;
01135                                 p->alpha = 0;
01136                         
01137                                 continue;
01138                         }
01139 
01140                 }
01141 
01142                 if (p->type == P_WEATHER_FLURRY)
01143                 {
01144                         if (cg.time > p->endtime)
01145                         {
01146                                 p->next = free_particles;
01147                                 free_particles = p;
01148                                 p->type = 0;
01149                                 p->color = 0;
01150                                 p->alpha = 0;
01151                         
01152                                 continue;
01153                         }
01154                 }
01155 
01156 
01157                 if (p->type == P_FLAT_SCALEUP_FADE)
01158                 {
01159                         if (cg.time > p->endtime)
01160                         {
01161                                 p->next = free_particles;
01162                                 free_particles = p;
01163                                 p->type = 0;
01164                                 p->color = 0;
01165                                 p->alpha = 0;
01166                                 continue;
01167                         }
01168 
01169                 }
01170 
01171                 if ((p->type == P_BAT || p->type == P_SPRITE) && p->endtime < 0) {
01172                         // temporary sprite
01173                         CG_AddParticleToScene (p, p->org, alpha);
01174                         p->next = free_particles;
01175                         free_particles = p;
01176                         p->type = 0;
01177                         p->color = 0;
01178                         p->alpha = 0;
01179                         continue;
01180                 }
01181 
01182                 p->next = NULL;
01183                 if (!tail)
01184                         active = tail = p;
01185                 else
01186                 {
01187                         tail->next = p;
01188                         tail = p;
01189                 }
01190 
01191                 if (alpha > 1.0)
01192                         alpha = 1;
01193 
01194                 color = p->color;
01195 
01196                 time2 = time*time;
01197 
01198                 org[0] = p->org[0] + p->vel[0]*time + p->accel[0]*time2;
01199                 org[1] = p->org[1] + p->vel[1]*time + p->accel[1]*time2;
01200                 org[2] = p->org[2] + p->vel[2]*time + p->accel[2]*time2;
01201 
01202                 type = p->type;
01203 
01204                 CG_AddParticleToScene (p, org, alpha);
01205         }
01206 
01207         active_particles = active;
01208 }

void CG_AddParticleShrapnel localEntity_t le  ) 
 

Definition at line 1550 of file cg_marks.c.

References localEntity_t.

01551 {
01552         return;
01553 }

void CG_AddParticleToScene cparticle_t p,
vec3_t  org,
float  alpha
 

Definition at line 436 of file cg_marks.c.

References particle_s::accumroll, particle_s::alpha, AngleVectors(), BLOODRED, cg, particle_s::color, cos(), cparticle_t, crandom, DEG2RAD, EMISIVEFADE, particle_s::end, particle_s::endheight, particle_s::endtime, particle_s::endwidth, floor(), GREY75, particle_s::height, particle_s::link, polyVert_t::modulate, NULL, particle_s::org, playerState_s::origin, P_ANIM, P_BLEED, P_BUBBLE, P_BUBBLE_TURBULENT, P_FLAT, P_FLAT_SCALEUP, P_SMOKE, P_SMOKE_IMPACT, P_SPRITE, P_WEATHER, P_WEATHER_FLURRY, P_WEATHER_TURBULENT, snapshot_t::ps, particle_s::pshader, pvright, pvup, cg_t::refdef, rforward, ROLL, particle_s::roll, particle_s::rotate, rright, rup, particle_s::shaderAnim, sin(), cg_t::snap, sqrt(), polyVert_t::st, particle_s::start, particle_s::startfade, cg_t::time, particle_s::time, trap_R_AddPolyToScene(), particle_s::type, vec3_t, vectoangles(), VectorCopy, VectorMA, VectorSet, particle_s::vel, refdef_t::viewaxis, particle_s::width, and polyVert_t::xyz.

Referenced by CG_AddParticles().

00437 {
00438 
00439         vec3_t          point;
00440         polyVert_t      verts[4];
00441         float           width;
00442         float           height;
00443         float           time, time2;
00444         float           ratio;
00445         float           invratio;
00446         vec3_t          color;
00447         polyVert_t      TRIverts[3];
00448         vec3_t          rright2, rup2;
00449 
00450         if (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY
00451                 || p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT)
00452         {// create a front facing polygon
00453                         
00454                 if (p->type != P_WEATHER_FLURRY)
00455                 {
00456                         if (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT)
00457                         {
00458                                 if (org[2] > p->end)                    
00459                                 {       
00460                                         p->time = cg.time;      
00461                                         VectorCopy (org, p->org); // Ridah, fixes rare snow flakes that flicker on the ground
00462                                                                         
00463                                         p->org[2] = ( p->start + crandom () * 4 );
00464                                         
00465                                         
00466                                         if (p->type == P_BUBBLE_TURBULENT)
00467                                         {
00468                                                 p->vel[0] = crandom() * 4;
00469                                                 p->vel[1] = crandom() * 4;
00470                                         }
00471                                 
00472                                 }
00473                         }
00474                         else
00475                         {
00476                                 if (org[2] < p->end)                    
00477                                 {       
00478                                         p->time = cg.time;      
00479                                         VectorCopy (org, p->org); // Ridah, fixes rare snow flakes that flicker on the ground
00480                                                                         
00481                                         while (p->org[2] < p->end) 
00482                                         {
00483                                                 p->org[2] += (p->start - p->end); 
00484                                         }
00485                                         
00486                                         
00487                                         if (p->type == P_WEATHER_TURBULENT)
00488                                         {
00489                                                 p->vel[0] = crandom() * 16;
00490                                                 p->vel[1] = crandom() * 16;
00491                                         }
00492                                 
00493                                 }
00494                         }
00495                         
00496 
00497                         // Rafael snow pvs check
00498                         if (!p->link)
00499                                 return;
00500 
00501                         p->alpha = 1;
00502                 }
00503                 
00504                 // Ridah, had to do this or MAX_POLYS is being exceeded in village1.bsp
00505                 if (Distance( cg.snap->ps.origin, org ) > 1024) {
00506                         return;
00507                 }
00508                 // done.
00509         
00510                 if (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT)
00511                 {
00512                         VectorMA (org, -p->height, pvup, point);        
00513                         VectorMA (point, -p->width, pvright, point);    
00514                         VectorCopy (point, verts[0].xyz);       
00515                         verts[0].st[0] = 0;     
00516                         verts[0].st[1] = 0;     
00517                         verts[0].modulate[0] = 255;     
00518                         verts[0].modulate[1] = 255;     
00519                         verts[0].modulate[2] = 255;     
00520                         verts[0].modulate[3] = 255 * p->alpha;  
00521 
00522                         VectorMA (org, -p->height, pvup, point);        
00523                         VectorMA (point, p->width, pvright, point);     
00524                         VectorCopy (point, verts[1].xyz);       
00525                         verts[1].st[0] = 0;     
00526                         verts[1].st[1] = 1;     
00527                         verts[1].modulate[0] = 255;     
00528                         verts[1].modulate[1] = 255;     
00529                         verts[1].modulate[2] = 255;     
00530                         verts[1].modulate[3] = 255 * p->alpha;  
00531 
00532                         VectorMA (org, p->height, pvup, point); 
00533                         VectorMA (point, p->width, pvright, point);     
00534                         VectorCopy (point, verts[2].xyz);       
00535                         verts[2].st[0] = 1;     
00536                         verts[2].st[1] = 1;     
00537                         verts[2].modulate[0] = 255;     
00538                         verts[2].modulate[1] = 255;     
00539                         verts[2].modulate[2] = 255;     
00540                         verts[2].modulate[3] = 255 * p->alpha;  
00541 
00542                         VectorMA (org, p->height, pvup, point); 
00543                         VectorMA (point, -p->width, pvright, point);    
00544                         VectorCopy (point, verts[3].xyz);       
00545                         verts[3].st[0] = 1;     
00546                         verts[3].st[1] = 0;     
00547                         verts[3].modulate[0] = 255;     
00548                         verts[3].modulate[1] = 255;     
00549                         verts[3].modulate[2] = 255;     
00550                         verts[3].modulate[3] = 255 * p->alpha;  
00551                 }
00552                 else
00553                 {
00554                         VectorMA (org, -p->height, pvup, point);        
00555                         VectorMA (point, -p->width, pvright, point);    
00556                         VectorCopy( point, TRIverts[0].xyz );
00557                         TRIverts[0].st[0] = 1;
00558                         TRIverts[0].st[1] = 0;
00559                         TRIverts[0].modulate[0] = 255;
00560                         TRIverts[0].modulate[1] = 255;
00561                         TRIverts[0].modulate[2] = 255;
00562                         TRIverts[0].modulate[3] = 255 * p->alpha;       
00563 
00564                         VectorMA (org, p->height, pvup, point); 
00565                         VectorMA (point, -p->width, pvright, point);    
00566                         VectorCopy (point, TRIverts[1].xyz);    
00567                         TRIverts[1].st[0] = 0;
00568                         TRIverts[1].st[1] = 0;
00569                         TRIverts[1].modulate[0] = 255;
00570                         TRIverts[1].modulate[1] = 255;
00571                         TRIverts[1].modulate[2] = 255;
00572                         TRIverts[1].modulate[3] = 255 * p->alpha;       
00573 
00574                         VectorMA (org, p->height, pvup, point); 
00575                         VectorMA (point, p->width, pvright, point);     
00576                         VectorCopy (point, TRIverts[2].xyz);    
00577                         TRIverts[2].st[0] = 0;
00578                         TRIverts[2].st[1] = 1;
00579                         TRIverts[2].modulate[0] = 255;
00580                         TRIverts[2].modulate[1] = 255;
00581                         TRIverts[2].modulate[2] = 255;
00582                         TRIverts[2].modulate[3] = 255 * p->alpha;       
00583                 }
00584         
00585         }
00586         else if (p->type == P_SPRITE)
00587         {
00588                 vec3_t  rr, ru;
00589                 vec3_t  rotate_ang;
00590 
00591                 VectorSet (color, 1.0, 1.0, 0.5);
00592                 time = cg.time - p->time;
00593                 time2 = p->endtime - p->time;
00594                 ratio = time / time2;
00595 
00596                 width = p->width + ( ratio * ( p->endwidth - p->width) );
00597                 height = p->height + ( ratio * ( p->endheight - p->height) );
00598 
00599                 if (p->roll) {
00600                         vectoangles( cg.refdef.viewaxis[0], rotate_ang );
00601                         rotate_ang[ROLL] += p->roll;
00602                         AngleVectors ( rotate_ang, NULL, rr, ru);
00603                 }
00604 
00605                 if (p->roll) {
00606                         VectorMA (org, -height, ru, point);     
00607                         VectorMA (point, -width, rr, point);    
00608                 } else {
00609                         VectorMA (org, -height, pvup, point);   
00610                         VectorMA (point, -width, pvright, point);       
00611                 }
00612                 VectorCopy (point, verts[0].xyz);       
00613                 verts[0].st[0] = 0;     
00614                 verts[0].st[1] = 0;     
00615                 verts[0].modulate[0] = 255;     
00616                 verts[0].modulate[1] = 255;     
00617                 verts[0].modulate[2] = 255;     
00618                 verts[0].modulate[3] = 255;
00619 
00620                 if (p->roll) {
00621                         VectorMA (point, 2*height, ru, point);  
00622                 } else {
00623                         VectorMA (point, 2*height, pvup, point);        
00624                 }
00625                 VectorCopy (point, verts[1].xyz);       
00626                 verts[1].st[0] = 0;     
00627                 verts[1].st[1] = 1;     
00628                 verts[1].modulate[0] = 255;     
00629                 verts[1].modulate[1] = 255;     
00630                 verts[1].modulate[2] = 255;     
00631                 verts[1].modulate[3] = 255;     
00632 
00633                 if (p->roll) {
00634                         VectorMA (point, 2*width, rr, point);   
00635                 } else {
00636                         VectorMA (point, 2*width, pvright, point);      
00637                 }
00638                 VectorCopy (point, verts[2].xyz);       
00639                 verts[2].st[0] = 1;     
00640                 verts[2].st[1] = 1;     
00641                 verts[2].modulate[0] = 255;     
00642                 verts[2].modulate[1] = 255;     
00643                 verts[2].modulate[2] = 255;     
00644                 verts[2].modulate[3] = 255;     
00645 
00646                 if (p->roll) {
00647                         VectorMA (point, -2*height, ru, point); 
00648                 } else {
00649                         VectorMA (point, -2*height, pvup, point);       
00650                 }
00651                 VectorCopy (point, verts[3].xyz);       
00652                 verts[3].st[0] = 1;     
00653                 verts[3].st[1] = 0;     
00654                 verts[3].modulate[0] = 255;     
00655                 verts[3].modulate[1] = 255;     
00656                 verts[3].modulate[2] = 255;     
00657                 verts[3].modulate[3] = 255;     
00658         }
00659         else if (p->type == P_SMOKE || p->type == P_SMOKE_IMPACT)
00660         {// create a front rotating facing polygon
00661 
00662                 if ( p->type == P_SMOKE_IMPACT && Distance( cg.snap->ps.origin, org ) > 1024) {
00663                         return;
00664                 }
00665 
00666                 if (p->color == BLOODRED)
00667                         VectorSet (color, 0.22f, 0.0f, 0.0f);
00668                 else if (p->color == GREY75)
00669                 {
00670                         float   len;
00671                         float   greyit;
00672                         float   val;
00673                         len = Distance (cg.snap->ps.origin, org);
00674                         if (!len)
00675                                 len = 1;
00676 
00677                         val = 4096/len;
00678                         greyit = 0.25 * val;
00679                         if (greyit > 0.5)
00680                                 greyit = 0.5;
00681 
00682                         VectorSet (color, greyit, greyit, greyit);
00683                 }
00684                 else
00685                         VectorSet (color, 1.0, 1.0, 1.0);
00686 
00687                 time = cg.time - p->time;
00688                 time2 = p->endtime - p->time;
00689                 ratio = time / time2;
00690                 
00691                 if (cg.time > p->startfade)
00692                 {
00693                         invratio = 1 - ( (cg.time - p->startfade) / (p->endtime - p->startfade) );
00694 
00695                         if (p->color == EMISIVEFADE)
00696                         {
00697                                 float fval;
00698                                 fval = (invratio * invratio);
00699                                 if (fval < 0)
00700                                         fval = 0;
00701                                 VectorSet (color, fval , fval , fval );
00702                         }
00703                         invratio *= p->alpha;
00704                 }
00705                 else 
00706                         invratio = 1 * p->alpha;
00707 
00708                 if (invratio > 1)
00709                         invratio = 1;
00710         
00711                 width = p->width + ( ratio * ( p->endwidth - p->width) );
00712                 height = p->height + ( ratio * ( p->endheight - p->height) );
00713 
00714                 if (p->type != P_SMOKE_IMPACT)
00715                 {
00716                         vec3_t temp;
00717 
00718                         vectoangles (rforward, temp);
00719                         p->accumroll += p->roll;
00720                         temp[ROLL] += p->accumroll * 0.1;
00721                         AngleVectors ( temp, NULL, rright2, rup2);
00722                 }
00723                 else
00724                 {
00725                         VectorCopy (rright, rright2);
00726                         VectorCopy (rup, rup2);
00727                 }
00728                 
00729                 if (p->rotate)
00730                 {
00731                         VectorMA (org, -height, rup2, point);   
00732                         VectorMA (point, -width, rright2, point);       
00733                 }
00734                 else
00735                 {
00736                         VectorMA (org, -p->height, pvup, point);        
00737                         VectorMA (point, -p->width, pvright, point);    
00738                 }
00739                 VectorCopy (point, verts[0].xyz);       
00740                 verts[0].st[0] = 0;     
00741                 verts[0].st[1] = 0;     
00742                 verts[0].modulate[0] = 255 * color[0];  
00743                 verts[0].modulate[1] = 255 * color[1];  
00744                 verts[0].modulate[2] = 255 * color[2];  
00745                 verts[0].modulate[3] = 255 * invratio;  
00746 
00747                 if (p->rotate)
00748                 {
00749                         VectorMA (org, -height, rup2, point);   
00750                         VectorMA (point, width, rright2, point);        
00751                 }
00752                 else
00753                 {
00754                         VectorMA (org, -p->height, pvup, point);        
00755                         VectorMA (point, p->width, pvright, point);     
00756                 }
00757                 VectorCopy (point, verts[1].xyz);       
00758                 verts[1].st[0] = 0;     
00759                 verts[1].st[1] = 1;     
00760                 verts[1].modulate[0] = 255 * color[0];  
00761                 verts[1].modulate[1] = 255 * color[1];  
00762                 verts[1].modulate[2] = 255 * color[2];  
00763                 verts[1].modulate[3] = 255 * invratio;  
00764 
00765                 if (p->rotate)
00766                 {
00767                         VectorMA (org, height, rup2, point);    
00768                         VectorMA (point, width, rright2, point);        
00769                 }
00770                 else
00771                 {
00772                         VectorMA (org, p->height, pvup, point); 
00773                         VectorMA (point, p->width, pvright, point);     
00774                 }
00775                 VectorCopy (point, verts[2].xyz);       
00776                 verts[2].st[0] = 1;     
00777                 verts[2].st[1] = 1;     
00778                 verts[2].modulate[0] = 255 * color[0];  
00779                 verts[2].modulate[1] = 255 * color[1];  
00780                 verts[2].modulate[2] = 255 * color[2];  
00781                 verts[2].modulate[3] = 255 * invratio;  
00782 
00783                 if (p->rotate)
00784                 {
00785                         VectorMA (org, height, rup2, point);    
00786                         VectorMA (point, -width, rright2, point);       
00787                 }
00788                 else
00789                 {
00790                         VectorMA (org, p->height, pvup, point); 
00791                         VectorMA (point, -p->width, pvright, point);    
00792                 }
00793                 VectorCopy (point, verts[3].xyz);       
00794                 verts[3].st[0] = 1;     
00795                 verts[3].st[1] = 0;     
00796                 verts[3].modulate[0] = 255 * color[0];  
00797                 verts[3].modulate[1] = 255 * color[1];  
00798                 verts[3].modulate[2] = 255 * color[2];  
00799                 verts[3].modulate[3] = 255  * invratio; 
00800                 
00801         }
00802         else if (p->type == P_BLEED)
00803         {
00804                 vec3_t  rr, ru;
00805                 vec3_t  rotate_ang;
00806                 float   alpha;
00807 
00808                 alpha = p->alpha;
00809                 
00810                 if (p->roll) 
00811                 {
00812                         vectoangles( cg.refdef.viewaxis[0], rotate_ang );
00813                         rotate_ang[ROLL] += p->roll;
00814                         AngleVectors ( rotate_ang, NULL, rr, ru);
00815                 }
00816                 else
00817                 {
00818                         VectorCopy (pvup, ru);
00819                         VectorCopy (pvright, rr);
00820                 }
00821 
00822                 VectorMA (org, -p->height, ru, point);  
00823                 VectorMA (point, -p->width, rr, point); 
00824                 VectorCopy (point, verts[0].xyz);       
00825                 verts[0].st[0] = 0;     
00826                 verts[0].st[1] = 0;     
00827                 verts[0].modulate[0] = 111;     
00828                 verts[0].modulate[1] = 19;      
00829                 verts[0].modulate[2] = 9;       
00830                 verts[0].modulate[3] = 255 * alpha;     
00831 
00832                 VectorMA (org, -p->height, ru, point);  
00833                 VectorMA (point, p->width, rr, point);  
00834                 VectorCopy (point, verts[1].xyz);       
00835                 verts[1].st[0] = 0;     
00836                 verts[1].st[1] = 1;     
00837                 verts[1].modulate[0] = 111;     
00838                 verts[1].modulate[1] = 19;      
00839                 verts[1].modulate[2] = 9;       
00840                 verts[1].modulate[3] = 255 * alpha;     
00841 
00842                 VectorMA (org, p->height, ru, point);   
00843                 VectorMA (point, p->width, rr, point);  
00844                 VectorCopy (point, verts[2].xyz);       
00845                 verts[2].st[0] = 1;     
00846                 verts[2].st[1] = 1;     
00847                 verts[2].modulate[0] = 111;     
00848                 verts[2].modulate[1] = 19;      
00849                 verts[2].modulate[2] = 9;       
00850                 verts[2].modulate[3] = 255 * alpha;     
00851 
00852                 VectorMA (org, p->height, ru, point);   
00853                 VectorMA (point, -p->width, rr, point); 
00854                 VectorCopy (point, verts[3].xyz);       
00855                 verts[3].st[0] = 1;     
00856                 verts[3].st[1] = 0;     
00857                 verts[3].modulate[0] = 111;     
00858                 verts[3].modulate[1] = 19;      
00859                 verts[3].modulate[2] = 9;       
00860                 verts[3].modulate[3] = 255 * alpha;     
00861 
00862         }
00863         else if (p->type == P_FLAT_SCALEUP)
00864         {
00865                 float width, height;
00866                 float sinR, cosR;
00867 
00868                 if (p->color == BLOODRED)
00869                         VectorSet (color, 1, 1, 1);
00870                 else
00871                         VectorSet (color, 0.5, 0.5, 0.5);
00872                 
00873                 time = cg.time - p->time;
00874                 time2 = p->endtime - p->time;
00875                 ratio = time / time2;
00876 
00877                 width = p->width + ( ratio * ( p->endwidth - p->width) );
00878                 height = p->height + ( ratio * ( p->endheight - p->height) );
00879 
00880                 if (width > p->endwidth)
00881                         width = p->endwidth;
00882 
00883                 if (height > p->endheight)
00884                         height = p->endheight;
00885 
00886                 sinR = height * sin(DEG2RAD(p->roll)) * sqrt(2.0f);
00887                 cosR = width * cos(DEG2RAD(p->roll)) * sqrt(2.0f);
00888 
00889                 VectorCopy (org, verts[0].xyz); 
00890                 verts[0].xyz[0] -= sinR;
00891                 verts[0].xyz[1] -= cosR;
00892                 verts[0].st[0] = 0;     
00893                 verts[0].st[1] = 0;     
00894                 verts[0].modulate[0] = 255 * color[0];  
00895                 verts[0].modulate[1] = 255 * color[1];  
00896                 verts[0].modulate[2] = 255 * color[2];  
00897                 verts[0].modulate[3] = 255;     
00898 
00899                 VectorCopy (org, verts[1].xyz); 
00900                 verts[1].xyz[0] -= cosR;        
00901                 verts[1].xyz[1] += sinR;        
00902                 verts[1].st[0] = 0;     
00903                 verts[1].st[1] = 1;     
00904                 verts[1].modulate[0] = 255 * color[0];  
00905                 verts[1].modulate[1] = 255 * color[1];  
00906                 verts[1].modulate[2] = 255 * color[2];  
00907                 verts[1].modulate[3] = 255;     
00908 
00909                 VectorCopy (org, verts[2].xyz); 
00910                 verts[2].xyz[0] += sinR;        
00911                 verts[2].xyz[1] += cosR;        
00912                 verts[2].st[0] = 1;     
00913                 verts[2].st[1] = 1;     
00914                 verts[2].modulate[0] = 255 * color[0];  
00915                 verts[2].modulate[1] = 255 * color[1];  
00916                 verts[2].modulate[2] = 255 * color[2];  
00917                 verts[2].modulate[3] = 255;     
00918 
00919                 VectorCopy (org, verts[3].xyz); 
00920                 verts[3].xyz[0] += cosR;        
00921                 verts[3].xyz[1] -= sinR;        
00922                 verts[3].st[0] = 1;     
00923                 verts[3].st[1] = 0;     
00924                 verts[3].modulate[0] = 255 * color[0];  
00925                 verts[3].modulate[1] = 255 * color[1];  
00926                 verts[3].modulate[2] = 255 * color[2];  
00927                 verts[3].modulate[3] = 255;             
00928         }
00929         else if (p->type == P_FLAT)
00930         {
00931 
00932                 VectorCopy (org, verts[0].xyz); 
00933                 verts[0].xyz[0] -= p->height;   
00934                 verts[0].xyz[1] -= p->width;    
00935                 verts[0].st[0] = 0;     
00936                 verts[0].st[1] = 0;     
00937                 verts[0].modulate[0] = 255;     
00938                 verts[0].modulate[1] = 255;     
00939                 verts[0].modulate[2] = 255;     
00940                 verts[0].modulate[3] = 255;     
00941 
00942                 VectorCopy (org, verts[1].xyz); 
00943                 verts[1].xyz[0] -= p->height;   
00944                 verts[1].xyz[1] += p->width;    
00945                 verts[1].st[0] = 0;     
00946                 verts[1].st[1] = 1;     
00947                 verts[1].modulate[0] = 255;     
00948                 verts[1].modulate[1] = 255;     
00949                 verts[1].modulate[2] = 255;     
00950                 verts[1].modulate[3] = 255;     
00951 
00952                 VectorCopy (org, verts[2].xyz); 
00953                 verts[2].xyz[0] += p->height;   
00954                 verts[2].xyz[1] += p->width;    
00955                 verts[2].st[0] = 1;     
00956                 verts[2].st[1] = 1;     
00957                 verts[2].modulate[0] = 255;     
00958                 verts[2].modulate[1] = 255;     
00959                 verts[2].modulate[2] = 255;     
00960                 verts[2].modulate[3] = 255;     
00961 
00962                 VectorCopy (org, verts[3].xyz); 
00963                 verts[3].xyz[0] += p->height;   
00964                 verts[3].xyz[1] -= p->width;    
00965                 verts[3].st[0] = 1;     
00966                 verts[3].st[1] = 0;     
00967                 verts[3].modulate[0] = 255;     
00968                 verts[3].modulate[1] = 255;     
00969                 verts[3].modulate[2] = 255;     
00970                 verts[3].modulate[3] = 255;     
00971 
00972         }
00973         // Ridah
00974         else if (p->type == P_ANIM) {
00975                 vec3_t  rr, ru;
00976                 vec3_t  rotate_ang;
00977                 int i, j;
00978 
00979                 time = cg.time - p->time;
00980                 time2 = p->endtime - p->time;
00981                 ratio = time / time2;
00982                 if (ratio >= 1.0f) {
00983                         ratio = 0.9999f;
00984                 }
00985 
00986                 width = p->width + ( ratio * ( p->endwidth - p->width) );
00987                 height = p->height + ( ratio * ( p->endheight - p->height) );
00988 
00989                 // if we are "inside" this sprite, don't draw
00990                 if (Distance( cg.snap->ps.origin, org ) < width/1.5) {
00991                         return;
00992                 }
00993 
00994                 i = p->shaderAnim;
00995                 j = (int)floor(ratio * shaderAnimCounts[p->shaderAnim]);
00996                 p->pshader = shaderAnims[i][j];
00997 
00998                 if (p->roll) {
00999                         vectoangles( cg.refdef.viewaxis[0], rotate_ang );
01000                         rotate_ang[ROLL] += p->roll;
01001                         AngleVectors ( rotate_ang, NULL, rr, ru);
01002                 }
01003 
01004                 if (p->roll) {
01005                         VectorMA (org, -height, ru, point);     
01006                         VectorMA (point, -width, rr, point);    
01007                 } else {
01008                         VectorMA (org, -height, pvup, point);   
01009                         VectorMA (point, -width, pvright, point);       
01010                 }
01011                 VectorCopy (point, verts[0].xyz);       
01012                 verts[0].st[0] = 0;     
01013                 verts[0].st[1] = 0;     
01014                 verts[0].modulate[0] = 255;     
01015                 verts[0].modulate[1] = 255;     
01016                 verts[0].modulate[2] = 255;     
01017                 verts[0].modulate[3] = 255;
01018 
01019                 if (p->roll) {
01020                         VectorMA (point, 2*height, ru, point);  
01021                 } else {
01022                         VectorMA (point, 2*height, pvup, point);        
01023                 }
01024                 VectorCopy (point, verts[1].xyz);       
01025                 verts[1].st[0] = 0;     
01026                 verts[1].st[1] = 1;     
01027                 verts[1].modulate[0] = 255;     
01028                 verts[1].modulate[1] = 255;     
01029                 verts[1].modulate[2] = 255;     
01030                 verts[1].modulate[3] = 255;     
01031 
01032                 if (p->roll) {
01033                         VectorMA (point, 2*width, rr, point);   
01034                 } else {
01035                         VectorMA (point, 2*width, pvright, point);      
01036                 }
01037                 VectorCopy (point, verts[2].xyz);       
01038                 verts[2].st[0] = 1;     
01039                 verts[2].st[1] = 1;     
01040                 verts[2].modulate[0] = 255;     
01041                 verts[2].modulate[1] = 255;     
01042                 verts[2].modulate[2] = 255;     
01043                 verts[2].modulate[3] = 255;     
01044 
01045                 if (p->roll) {
01046                         VectorMA (point, -2*height, ru, point); 
01047                 } else {
01048                         VectorMA (point, -2*height, pvup, point);       
01049                 }
01050                 VectorCopy (point, verts[3].xyz);       
01051                 verts[3].st[0] = 1;     
01052                 verts[3].st[1] = 0;     
01053                 verts[3].modulate[0] = 255;     
01054                 verts[3].modulate[1] = 255;     
01055                 verts[3].modulate[2] = 255;     
01056                 verts[3].modulate[3] = 255;     
01057         }
01058         // done.
01059         
01060         if (!p->pshader) {
01061 // (SA) temp commented out for DM
01062 //              CG_Printf ("CG_AddParticleToScene type %d p->pshader == ZERO\n", p->type);
01063                 return;
01064         }
01065 
01066         if (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY)
01067                 trap_R_AddPolyToScene( p->pshader, 3, TRIverts );
01068         else
01069                 trap_R_AddPolyToScene( p->pshader, 4, verts );
01070 
01071 }

markPoly_t* CG_AllocMark void   ) 
 

Definition at line 68 of file cg_marks.c.

References cg_activeMarkPolys, CG_FreeMarkPoly(), cg_freeMarkPolys, markPoly_t, memset(), markPoly_s::nextMark, markPoly_s::prevMark, and markPoly_s::time.

Referenced by CG_CreateSaberMarks(), and CG_ImpactMark().

00068                                       {
00069         markPoly_t      *le;
00070         int time;
00071 
00072         if ( !cg_freeMarkPolys ) {
00073                 // no free entities, so free the one at the end of the chain
00074                 // remove the oldest active entity
00075                 time = cg_activeMarkPolys.prevMark->time;
00076                 while (cg_activeMarkPolys.prevMark && time == cg_activeMarkPolys.prevMark->time) {
00077                         CG_FreeMarkPoly( cg_activeMarkPolys.prevMark );
00078                 }
00079         }
00080 
00081         le = cg_freeMarkPolys;
00082         cg_freeMarkPolys = cg_freeMarkPolys->nextMark;
00083 
00084         memset( le, 0, sizeof( *le ) );
00085 
00086         // link into the active list
00087         le->nextMark = cg_activeMarkPolys.nextMark;
00088         le->prevMark = &cg_activeMarkPolys;
00089         cg_activeMarkPolys.nextMark->prevMark = le;
00090         cg_activeMarkPolys.nextMark = le;
00091         return le;
00092 }

void CG_BloodPool localEntity_t le,
qhandle_t  pshader,
trace_t tr
 

Definition at line 1948 of file cg_marks.c.

References active_particles, BLOODRED, cg, CG_Printf(), cparticle_t, trace_t::endpos, free_particles, localEntity_t, particle_s::next, P_FLAT_SCALEUP, qboolean, qfalse, qhandle_t, rand(), random, cg_t::time, particle_s::time, ValidBloodPool(), vec3_t, VectorClear, and VectorCopy.

01949 {       
01950         cparticle_t     *p;
01951         qboolean        legit;
01952         vec3_t          start;
01953         float           rndSize;
01954         
01955         if (!pshader)
01956                 CG_Printf ("CG_BloodPool pshader == ZERO!\n");
01957 
01958         if (!free_particles)
01959                 return;
01960         
01961         VectorCopy (tr->endpos, start);
01962         legit = ValidBloodPool (start);
01963 
01964         if (!legit) 
01965                 return;
01966 
01967         p = free_particles;
01968         free_particles = p->next;
01969         p->next = active_particles;
01970         active_particles = p;
01971         p->time = cg.time;
01972         
01973         p->endtime = cg.time + 3000;
01974         p->startfade = p->endtime;
01975 
01976         p->alpha = 1.0;
01977         p->alphavel = 0;
01978         p->roll = 0;
01979 
01980         p->pshader = pshader;
01981 
01982         rndSize = 0.4 + random()*0.6;
01983 
01984         p->width = 8*rndSize;
01985         p->height = 8*rndSize;
01986 
01987         p->endheight = 16*rndSize;
01988         p->endwidth = 16*rndSize;
01989         
01990         p->type = P_FLAT_SCALEUP;
01991 
01992         VectorCopy(start, p->org );
01993         
01994         p->vel[0] = 0;
01995         p->vel[1] = 0;
01996         p->vel[2] = 0;
01997         VectorClear( p->accel );
01998 
01999         p->rotate = qfalse;
02000 
02001         p->roll = rand()%179;
02002         
02003         p->alpha = 0.75;
02004         
02005         p->color = BLOODRED;
02006 }

void CG_ClearParticles void   ) 
 

Definition at line 395 of file cg_marks.c.

References active_particles, cg, cl_numparticles, free_particles, initparticles, memset(), particle_s::next, NULL, oldtime, particles, qtrue, cg_t::time, and particle_s::type.

Referenced by CG_AddParticles().

00396 {
00397         int             i;
00398 
00399         memset( particles, 0, sizeof(particles) );
00400 
00401         free_particles = &particles[0];
00402         active_particles = NULL;
00403 
00404         for (i=0 ;i<cl_numparticles ; i++)
00405         {
00406                 particles[i].next = &particles[i+1];
00407                 particles[i].type = 0;
00408         }
00409         particles[cl_numparticles-1].next = NULL;
00410 
00411         oldtime = cg.time;
00412 
00413         /*
00414         // Ridah, init the shaderAnims
00415         for (i=0; shaderAnimNames[i]; i++) {
00416                 int j;
00417 
00418                 for (j=0; j<shaderAnimCounts[i]; j++) {
00419                         shaderAnims[i][j] = trap_R_RegisterShader( va("%s%i", shaderAnimNames[i], j+1) );
00420                 }
00421         }
00422         numShaderAnims = i;
00423         */
00424         numShaderAnims = 0;
00425         // done.
00426 
00427         initparticles = qtrue;
00428 }

void CG_FreeMarkPoly markPoly_t le  ) 
 

Definition at line 47 of file cg_marks.c.

References CG_Error(), cg_freeMarkPolys, markPoly_t, markPoly_s::nextMark, and markPoly_s::prevMark.

Referenced by CG_AddMarks(), and CG_AllocMark().

00047                                        {
00048         if ( !le->prevMark ) {
00049                 CG_Error( "CG_FreeLocalEntity: not active" );
00050         }
00051 
00052         // remove from the doubly linked active list
00053         le->prevMark->nextMark = le->nextMark;
00054         le->nextMark->prevMark = le->prevMark;
00055 
00056         // the free list is only singly linked
00057         le->nextMark = cg_freeMarkPolys;
00058         cg_freeMarkPolys = le;
00059 }

void CG_ImpactMark qhandle_t  markShader,
const vec3_t  origin,
const vec3_t  dir,
float  orientation,
float  red,
float  green,
float  blue,
float  alpha,
qboolean  alphaFade,
float  radius,
qboolean  temporary
 

Definition at line 110 of file cg_marks.c.

References markPoly_s::alphaFade, byte, cg, cg_addMarks, CG_AllocMark(), CG_Error(), markPoly_s::color, DotProduct, vmCvar_t::integer, markPoly_t, markPoly_s::markShader, MAX_MARK_FRAGMENTS, MAX_MARK_POINTS, MAX_VERTS_ON_POLY, memcpy(), poly_s::numVerts, PerpendicularVector(), markPoly_s::poly, qhandle_t, RotatePointAroundVector(), cg_t::time, markPoly_s::time, trap_CM_MarkFragments(), trap_R_AddDecalToScene(), trap_R_AddPolyToScene(), vec3_t, VectorCopy, VectorNormalize2(), VectorScale, VectorSubtract, and markPoly_s::verts.

00112                                                                                           {
00113         vec3_t                  axis[3];
00114         float                   texCoordScale;
00115         vec3_t                  originalPoints[4];
00116         byte                    colors[4];
00117         int                             i, j;
00118         int                             numFragments;
00119         markFragment_t  markFragments[MAX_MARK_FRAGMENTS], *mf;
00120         vec3_t                  markPoints[MAX_MARK_POINTS];
00121         vec3_t                  projection;
00122 
00123         assert(markShader);
00124 
00125         if ( !cg_addMarks.integer ) {
00126                 return;
00127         }
00128         else if (cg_addMarks.integer == 2)
00129         {
00130                 trap_R_AddDecalToScene(markShader, origin, dir, orientation, red, green, blue, alpha,
00131                         alphaFade, radius, temporary);
00132                 return;
00133         }
00134 
00135         if ( radius <= 0 ) {
00136                 CG_Error( "CG_ImpactMark called with <= 0 radius" );
00137         }
00138 
00139         //if ( markTotal >= MAX_MARK_POLYS ) {
00140         //      return;
00141         //}
00142 
00143         // create the texture axis
00144         VectorNormalize2( dir, axis[0] );
00145         PerpendicularVector( axis[1], axis[0] );
00146         RotatePointAroundVector( axis[2], axis[0], axis[1], orientation );
00147         CrossProduct( axis[0], axis[2], axis[1] );
00148 
00149         texCoordScale = 0.5 * 1.0 / radius;
00150 
00151         // create the full polygon
00152         for ( i = 0 ; i < 3 ; i++ ) {
00153                 originalPoints[0][i] = origin[i] - radius * axis[1][i] - radius * axis[2][i];
00154                 originalPoints[1][i] = origin[i] + radius * axis[1][i] - radius * axis[2][i];
00155                 originalPoints[2][i] = origin[i] + radius * axis[1][i] + radius * axis[2][i];
00156                 originalPoints[3][i] = origin[i] - radius * axis[1][i] + radius * axis[2][i];
00157         }
00158 
00159         // get the fragments
00160         VectorScale( dir, -20, projection );
00161         numFragments = trap_CM_MarkFragments( 4, (const vec3_t *) originalPoints,
00162                                         projection, MAX_MARK_POINTS, markPoints[0],
00163                                         MAX_MARK_FRAGMENTS, markFragments );
00164 
00165         colors[0] = red * 255;
00166         colors[1] = green * 255;
00167         colors[2] = blue * 255;
00168         colors[3] = alpha * 255;
00169 
00170         for ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ ) {
00171                 polyVert_t      *v;
00172                 polyVert_t      verts[MAX_VERTS_ON_POLY];
00173                 markPoly_t      *mark;
00174 
00175                 // we have an upper limit on the complexity of polygons
00176                 // that we store persistantly
00177                 if ( mf->numPoints > MAX_VERTS_ON_POLY ) {
00178                         mf->numPoints = MAX_VERTS_ON_POLY;
00179                 }
00180                 for ( j = 0, v = verts ; j < mf->numPoints ; j++, v++ ) {
00181                         vec3_t          delta;
00182 
00183                         VectorCopy( markPoints[mf->firstPoint + j], v->xyz );
00184 
00185                         VectorSubtract( v->xyz, origin, delta );
00186                         v->st[0] = 0.5 + DotProduct( delta, axis[1] ) * texCoordScale;
00187                         v->st[1] = 0.5 + DotProduct( delta, axis[2] ) * texCoordScale;
00188                         *(int *)v->modulate = *(int *)colors;
00189                 }
00190 
00191                 // if it is a temporary (shadow) mark, add it immediately and forget about it
00192                 if ( temporary ) {
00193                         trap_R_AddPolyToScene( markShader, mf->numPoints, verts );
00194                         continue;
00195                 }
00196 
00197                 // otherwise save it persistantly
00198                 mark = CG_AllocMark();
00199                 mark->time = cg.time;
00200                 mark->alphaFade = alphaFade;
00201                 mark->markShader = markShader;
00202                 mark->poly.numVerts = mf->numPoints;
00203                 mark->color[0] = red;
00204                 mark->color[1] = green;
00205                 mark->color[2] = blue;
00206                 mark->color[3] = alpha;
00207                 memcpy( mark->verts, verts, mf->numPoints * sizeof( verts[0] ) );
00208                 markTotal++;
00209         }
00210 }

void CG_InitMarkPolys void   ) 
 

Definition at line 28 of file cg_marks.c.

References cg_activeMarkPolys, cg_freeMarkPolys, cg_markPolys, MAX_MARK_POLYS, memset(), markPoly_s::nextMark, and markPoly_s::prevMark.

Referenced by CG_Init().

00028                                  {
00029         int             i;
00030 
00031         memset( cg_markPolys, 0, sizeof(cg_markPolys) );
00032 
00033         cg_activeMarkPolys.nextMark = &cg_activeMarkPolys;
00034         cg_activeMarkPolys.prevMark = &cg_activeMarkPolys;
00035         cg_freeMarkPolys = cg_markPolys;
00036         for ( i = 0 ; i < MAX_MARK_POLYS - 1 ; i++ ) {
00037                 cg_markPolys[i].nextMark = &cg_markPolys[i+1];
00038         }
00039 }

int CG_NewParticleArea int  num  ) 
 

Definition at line 1556 of file cg_marks.c.

References atof(), atoi(), CG_ConfigString(), COM_Parse(), and vec3_t.

01557 {
01558         // const char *str;
01559         char *str;
01560         char *token;
01561         int type;
01562         vec3_t origin, origin2;
01563         int             i;
01564         float range = 0;
01565         int turb;
01566         int     numparticles;
01567         int     snum;
01568         
01569         str = (char *) CG_ConfigString (num);
01570         if (!str[0])
01571                 return (0);
01572         
01573         // returns type 128 64 or 32
01574         token = COM_Parse ((const char **)&str);
01575         type = atoi (token);
01576         
01577         if (type == 1)
01578                 range = 128;
01579         else if (type == 2)
01580                 range = 64;
01581         else if (type == 3)
01582                 range = 32;
01583         else if (type == 0)
01584                 range = 256;
01585         else if (type == 4)
01586                 range = 8;
01587         else if (type == 5)
01588                 range = 16;
01589         else if (type == 6)
01590                 range = 32;
01591         else if (type == 7)
01592                 range = 64;
01593 
01594 
01595         for (i=0; i<3; i++)
01596         {
01597                 token = COM_Parse ((const char **)&str);
01598                 origin[i] = atof (token);
01599         }
01600 
01601         for (i=0; i<3; i++)
01602         {
01603                 token = COM_Parse ((const char **)&str);
01604                 origin2[i] = atof (token);
01605         }
01606                 
01607         token = COM_Parse ((const char **)&str);
01608         numparticles = atoi (token);
01609         
01610         token = COM_Parse ((const char **)&str);
01611         turb = atoi (token);
01612 
01613         token = COM_Parse ((const char **)&str);
01614         snum = atoi (token);
01615         
01616         /*
01617         for (i=0; i<numparticles; i++)
01618         {
01619                 if (type >= 4)
01620                         CG_ParticleBubble (cgs.media.waterBubbleShader, origin, origin2, turb, range, snum);
01621                 else
01622                         CG_ParticleSnow (cgs.media.waterBubbleShader, origin, origin2, turb, range, snum);
01623         }
01624         */
01625 
01626         return (1);
01627 }

void CG_OilSlickRemove centity_t cent  ) 
 

Definition at line 1874 of file cg_marks.c.

References active_particles, centity_t, cg, CG_Printf(), cparticle_t, particle_s::endtime, particle_s::next, P_FLAT_SCALEUP, P_FLAT_SCALEUP_FADE, particle_s::snum, particle_s::startfade, cg_t::time, and particle_s::type.

01875 {
01876         cparticle_t             *p, *next;
01877         int                             id;
01878 
01879         id = 1.0f;
01880 
01881         if (!id)
01882                 CG_Printf ("CG_OilSlickRevove NULL id\n");
01883 
01884         for (p=active_particles ; p ; p=next)
01885         {
01886                 next = p->next;
01887                 
01888                 if (p->type == P_FLAT_SCALEUP)
01889                 {
01890                         if (p->snum == id)
01891                         {
01892                                 p->endtime = cg.time + 100;
01893                                 p->startfade = p->endtime;
01894                                 p->type = P_FLAT_SCALEUP_FADE;
01895 
01896                         }
01897                 }
01898 
01899         }
01900 }

void CG_Particle_Bleed qhandle_t  pshader,
vec3_t  start,
vec3_t  dir,
int  fleshEntityNum,
int  duration
 

Definition at line 1694 of file cg_marks.c.

References active_particles, BLOODRED, cg, CG_Printf(), cparticle_t, free_particles, particle_s::next, P_SMOKE, qfalse, qhandle_t, rand(), cg_t::time, particle_s::time, vec3_t, VectorClear, and VectorCopy.

01695 {
01696         cparticle_t     *p;
01697 
01698         if (!pshader)
01699                 CG_Printf ("CG_Particle_Bleed pshader == ZERO!\n");
01700 
01701         if (!free_particles)
01702                 return;
01703         p = free_particles;
01704         free_particles = p->next;
01705         p->next = active_particles;
01706         active_particles = p;
01707         p->time = cg.time;
01708         p->alpha = 1.0;
01709         p->alphavel = 0;
01710         p->roll = 0;
01711 
01712         p->pshader = pshader;
01713 
01714         p->endtime = cg.time + duration;
01715         
01716         if (fleshEntityNum)
01717                 p->startfade = cg.time;
01718         else
01719                 p->startfade = cg.time + 100;
01720 
01721         p->width = 4;
01722         p->height = 4;
01723 
01724         p->endheight = 4+rand()%3;
01725         p->endwidth = p->endheight;
01726 
01727         p->type = P_SMOKE;
01728 
01729         VectorCopy( start, p->org );
01730         p->vel[0] = 0;
01731         p->vel[1] = 0;
01732         p->vel[2] = -20;
01733         VectorClear( p->accel );
01734 
01735         p->rotate = qfalse;
01736 
01737         p->roll = rand()%179;
01738         
01739         p->color = BLOODRED;
01740         p->alpha = 0.75;
01741 
01742 }

void CG_Particle_OilParticle qhandle_t  pshader,
centity_t cent
 

Definition at line 1744 of file cg_marks.c.

References active_particles, centity_t, cg, CG_Printf(), cparticle_t, centity_s::currentState, free_particles, particle_s::next, entityState_s::origin, entityState_s::origin2, P_SMOKE, qfalse, qhandle_t, rand(), particle_s::time, entityState_s::time, cg_t::time, VectorClear, and VectorCopy.

01745 {
01746         cparticle_t     *p;
01747 
01748         int                     time;
01749         int                     time2;
01750         float           ratio;
01751 
01752         float   duration = 1500;
01753 
01754         time = cg.time;
01755         time2 = cg.time + cent->currentState.time;
01756 
01757         ratio =(float)1 - ((float)time / (float)time2);
01758 
01759         if (!pshader)
01760                 CG_Printf ("CG_Particle_OilParticle == ZERO!\n");
01761 
01762         if (!free_particles)
01763                 return;
01764         p = free_particles;
01765         free_particles = p->next;
01766         p->next = active_particles;
01767         active_particles = p;
01768         p->time = cg.time;
01769         p->alpha = 1.0;
01770         p->alphavel = 0;
01771         p->roll = 0;
01772 
01773         p->pshader = pshader;
01774 
01775         p->endtime = cg.time + duration;
01776         
01777         p->startfade = p->endtime;
01778 
01779         p->width = 1;
01780         p->height = 3;
01781 
01782         p->endheight = 3;
01783         p->endwidth = 1;
01784 
01785         p->type = P_SMOKE;
01786 
01787         VectorCopy(cent->currentState.origin, p->org ); 
01788         
01789         p->vel[0] = (cent->currentState.origin2[0] * (16 * ratio));
01790         p->vel[1] = (cent->currentState.origin2[1] * (16 * ratio));
01791         p->vel[2] = (cent->currentState.origin2[2]);
01792 
01793         p->snum = 1.0f;
01794 
01795         VectorClear( p->accel );
01796 
01797         p->accel[2] = -20;
01798 
01799         p->rotate = qfalse;
01800 
01801         p->roll = rand()%179;
01802         
01803         p->alpha = 0.75;
01804 
01805 }

void CG_Particle_OilSlick qhandle_t  pshader,
centity_t cent
 

Definition at line 1808 of file cg_marks.c.

References active_particles, entityState_s::angles2, centity_t, cg, CG_Printf(), cparticle_t, crandom, centity_s::currentState, free_particles, particle_s::next, entityState_s::origin, P_FLAT_SCALEUP, qfalse, qhandle_t, rand(), cg_t::time, particle_s::time, VectorClear, and VectorCopy.

01809 {
01810         cparticle_t     *p;
01811         
01812         if (!pshader)
01813                 CG_Printf ("CG_Particle_OilSlick == ZERO!\n");
01814 
01815         if (!free_particles)
01816                 return;
01817         p = free_particles;
01818         free_particles = p->next;
01819         p->next = active_particles;
01820         active_particles = p;
01821         p->time = cg.time;
01822         
01823         if (cent->currentState.angles2[2])
01824                 p->endtime = cg.time + cent->currentState.angles2[2];
01825         else
01826                 p->endtime = cg.time + 60000;
01827 
01828         p->startfade = p->endtime;
01829 
01830         p->alpha = 1.0;
01831         p->alphavel = 0;
01832         p->roll = 0;
01833 
01834         p->pshader = pshader;
01835 
01836         if (cent->currentState.angles2[0] || cent->currentState.angles2[1])
01837         {
01838                 p->width = cent->currentState.angles2[0];
01839                 p->height = cent->currentState.angles2[0];
01840 
01841                 p->endheight = cent->currentState.angles2[1];
01842                 p->endwidth = cent->currentState.angles2[1];
01843         }
01844         else
01845         {
01846                 p->width = 8;
01847                 p->height = 8;
01848 
01849                 p->endheight = 16;
01850                 p->endwidth = 16;
01851         }
01852 
01853         p->type = P_FLAT_SCALEUP;
01854 
01855         p->snum = 1.0;
01856 
01857         VectorCopy(cent->currentState.origin, p->org );
01858         
01859         p->org[2]+= 0.55 + (crandom() * 0.5);
01860 
01861         p->vel[0] = 0;
01862         p->vel[1] = 0;
01863         p->vel[2] = 0;
01864         VectorClear( p->accel );
01865 
01866         p->rotate = qfalse;
01867 
01868         p->roll = rand()%179;
01869         
01870         p->alpha = 0.75;
01871 
01872 }

void CG_ParticleBloodCloud centity_t cent,
vec3_t  origin,
vec3_t  dir
 

Definition at line 2011 of file cg_marks.c.

References active_particles, AngleVectors(), BLOODRED, centity_t, cg, cparticle_t, crandom, free_particles, LARGESIZE, particle_s::next, NULL, P_SMOKE, qfalse, rand(), cg_t::time, particle_s::time, vec3_t, vectoangles(), VectorClear, VectorCopy, and VectorMA.

02012 {
02013         float   length;
02014         float   dist;
02015         float   crittersize;
02016         vec3_t  angles, forward;
02017         vec3_t  point;
02018         cparticle_t     *p;
02019         int             i;
02020         
02021         dist = 0;
02022 
02023         length = VectorLength (dir);
02024         vectoangles (dir, angles);
02025         AngleVectors (angles, forward, NULL, NULL);
02026 
02027         crittersize = LARGESIZE;
02028 
02029         if (length)
02030                 dist = length / crittersize;
02031 
02032         if (dist < 1)
02033                 dist = 1;
02034 
02035         VectorCopy (origin, point);
02036 
02037         for (i=0; i<dist; i++)
02038         {
02039                 VectorMA (point, crittersize, forward, point);  
02040                 
02041                 if (!free_particles)
02042                         return;
02043 
02044                 p = free_particles;
02045                 free_particles = p->next;
02046                 p->next = active_particles;
02047                 active_particles = p;
02048 
02049                 p->time = cg.time;
02050                 p->alpha = 1.0;
02051                 p->alphavel = 0;
02052                 p->roll = 0;
02053 
02054                 p->pshader = 0;//cgs.media.smokePuffShader;
02055 
02056                 p->endtime = cg.time + 350 + (crandom() * 100);
02057                 
02058                 p->startfade = cg.time;
02059                 
02060                 p->width = LARGESIZE;
02061                 p->height = LARGESIZE;
02062                 p->endheight = LARGESIZE;
02063                 p->endwidth = LARGESIZE;
02064 
02065                 p->type = P_SMOKE;
02066 
02067                 VectorCopy( origin, p->org );
02068                 
02069                 p->vel[0] = 0;
02070                 p->vel[1] = 0;
02071                 p->vel[2] = -1;
02072                 
02073                 VectorClear( p->accel );
02074 
02075                 p->rotate = qfalse;
02076 
02077                 p->roll = rand()%179;
02078                 
02079                 p->color = BLOODRED;
02080                 
02081                 p->alpha = 0.75;
02082                 
02083         }
02084 
02085         
02086 }

void CG_ParticleBubble qhandle_t  pshader,
vec3_t  origin,
vec3_t  origin2,
int  turb,
float  range,
int  snum
 

Definition at line 1340 of file cg_marks.c.

References active_particles, cg, CG_Printf(), cparticle_t, crandom, free_particles, particle_s::next, P_BUBBLE, P_BUBBLE_TURBULENT, qhandle_t, qtrue, cg_t::time, particle_s::time, vec3_t, and VectorCopy.

01341 {
01342         cparticle_t     *p;
01343         float           randsize;
01344 
01345         if (!pshader)
01346                 CG_Printf ("CG_ParticleSnow pshader == ZERO!\n");
01347 
01348         if (!free_particles)
01349                 return;
01350         p = free_particles;
01351         free_particles = p->next;
01352         p->next = active_particles;
01353         active_particles = p;
01354         p->time = cg.time;
01355         p->color = 0;
01356         p->alpha = 0.40f;
01357         p->alphavel = 0;
01358         p->start = origin[2];
01359         p->end = origin2[2];
01360         p->pshader = pshader;
01361         
01362         randsize = 1 + (crandom() * 0.5);
01363         
01364         p->height = randsize;
01365         p->width = randsize;
01366         
01367         p->vel[2] = 50 + ( crandom() * 10 );
01368 
01369         if (turb)
01370         {
01371                 p->type = P_BUBBLE_TURBULENT;
01372                 p->vel[2] = 50 * 1.3;
01373         }
01374         else
01375         {
01376                 p->type = P_BUBBLE;
01377         }
01378         
01379         VectorCopy(origin, p->org);
01380 
01381         p->org[0] = p->org[0] + ( crandom() * range);
01382         p->org[1] = p->org[1] + ( crandom() * range);
01383         p->org[2] = p->org[2] + ( crandom() * (p->start - p->end)); 
01384 
01385         p->vel[0] = p->vel[1] = 0;
01386         
01387         p->accel[0] = p->accel[1] = p->accel[2] = 0;
01388 
01389         if (turb)
01390         {
01391                 p->vel[0] = crandom() * 4;
01392                 p->vel[1] = crandom() * 4;
01393         }
01394 
01395         // Rafael snow pvs check
01396         p->snum = snum;
01397         p->link = qtrue;
01398 
01399 }

void CG_ParticleBulletDebris vec3_t  org,
vec3_t  vel,
int  duration
 

Definition at line 1449 of file cg_marks.c.

References active_particles, cg, cparticle_t, EMISIVEFADE, free_particles, particle_s::next, P_SMOKE, cg_t::time, particle_s::time, vec3_t, and VectorCopy.

01450 {
01451 
01452         cparticle_t     *p;
01453 
01454         if (!free_particles)
01455                 return;
01456         p = free_particles;
01457         free_particles = p->next;
01458         p->next = active_particles;
01459         active_particles = p;
01460         p->time = cg.time;
01461         
01462         p->endtime = cg.time + duration;
01463         p->startfade = cg.time + duration/2;
01464         
01465         p->color = EMISIVEFADE;
01466         p->alpha = 1.0;
01467         p->alphavel = 0;
01468 
01469         p->height = 0.5;
01470         p->width = 0.5;
01471         p->endheight = 0.5;
01472         p->endwidth = 0.5;
01473 
01474         p->pshader = 0;//cgs.media.tracerShader;
01475 
01476         p->type = P_SMOKE;
01477         
01478         VectorCopy(org, p->org);
01479 
01480         p->vel[0] = vel[0];
01481         p->vel[1] = vel[1];
01482         p->vel[2] = vel[2];
01483         p->accel[0] = p->accel[1] = p->accel[2] = 0;
01484 
01485         p->accel[2] = -60;
01486         p->vel[2] += -20;
01487         
01488 }

void CG_ParticleDust centity_t cent,
vec3_t  origin,
vec3_t  dir
 

Definition at line 2136 of file cg_marks.c.

References active_particles, AngleVectors(), centity_t, cg, cparticle_t, crandom, free_particles, LARGESIZE, particle_s::next, NORMALSIZE, NULL, P_SMOKE, PARTICLE_GRAVITY, qfalse, rand(), random, cg_t::time, particle_s::time, vec3_t, vectoangles(), VectorClear, VectorCopy, VectorMA, and VectorNegate.

02137 {
02138         float   length;
02139         float   dist;
02140         float   crittersize;
02141         vec3_t  angles, forward;
02142         vec3_t  point;
02143         cparticle_t     *p;
02144         int             i;
02145         
02146         dist = 0;
02147 
02148         VectorNegate (dir, dir);
02149         length = VectorLength (dir);
02150         vectoangles (dir, angles);
02151         AngleVectors (angles, forward, NULL, NULL);
02152 
02153         crittersize = LARGESIZE;
02154 
02155         if (length)
02156                 dist = length / crittersize;
02157 
02158         if (dist < 1)
02159                 dist = 1;
02160 
02161         VectorCopy (origin, point);
02162 
02163         for (i=0; i<dist; i++)
02164         {
02165                 VectorMA (point, crittersize, forward, point);  
02166                                 
02167                 if (!free_particles)
02168                         return;
02169 
02170                 p = free_particles;
02171                 free_particles = p->next;
02172                 p->next = active_particles;
02173                 active_particles = p;
02174 
02175                 p->time = cg.time;
02176                 p->alpha = 5.0;
02177                 p->alphavel = 0;
02178                 p->roll = 0;
02179 
02180                 p->pshader = 0;//cgs.media.smokePuffShader;
02181 
02182                 // RF, stay around for long enough to expand and dissipate naturally
02183                 if (length)
02184                         p->endtime = cg.time + 4500 + (crandom() * 3500);
02185                 else
02186                         p->endtime = cg.time + 750 + (crandom() * 500);
02187                 
02188                 p->startfade = cg.time;
02189                 
02190                 p->width = LARGESIZE;
02191                 p->height = LARGESIZE;
02192 
02193                 // RF, expand while falling
02194                 p->endheight = LARGESIZE*3.0;
02195                 p->endwidth = LARGESIZE*3.0;
02196 
02197                 if (!length)
02198                 {
02199                         p->width *= 0.2f;
02200                         p->height *= 0.2f;
02201 
02202                         p->endheight = NORMALSIZE;
02203                         p->endwidth = NORMALSIZE;
02204                 }
02205 
02206                 p->type = P_SMOKE;
02207 
02208                 VectorCopy( point, p->org );
02209                 
02210                 p->vel[0] = crandom()*6;
02211                 p->vel[1] = crandom()*6;
02212                 p->vel[2] = random()*20;
02213 
02214                 // RF, add some gravity/randomness
02215                 p->accel[0] = crandom()*3;
02216                 p->accel[1] = crandom()*3;
02217                 p->accel[2] = -PARTICLE_GRAVITY*0.4;
02218 
02219                 VectorClear( p->accel );
02220 
02221                 p->rotate = qfalse;
02222 
02223                 p->roll = rand()%179;
02224                 
02225                 p->alpha = 0.75;
02226                 
02227         }
02228 
02229         
02230 }

void CG_ParticleExplosion char *  animStr,
vec3_t  origin,
vec3_t  vel,
int  duration,
int  sizeStart,
int  sizeEnd
 

Definition at line 1496 of file cg_marks.c.

References active_particles, cg, CG_Error(), cparticle_t, crandom, free_particles, particle_s::next, P_ANIM, Q_stricmp(), cg_t::time, particle_s::time, vec3_t, VectorClear, and VectorCopy.

01497 {
01498         cparticle_t     *p;
01499         int anim;
01500 
01501         if (animStr < (char *)10)
01502                 CG_Error( "CG_ParticleExplosion: animStr is probably an index rather than a string" );
01503 
01504         // find the animation string
01505         for (anim=0; shaderAnimNames[anim]; anim++) {
01506                 if (!Q_stricmp( animStr, shaderAnimNames[anim] ))
01507                         break;
01508         }
01509         if (!shaderAnimNames[anim]) {
01510                 CG_Error("CG_ParticleExplosion: unknown animation string: %s\n", animStr);
01511                 return;
01512         }
01513 
01514         if (!free_particles)
01515                 return;
01516         p = free_particles;
01517         free_particles = p->next;
01518         p->next = active_particles;
01519         active_particles = p;
01520         p->time = cg.time;
01521         p->alpha = 0.5;
01522         p->alphavel = 0;
01523 
01524         if (duration < 0) {
01525                 duration *= -1;
01526                 p->roll = 0;
01527         } else {
01528                 p->roll = crandom()*179;
01529         }
01530 
01531         p->shaderAnim = anim;
01532 
01533         p->width = sizeStart;
01534         p->height = sizeStart*shaderAnimSTRatio[anim];  // for sprites that are stretch in either direction
01535 
01536         p->endheight = sizeEnd;
01537         p->endwidth = sizeEnd*shaderAnimSTRatio[anim];
01538 
01539         p->endtime = cg.time + duration;
01540 
01541         p->type = P_ANIM;
01542 
01543         VectorCopy( origin, p->org );
01544         VectorCopy( vel, p->vel );
01545         VectorClear( p->accel );
01546 
01547 }

void CG_ParticleImpactSmokePuff qhandle_t  pshader,
vec3_t  origin
 

Definition at line 1654 of file cg_marks.c.

References active_particles, cg, CG_Printf(), cparticle_t, crandom, free_particles, particle_s::next, P_SMOKE_IMPACT, qhandle_t, qtrue, rand(), cg_t::time, particle_s::time, vec3_t, VectorCopy, and VectorSet.

01655 {
01656         cparticle_t     *p;
01657 
01658         if (!pshader)
01659                 CG_Printf ("CG_ParticleImpactSmokePuff pshader == ZERO!\n");
01660 
01661         if (!free_particles)
01662                 return;
01663         p = free_particles;
01664         free_particles = p->next;
01665         p->next = active_particles;
01666         active_particles = p;
01667         p->time = cg.time;
01668         p->alpha = 0.25;
01669         p->alphavel = 0;
01670         p->roll = crandom()*179;
01671 
01672         p->pshader = pshader;
01673 
01674         p->endtime = cg.time + 1000;
01675         p->startfade = cg.time + 100;
01676 
01677         p->width = rand()%4 + 8;
01678         p->height = rand()%4 + 8;
01679 
01680         p->endheight = p->height *2;
01681         p->endwidth = p->width * 2;
01682 
01683         p->endtime = cg.time + 500;
01684 
01685         p->type = P_SMOKE_IMPACT;
01686 
01687         VectorCopy( origin, p->org );
01688         VectorSet(p->vel, 0, 0, 20);
01689         VectorSet(p->accel, 0, 0, 20);
01690 
01691         p->rotate = qtrue;
01692 }

void CG_ParticleMisc qhandle_t  pshader,
vec3_t  origin,
int  size,
int  duration,
float  alpha
 

Definition at line 2232 of file cg_marks.c.

References active_particles, cg, CG_Printf(), cparticle_t, free_particles, particle_s::next, P_SPRITE, qfalse, qhandle_t, rand(), cg_t::time, particle_s::time, vec3_t, and VectorCopy.

02233 {
02234         cparticle_t     *p;
02235 
02236         if (!pshader)
02237                 CG_Printf ("CG_ParticleImpactSmokePuff pshader == ZERO!\n");
02238 
02239         if (!free_particles)
02240                 return;
02241 
02242         p = free_particles;
02243         free_particles = p->next;
02244         p->next = active_particles;
02245         active_particles = p;
02246         p->time = cg.time;
02247         p->alpha = 1.0;
02248         p->alphavel = 0;
02249         p->roll = rand()%179;
02250 
02251         p->pshader = pshader;
02252 
02253         if (duration > 0)
02254                 p->endtime = cg.time + duration;
02255         else
02256                 p->endtime = duration;
02257 
02258         p->startfade = cg.time;
02259 
02260         p->width = size;
02261         p->height = size;
02262 
02263         p->endheight = size;
02264         p->endwidth = size;
02265 
02266         p->type = P_SPRITE;
02267 
02268         VectorCopy( origin, p->org );
02269 
02270         p->rotate = qfalse;
02271 }

void CG_ParticleSmoke qhandle_t  pshader,
centity_t cent
 

Definition at line 1401 of file cg_marks.c.

References active_particles, centity_t, cg, CG_Printf(), cparticle_t, crandom, centity_s::currentState, entityState_s::frame, free_particles, particle_s::next, entityState_s::origin, entityState_s::origin2, P_SMOKE, qfalse, qhandle_t, entityState_s::time, cg_t::time, particle_s::time, entityState_s::time2, and VectorCopy.

01402 {
01403 
01404         // using cent->density = enttime
01405         //               cent->frame = startfade
01406         cparticle_t     *p;
01407 
01408         if (!pshader)
01409                 CG_Printf ("CG_ParticleSmoke == ZERO!\n");
01410 
01411         if (!free_particles)
01412                 return;
01413         p = free_particles;
01414         free_particles = p->next;
01415         p->next = active_particles;
01416         active_particles = p;
01417         p->time = cg.time;
01418         
01419         p->endtime = cg.time + cent->currentState.time;
01420         p->startfade = cg.time + cent->currentState.time2;
01421         
01422         p->color = 0;
01423         p->alpha = 1.0;
01424         p->alphavel = 0;
01425         p->start = cent->currentState.origin[2];
01426         p->end = cent->currentState.origin2[2];
01427         p->pshader = pshader;
01428         p->rotate = qfalse;
01429         p->height = 8;
01430         p->width = 8;
01431         p->endheight = 32;
01432         p->endwidth = 32;
01433         p->type = P_SMOKE;
01434         
01435         VectorCopy(cent->currentState.origin, p->org);
01436 
01437         p->vel[0] = p->vel[1] = 0;
01438         p->accel[0] = p->accel[1] = p->accel[2] = 0;
01439 
01440         p->vel[2] = 5;
01441 
01442         if (cent->currentState.frame == 1)// reverse gravity    
01443                 p->vel[2] *= -1;
01444 
01445         p->roll = 8 + (crandom() * 4);
01446 }

void CG_ParticleSnow qhandle_t  pshader,
vec3_t  origin,
vec3_t  origin2,
int  turb,
float  range,
int  snum
 

Definition at line 1283 of file cg_marks.c.

References active_particles, cg, CG_Printf(), cparticle_t, crandom, free_particles, particle_s::next, P_WEATHER, P_WEATHER_TURBULENT, qhandle_t, qtrue, cg_t::time, particle_s::time, vec3_t, and VectorCopy.

01284 {
01285         cparticle_t     *p;
01286 
01287         if (!pshader)
01288                 CG_Printf ("CG_ParticleSnow pshader == ZERO!\n");
01289 
01290         if (!free_particles)
01291                 return;
01292         p = free_particles;
01293         free_particles = p->next;
01294         p->next = active_particles;
01295         active_particles = p;
01296         p->time = cg.time;
01297         p->color = 0;
01298         p->alpha = 0.40f;
01299         p->alphavel = 0;
01300         p->start = origin[2];
01301         p->end = origin2[2];
01302         p->pshader = pshader;
01303         p->height = 1;
01304         p->width = 1;
01305         
01306         p->vel[2] = -50;
01307 
01308         if (turb)
01309         {
01310                 p->type = P_WEATHER_TURBULENT;
01311                 p->vel[2] = -50 * 1.3;
01312         }
01313         else
01314         {
01315                 p->type = P_WEATHER;
01316         }
01317         
01318         VectorCopy(origin, p->org);
01319 
01320         p->org[0] = p->org[0] + ( crandom() * range);
01321         p->org[1] = p->org[1] + ( crandom() * range);
01322         p->org[2] = p->org[2] + ( crandom() * (p->start - p->end)); 
01323 
01324         p->vel[0] = p->vel[1] = 0;
01325         
01326         p->accel[0] = p->accel[1] = p->accel[2] = 0;
01327 
01328         if (turb)
01329         {
01330                 p->vel[0] = crandom() * 16;
01331                 p->vel[1] = crandom() * 16;
01332         }
01333 
01334         // Rafael snow pvs check
01335         p->snum = snum;
01336         p->link = qtrue;
01337 
01338 }

void CG_ParticleSnowFlurry qhandle_t  pshader,
centity_t cent
 

Definition at line 1215 of file cg_marks.c.

References active_particles, entityState_s::angles, centity_t, cg, CG_Printf(), cparticle_t, crandom, centity_s::currentState, free_particles, particle_s::next, entityState_s::origin, entityState_s::origin2, P_WEATHER_FLURRY, qboolean, qhandle_t, qtrue, rand(), entityState_s::time, cg_t::time, particle_s::time, entityState_s::time2, and VectorCopy.

01216 {
01217         cparticle_t     *p;
01218         qboolean turb = qtrue;
01219 
01220         if (!pshader)
01221                 CG_Printf ("CG_ParticleSnowFlurry pshader == ZERO!\n");
01222 
01223         if (!free_particles)
01224                 return;
01225         p = free_particles;
01226         free_particles = p->next;
01227         p->next = active_particles;
01228         active_particles = p;
01229         p->time = cg.time;
01230         p->color = 0;
01231         p->alpha = 0.90f;
01232         p->alphavel = 0;
01233 
01234         p->start = cent->currentState.origin2[0];
01235         p->end = cent->currentState.origin2[1];
01236         
01237         p->endtime = cg.time + cent->currentState.time;
01238         p->startfade = cg.time + cent->currentState.time2;
01239         
01240         p->pshader = pshader;
01241         
01242         if (rand()%100 > 90)
01243         {
01244                 p->height = 32;
01245                 p->width = 32;
01246                 p->alpha = 0.10f;
01247         }
01248         else
01249         {
01250                 p->height = 1;
01251                 p->width = 1;
01252         }
01253 
01254         p->vel[2] = -20;
01255 
01256         p->type = P_WEATHER_FLURRY;
01257         
01258         if (turb)
01259                 p->vel[2] = -10;
01260         
01261         VectorCopy(cent->currentState.origin, p->org);
01262 
01263         p->org[0] = p->org[0];
01264         p->org[1] = p->org[1];
01265         p->org[2] = p->org[2];
01266 
01267         p->vel[0] = p->vel[1] = 0;
01268         
01269         p->accel[0] = p->accel[1] = p->accel[2] = 0;
01270 
01271         p->vel[0] += cent->currentState.angles[0] * 32 + (crandom() * 16);
01272         p->vel[1] += cent->currentState.angles[1] * 32 + (crandom() * 16);
01273         p->vel[2] += cent->currentState.angles[2];
01274 
01275         if (turb)
01276         {
01277                 p->accel[0] = crandom () * 16;
01278                 p->accel[1] = crandom () * 16;
01279         }
01280 
01281 }

void CG_ParticleSparks vec3_t  org,
vec3_t  vel,
int  duration,
float  x,
float  y,
float  speed
 

Definition at line 2088 of file cg_marks.c.

References active_particles, cg, cparticle_t, crandom, EMISIVEFADE, free_particles, particle_s::next, P_SMOKE, cg_t::time, particle_s::time, vec3_t, and VectorCopy.

02089 {
02090         cparticle_t     *p;
02091 
02092         if (!free_particles)
02093                 return;
02094         p = free_particles;
02095         free_particles = p->next;
02096         p->next = active_particles;
02097         active_particles = p;
02098         p->time = cg.time;
02099         
02100         p->endtime = cg.time + duration;
02101         p->startfade = cg.time + duration/2;
02102         
02103         p->color = EMISIVEFADE;
02104         p->alpha = 0.4f;
02105         p->alphavel = 0;
02106 
02107         p->height = 0.5;
02108         p->width = 0.5;
02109         p->endheight = 0.5;
02110         p->endwidth = 0.5;
02111 
02112         p->pshader = 0;//cgs.media.tracerShader;
02113 
02114         p->type = P_SMOKE;
02115         
02116         VectorCopy(org, p->org);
02117 
02118         p->org[0] += (crandom() * x);
02119         p->org[1] += (crandom() * y);
02120 
02121         p->vel[0] = vel[0];
02122         p->vel[1] = vel[1];
02123         p->vel[2] = vel[2];
02124 
02125         p->accel[0] = p->accel[1] = p->accel[2] = 0;
02126 
02127         p->vel[0] += (crandom() * 4);
02128         p->vel[1] += (crandom() * 4);
02129         p->vel[2] += (20 + (crandom() * 10)) * speed;   
02130 
02131         p->accel[0] = crandom () * 4;
02132         p->accel[1] = crandom () * 4;
02133         
02134 }

void CG_SnowLink centity_t cent,
qboolean  particleOn
 

Definition at line 1629 of file cg_marks.c.

References active_particles, centity_t, cparticle_t, centity_s::currentState, entityState_s::frame, particle_s::link, particle_s::next, P_WEATHER, P_WEATHER_TURBULENT, qfalse, qtrue, particle_s::snum, and particle_s::type.

01630 {
01631         cparticle_t             *p, *next;
01632         int id;
01633 
01634         id = cent->currentState.frame;
01635 
01636         for (p=active_particles ; p ; p=next)
01637         {
01638                 next = p->next;
01639                 
01640                 if (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT)
01641                 {
01642                         if (p->snum == id)
01643                         {
01644                                 if (particleOn)
01645                                         p->link = qtrue;
01646                                 else
01647                                         p->link = qfalse;
01648                         }
01649                 }
01650 
01651         }
01652 }

qboolean ValidBloodPool vec3_t  start  ) 
 

Definition at line 1902 of file cg_marks.c.

References AngleVectors(), CG_Trace(), CONTENTS_SOLID, trace_t::entityNum, ENTITYNUM_WORLD, EXTRUDE_DIST, trace_t::fraction, NULL, qboolean, qfalse, qtrue, trace_t::startsolid, vec3_t, vectoangles(), VectorMA, and VectorSet.

Referenced by CG_BloodPool().

01903 {
01904 #define EXTRUDE_DIST    0.5
01905 
01906         vec3_t  angles;
01907         vec3_t  right, up;
01908         vec3_t  this_pos, x_pos, center_pos, end_pos;
01909         float   x, y;
01910         float   fwidth, fheight;
01911         trace_t trace;
01912         vec3_t  normal;
01913 
01914         fwidth = 16;
01915         fheight = 16;
01916 
01917         VectorSet (normal, 0, 0, 1);
01918 
01919         vectoangles (normal, angles);
01920         AngleVectors (angles, NULL, right, up);
01921 
01922         VectorMA (start, EXTRUDE_DIST, normal, center_pos);
01923 
01924         for (x= -fwidth/2; x<fwidth; x+= fwidth)
01925         {
01926                 VectorMA (center_pos, x, right, x_pos);
01927 
01928                 for (y= -fheight/2; y<fheight; y+= fheight)
01929                 {
01930                         VectorMA (x_pos, y, up, this_pos);
01931                         VectorMA (this_pos, -EXTRUDE_DIST*2, normal, end_pos);
01932                         
01933                         CG_Trace (&trace, this_pos, NULL, NULL, end_pos, -1, CONTENTS_SOLID);
01934 
01935                         
01936                         if (trace.entityNum != ENTITYNUM_WORLD ) // may only land on world
01937                                 return qfalse;
01938 
01939                         if (!(!trace.startsolid && trace.fraction < 1))
01940                                 return qfalse;
01941                 
01942                 }
01943         }
01944 
01945         return qtrue;
01946 }


Variable Documentation

cparticle_t* active_particles
 

Definition at line 380 of file cg_marks.c.

Referenced by CG_AddParticles(), CG_BloodPool(), CG_ClearParticles(), CG_OilSlickRemove(), CG_Particle_Bleed(), CG_Particle_OilParticle(), CG_Particle_OilSlick(), CG_ParticleBloodCloud(), CG_ParticleBubble(), CG_ParticleBulletDebris(), CG_ParticleDust(), CG_ParticleExplosion(), CG_ParticleImpactSmokePuff(), CG_ParticleMisc(), CG_ParticleSmoke(), CG_ParticleSnow(), CG_ParticleSnowFlurry(), CG_ParticleSparks(), and CG_SnowLink().

markPoly_t cg_activeMarkPolys
 

Definition at line 16 of file cg_marks.c.

Referenced by CG_AddMarks(), CG_AllocMark(), and CG_InitMarkPolys().

markPoly_t* cg_freeMarkPolys
 

Definition at line 17 of file cg_marks.c.

Referenced by CG_AllocMark(), CG_FreeMarkPoly(), and CG_InitMarkPolys().

markPoly_t cg_markPolys[MAX_MARK_POLYS]
 

Definition at line 18 of file cg_marks.c.

Referenced by CG_InitMarkPolys().

int cl_numparticles = MAX_PARTICLES
 

Definition at line 382 of file cg_marks.c.

Referenced by CG_ClearParticles().

cparticle_t * free_particles
 

Definition at line 380 of file cg_marks.c.

Referenced by CG_AddParticles(), CG_BloodPool(), CG_ClearParticles(), CG_Particle_Bleed(), CG_Particle_OilParticle(), CG_Particle_OilSlick(), CG_ParticleBloodCloud(), CG_ParticleBubble(), CG_ParticleBulletDebris(), CG_ParticleDust(), CG_ParticleExplosion(), CG_ParticleImpactSmokePuff(), CG_ParticleMisc(), CG_ParticleSmoke(), CG_ParticleSnow(), CG_ParticleSnowFlurry(), and CG_ParticleSparks().

qboolean initparticles = qfalse
 

Definition at line 384 of file cg_marks.c.

Referenced by CG_AddParticles(), and CG_ClearParticles().

float oldtime
 

Definition at line 388 of file cg_marks.c.

Referenced by CG_AddParticles(), and CG_ClearParticles().

cparticle_t particles[MAX_PARTICLES]
 

Definition at line 381 of file cg_marks.c.

Referenced by CG_ClearParticles().

vec3_t pvforward
 

Definition at line 385 of file cg_marks.c.

Referenced by CG_AddParticles().

vec3_t pvright
 

Definition at line 385 of file cg_marks.c.

Referenced by CG_AddParticles(), and CG_AddParticleToScene().

vec3_t pvup
 

Definition at line 385 of file cg_marks.c.

Referenced by CG_AddParticles(), and CG_AddParticleToScene().

vec3_t rforward
 

Definition at line 386 of file cg_marks.c.

Referenced by CG_AddParticles(), and CG_AddParticleToScene().

vec3_t rright
 

Definition at line 386 of file cg_marks.c.

Referenced by CG_AddParticles(), and CG_AddParticleToScene().

vec3_t rup
 

Definition at line 386 of file cg_marks.c.

Referenced by CG_AddParticles(), and CG_AddParticleToScene().