avdl_particle_system.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef AVDL_PARTICLE_SYSTEM_H
  2. #define AVDL_PARTICLE_SYSTEM_H
  3. #include "dd_mesh.h"
  4. #include "dd_vec4.h"
  5. #include "dd_vec3.h"
  6. /*
  7. * the maximum number of particles that can
  8. * be active at a time
  9. */
  10. #define PARTICLES_TOTAL 10
  11. /*
  12. * each individual particle's data
  13. */
  14. struct avdl_particle {
  15. // particles location and mesh
  16. struct dd_matrix matrix;
  17. struct dd_mesh *mesh;
  18. // current speed of particle
  19. struct dd_vec3 speed;
  20. // current life of particle
  21. float life;
  22. };
  23. /*
  24. * particle system that spawns particles every
  25. * so often.
  26. */
  27. struct avdl_particle_system {
  28. // active particles
  29. struct avdl_particle particles[PARTICLES_TOTAL];
  30. int particlesCount;
  31. int particlesStart;
  32. // how often particles appear
  33. float delayMax;
  34. float delayCurrent;
  35. // values to be given to each new particle
  36. struct dd_mesh *particleMesh;
  37. float particleLife;
  38. struct dd_vec3 particleSpeed;
  39. void (*clean)(struct avdl_particle_system *);
  40. void (*update)(struct avdl_particle_system *);
  41. void (*draw)(struct avdl_particle_system *);
  42. void (*assignAsset)(struct avdl_particle_system *, struct dd_mesh *);
  43. void (*setDelay)(struct avdl_particle_system *, float);
  44. void (*setParticleLife)(struct avdl_particle_system *, float);
  45. void (*setParticleSpeed)(struct avdl_particle_system *, float, float, float);
  46. };
  47. void avdl_particle_system_create(struct avdl_particle_system *);
  48. void avdl_particle_system_clean(struct avdl_particle_system *);
  49. void avdl_particle_system_assignAsset(struct avdl_particle_system *, struct dd_mesh *);
  50. void avdl_particle_system_update(struct avdl_particle_system *);
  51. void avdl_particle_system_draw(struct avdl_particle_system *);
  52. void avdl_particle_system_setDelay(struct avdl_particle_system *, float newDelay);
  53. void avdl_particle_system_setParticleLife(struct avdl_particle_system *, float pLife);
  54. void avdl_particle_system_setParticleSpeed(struct avdl_particle_system *, float x, float y, float z);
  55. #endif