aboutsummaryrefslogtreecommitdiff
path: root/09-september/tomcat/particles/particles.h
diff options
context:
space:
mode:
Diffstat (limited to '09-september/tomcat/particles/particles.h')
-rw-r--r--09-september/tomcat/particles/particles.h62
1 files changed, 62 insertions, 0 deletions
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