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