summaryrefslogtreecommitdiff
path: root/src/cgame/cg_local.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgame/cg_local.h')
-rw-r--r--src/cgame/cg_local.h239
1 files changed, 238 insertions, 1 deletions
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index 941c3d31..281d732b 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -948,6 +948,8 @@ typedef struct
sfxHandle_t buildableRepairSound;
sfxHandle_t buildableRepairedSound;
+
+ qhandle_t testParticleSystem;
} cgMedia_t;
@@ -1008,7 +1010,7 @@ typedef struct
qhandle_t gameModels[ MAX_MODELS ];
qhandle_t gameShaders[ MAX_SHADERS ];
sfxHandle_t gameSounds[ MAX_SOUNDS ];
-
+
int numInlineModels;
qhandle_t inlineDrawModel[ MAX_MODELS ];
vec3_t inlineModelMidpoints[ MAX_MODELS ];
@@ -1462,6 +1464,241 @@ void CG_DefragmentMemory( void );
//
qboolean S_decodeMP3( char *mp3File, char *wavFile );
+//
+// cg_particles.c
+//
+
+#define MAX_SHADER_FRAMES 64
+#define MAX_EJECTORS_PER_SYSTEM 4
+#define MAX_PARTICLES_PER_EJECTOR 4
+
+#define MAX_BASEPARTICLE_SYSTEMS 512
+#define MAX_BASEPARTICLE_EJECTORS MAX_BASEPARTICLE_SYSTEMS*MAX_EJECTORS_PER_SYSTEM
+#define MAX_BASEPARTICLES MAX_BASEPARTICLE_EJECTORS*MAX_PARTICLES_PER_EJECTOR
+
+#define MAX_PARTICLE_SYSTEMS 16
+#define MAX_PARTICLE_EJECTORS MAX_PARTICLE_SYSTEMS*MAX_EJECTORS_PER_SYSTEM
+#define MAX_PARTICLES MAX_PARTICLE_EJECTORS*8
+
+#define PARTICLES_INFINITE -1
+#define PARTICLES_SAME_AS_INITIAL -2
+
+/*
+===============
+
+COMPILE TIME STRUCTURES
+
+===============
+*/
+
+typedef enum
+{
+ PMT_STATIC,
+ PMT_TAG,
+ PMT_CENT_ANGLES
+} pMoveType_t;
+
+typedef enum
+{
+ PMD_LINEAR,
+ PMD_POINT
+} pDirType_t;
+
+typedef struct pMoveValues_u
+{
+ pDirType_t dirType;
+
+ //PMD_LINEAR
+ vec3_t dir;
+ float dirRandAngle;
+
+ //PMD_POINT
+ vec3_t point;
+ float pointRandAngle;
+
+ float mag;
+ float magRandFrac;
+
+ float parentVelFrac;
+ float parentVelFracRandFrac;
+} pMoveValues_t;
+
+typedef struct pLerpValues_s
+{
+ int delay;
+ float delayRandFrac;
+
+ float initial;
+ float initialRandFrac;
+
+ float final;
+ float finalRandFrac;
+
+ float randFrac;
+} pLerpValues_t;
+
+//particle template
+typedef struct baseParticle_s
+{
+ float randDisplacement;
+
+ pMoveType_t velMoveType;
+ pMoveValues_t velMoveValues;
+
+ pMoveType_t accMoveType;
+ pMoveValues_t accMoveValues;
+
+ int lifeTime;
+ float lifeTimeRandFrac;
+
+ float bounceFrac;
+ float bounceFracRandFrac;
+
+ pLerpValues_t radius;
+ pLerpValues_t alpha;
+ pLerpValues_t rotation;
+
+ //particle invariant stuff
+ char shaderNames[ MAX_QPATH ][ MAX_SHADER_FRAMES ];
+ qhandle_t shaders[ MAX_SHADER_FRAMES ];
+ int numFrames;
+ float framerate;
+
+ qboolean overdrawProtection;
+ qboolean realLight;
+} baseParticle_t;
+
+
+//ejector template
+typedef struct baseParticleEjector_s
+{
+ baseParticle_t *particles[ MAX_PARTICLES_PER_EJECTOR ];
+ int numParticles;
+
+ pLerpValues_t eject; //zero period indicates creation of all particles at once
+
+ int totalParticles; //can be infinite
+ float totalParticlesRandFrac;
+} baseParticleEjector_t;
+
+
+//particle system template
+typedef struct baseParticleSystem_s
+{
+ char name[ MAX_QPATH ];
+ baseParticleEjector_t *ejectors[ MAX_EJECTORS_PER_SYSTEM ];
+ int numEjectors;
+
+ qboolean registered; //whether or not the assets for this particle have been loaded
+} baseParticleSystem_t;
+
+
+/*
+===============
+
+RUN TIME STRUCTURES
+
+===============
+*/
+
+typedef enum
+{
+ PSA_STATIC,
+ PSA_TAG,
+ PSA_CENT_ORIGIN
+} psAttachmentType_t;
+
+
+typedef struct psAttachment_s
+{
+ qboolean staticValid;
+ qboolean tagValid;
+ qboolean centValid;
+
+ //PMT_STATIC
+ vec3_t origin;
+
+ //PMT_TAG
+ refEntity_t re;
+ refEntity_t parent;
+ qhandle_t model;
+ char tagName[ MAX_STRING_CHARS ];
+
+ //PMT_CENT_ANGLES
+ centity_t *cent;
+} psAttachment_t;
+
+
+typedef struct particleSystem_s
+{
+ baseParticleSystem_t *class;
+
+ psAttachmentType_t attachType;
+ psAttachment_t attachment;
+ qboolean attached; //is the particle system attached to anything
+
+ qboolean enabled; //necessary?
+
+ qboolean valid;
+} particleSystem_t;
+
+
+typedef struct particleEjector_s
+{
+ baseParticleEjector_t *class;
+ particleSystem_t *parent;
+
+ pLerpValues_t ejectPeriod;
+
+ int count;
+ int totalParticles;
+
+ int nextEjectionTime;
+
+ qboolean valid;
+} particleEjector_t;
+
+
+//used for actual particle evaluation
+typedef struct particle_s
+{
+ baseParticle_t *class;
+ particleEjector_t *parent;
+
+ int birthTime;
+ int lifeTime;
+
+ vec3_t origin;
+ vec3_t velocity;
+
+ pMoveType_t accMoveType;
+ pMoveValues_t accMoveValues;
+
+ int lastEvalTime;
+
+ pLerpValues_t radius;
+ pLerpValues_t alpha;
+ pLerpValues_t rotation;
+
+ qboolean valid;
+} particle_t;
+
+void CG_LoadParticleSystems( void );
+qhandle_t CG_RegisterParticleSystem( char *name );
+
+particleSystem_t *CG_SpawnNewParticleSystem( qhandle_t psHandle );
+void CG_DestroyParticleSystem( particleSystem_t *ps );
+
+void CG_SetParticleSystemCent( particleSystem_t *ps, centity_t *cent );
+void CG_AttachParticleSystemToCent( particleSystem_t *ps );
+void CG_SetParticleSystemTag( particleSystem_t *ps, refEntity_t parent, qhandle_t model, char *tagName );
+void CG_AttachParticleSystemToTag( particleSystem_t *ps );
+void CG_SetParticleSystemOrigin( particleSystem_t *ps, vec3_t origin );
+void CG_AttachParticleSystemOrigin( particleSystem_t *ps );
+
+void CG_AddParticles( void );
+
+
//===============================================
//