]> git.xonotic.org Git - xonotic/darkplaces.git/blob - cl_particles.h
client: Add cl_particles.h and move cl_particles definitions to it.
[xonotic/darkplaces.git] / cl_particles.h
1 #ifndef CL_PARTICLES_H
2 #define CL_PARTICLES_H
3
4 #include "qtypes.h"
5 #include "cvar.h"
6 typedef struct entity_s entity_t;
7
8 extern cvar_t cl_particles;
9 extern cvar_t cl_particles_quality;
10 extern cvar_t cl_particles_size;
11 extern cvar_t cl_particles_quake;
12 extern cvar_t cl_particles_blood;
13 extern cvar_t cl_particles_blood_alpha;
14 extern cvar_t cl_particles_blood_decal_alpha;
15 extern cvar_t cl_particles_blood_decal_scalemin;
16 extern cvar_t cl_particles_blood_decal_scalemax;
17 extern cvar_t cl_particles_blood_bloodhack;
18 extern cvar_t cl_particles_bulletimpacts;
19 extern cvar_t cl_particles_explosions_sparks;
20 extern cvar_t cl_particles_explosions_shell;
21 extern cvar_t cl_particles_rain;
22 extern cvar_t cl_particles_snow;
23 extern cvar_t cl_particles_smoke;
24 extern cvar_t cl_particles_smoke_alpha;
25 extern cvar_t cl_particles_smoke_alphafade;
26 extern cvar_t cl_particles_sparks;
27 extern cvar_t cl_particles_bubbles;
28 extern cvar_t cl_decals;
29 extern cvar_t cl_decals_time;
30 extern cvar_t cl_decals_fadetime;
31
32 typedef enum
33 {
34         PARTICLE_BILLBOARD = 0,
35         PARTICLE_SPARK = 1,
36         PARTICLE_ORIENTED_DOUBLESIDED = 2,
37         PARTICLE_VBEAM = 3,
38         PARTICLE_HBEAM = 4,
39         PARTICLE_INVALID = -1
40 }
41 porientation_t;
42
43 typedef enum
44 {
45         PBLEND_ALPHA = 0,
46         PBLEND_ADD = 1,
47         PBLEND_INVMOD = 2,
48         PBLEND_INVALID = -1
49 }
50 pblend_t;
51
52 typedef struct particletype_s
53 {
54         pblend_t blendmode;
55         porientation_t orientation;
56         qbool lighting;
57 }
58 particletype_t;
59
60 typedef enum ptype_e
61 {
62         pt_dead, pt_alphastatic, pt_static, pt_spark, pt_beam, pt_rain, pt_raindecal, pt_snow, pt_bubble, pt_blood, pt_smoke, pt_decal, pt_entityparticle, pt_total
63 }
64 ptype_t;
65
66 typedef struct particle_s
67 {
68         // for faster batch rendering, particles are rendered in groups by effect (resulting in less perfect sorting but far less state changes)
69
70         // fields used by rendering: (48 bytes)
71         vec3_t          sortorigin; // sort by this group origin, not particle org
72         vec3_t          org;
73         vec3_t          vel; // velocity of particle, or orientation of decal, or end point of beam
74         float           size;
75         float           alpha; // 0-255
76         float           stretch; // only for sparks
77
78         // fields not used by rendering:  (44 bytes)
79         float           stainsize;
80         float           stainalpha;
81         float           sizeincrease; // rate of size change per second
82         float           alphafade; // how much alpha reduces per second
83         float           time2; // used for snow fluttering and decal fade
84         float           bounce; // how much bounce-back from a surface the particle hits (0 = no physics, 1 = stop and slide, 2 = keep bouncing forever, 1.5 is typical)
85         float           gravity; // how much gravity affects this particle (1.0 = normal gravity, 0.0 = none)
86         float           airfriction; // how much air friction affects this object (objects with a low mass/size ratio tend to get more air friction)
87         float           liquidfriction; // how much liquid friction affects this object (objects with a low mass/size ratio tend to get more liquid friction)
88 //      float           delayedcollisions; // time that p->bounce becomes active
89         float           delayedspawn; // time that particle appears and begins moving
90         float           die; // time when this particle should be removed, regardless of alpha
91
92         // short variables grouped to save memory (4 bytes)
93         short                   angle; // base rotation of particle
94         short                   spin; // geometry rotation speed around the particle center normal
95
96         // byte variables grouped to save memory (12 bytes)
97         unsigned char   color[3];
98         unsigned char   qualityreduction; // enables skipping of this particle according to r_refdef.view.qualityreduction
99         unsigned char   typeindex;
100         unsigned char   blendmode;
101         unsigned char   orientation;
102         unsigned char   texnum;
103         unsigned char   staincolor[3];
104         signed char     staintexnum;
105 }
106 particle_t;
107
108 void CL_Particles_Clear(void);
109 void CL_Particles_Init(void);
110 void CL_Particles_Shutdown(void);
111 particle_t *CL_NewParticle(const vec3_t sortorigin, unsigned short ptypeindex, int pcolor1, int pcolor2, int ptex, float psize, float psizeincrease, float palpha, float palphafade, float pgravity, float pbounce, float px, float py, float pz, float pvx, float pvy, float pvz, float pairfriction, float pliquidfriction, float originjitter, float velocityjitter, qbool pqualityreduction, float lifetime, float stretch, pblend_t blendmode, porientation_t orientation, int staincolor1, int staincolor2, int staintex, float stainalpha, float stainsize, float angle, float spin, float tint[4]);
112
113 typedef enum effectnameindex_s
114 {
115         EFFECT_NONE,
116         EFFECT_TE_GUNSHOT,
117         EFFECT_TE_GUNSHOTQUAD,
118         EFFECT_TE_SPIKE,
119         EFFECT_TE_SPIKEQUAD,
120         EFFECT_TE_SUPERSPIKE,
121         EFFECT_TE_SUPERSPIKEQUAD,
122         EFFECT_TE_WIZSPIKE,
123         EFFECT_TE_KNIGHTSPIKE,
124         EFFECT_TE_EXPLOSION,
125         EFFECT_TE_EXPLOSIONQUAD,
126         EFFECT_TE_TAREXPLOSION,
127         EFFECT_TE_TELEPORT,
128         EFFECT_TE_LAVASPLASH,
129         EFFECT_TE_SMALLFLASH,
130         EFFECT_TE_FLAMEJET,
131         EFFECT_EF_FLAME,
132         EFFECT_TE_BLOOD,
133         EFFECT_TE_SPARK,
134         EFFECT_TE_PLASMABURN,
135         EFFECT_TE_TEI_G3,
136         EFFECT_TE_TEI_SMOKE,
137         EFFECT_TE_TEI_BIGEXPLOSION,
138         EFFECT_TE_TEI_PLASMAHIT,
139         EFFECT_EF_STARDUST,
140         EFFECT_TR_ROCKET,
141         EFFECT_TR_GRENADE,
142         EFFECT_TR_BLOOD,
143         EFFECT_TR_WIZSPIKE,
144         EFFECT_TR_SLIGHTBLOOD,
145         EFFECT_TR_KNIGHTSPIKE,
146         EFFECT_TR_VORESPIKE,
147         EFFECT_TR_NEHAHRASMOKE,
148         EFFECT_TR_NEXUIZPLASMA,
149         EFFECT_TR_GLOWTRAIL,
150         EFFECT_SVC_PARTICLE,
151         EFFECT_TOTAL
152 }
153 effectnameindex_t;
154
155 int CL_ParticleEffectIndexForName(const char *name);
156 const char *CL_ParticleEffectNameForIndex(int i);
157 void CL_ParticleEffect(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor);
158 void CL_ParticleTrail(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor, qbool spawndlight, qbool spawnparticles, float tintmins[4], float tintmaxs[4], float fade);
159 void CL_ParticleBox(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor, qbool spawndlight, qbool spawnparticles, float tintmins[4], float tintmaxs[4], float fade);
160 void CL_ParseParticleEffect (void);
161 void CL_ParticleCube (const vec3_t mins, const vec3_t maxs, const vec3_t dir, int count, int colorbase, vec_t gravity, vec_t randomvel);
162 void CL_ParticleRain (const vec3_t mins, const vec3_t maxs, const vec3_t dir, int count, int colorbase, int type);
163 void CL_EntityParticles (const entity_t *ent);
164 void CL_ParticleExplosion (const vec3_t org);
165 void CL_ParticleExplosion2 (const vec3_t org, int colorStart, int colorLength);
166
167 #endif