From 6b8af9cf83851c075c6c9514b1deaa931c2b19a4 Mon Sep 17 00:00:00 2001 From: Thomas Guillermo Albers Raviola Date: Fri, 16 Jan 2026 23:02:32 +0100 Subject: Initial commit --- 09-september/tomcat/particles/particles.h | 62 +++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 09-september/tomcat/particles/particles.h (limited to '09-september/tomcat/particles/particles.h') diff --git a/09-september/tomcat/particles/particles.h b/09-september/tomcat/particles/particles.h new file mode 100644 index 0000000..8404ff4 --- /dev/null +++ b/09-september/tomcat/particles/particles.h @@ -0,0 +1,62 @@ +#ifndef PARTICLES_H +#define PARTICLES_H + +#include "../renderer/renderer_types.h" +#include "../math/vector.h" + +#define MAX_PARTICLES_PER_SYSTEM 10000 +#define MAX_PARTICLES_SYSTEMS 10 + +typedef struct _Particle +{ + Vec3 position; + Vec3 velocity; + + Vec2 tex_offset; /* Used for animating */ + + GLfloat weight; /* How does the gravity affect the particle (In theory it should be a vector)*/ + GLfloat life_length; + GLfloat rotation; + GLfloat scale; + GLfloat distance_to_camera; /* Used for sorting the systems */ + + GLfloat elapsed_time; +} Particle; + +typedef struct _ParticleSystem +{ + Vec3 position; + + GLint emit_rate; + GLfloat speed; + GLfloat weight; + GLfloat life_length; + + bool additive; /* Additive vs alpha blending */ + + Texture *texture; + Particle particles[MAX_PARTICLES_PER_SYSTEM]; + int num_particles; + +} ParticleSystem; + +typedef struct +{ + ParticleSystem *systems[MAX_PARTICLES_SYSTEMS]; + int num_systems; +} ParticleManager; + +extern ParticleManager particles; + +extern void Particles_Init(); + +extern ParticleSystem *Particles_AddSystem(); +extern void Particles_RemoveSystem(ParticleSystem *system); +/* Used for manual emission */ +extern void Particles_EmitParticle(ParticleSystem *system, Particle *p); +/* Removes a particle if it "dies" */ +extern void Particles_Update(const Vec3 *camera_position); +/* We need to delete all dynamically allocated particles that still remains */ +extern void Particles_Shutdown(); + +#endif // PARTICLES_H -- cgit v1.2.3