2022-12-28 16:50:54 -06:00
|
|
|
#ifndef PARTICLE_H
|
|
|
|
#define PARTICLE_H
|
|
|
|
|
2023-11-28 17:17:40 -06:00
|
|
|
#include "HandmadeMath.h"
|
2023-12-04 13:38:37 -06:00
|
|
|
#include "transform.h"
|
2023-12-29 19:08:53 -06:00
|
|
|
#include "texture.h"
|
2022-12-28 16:50:54 -06:00
|
|
|
|
2023-12-29 19:08:53 -06:00
|
|
|
typedef struct particle {
|
2023-11-28 17:17:40 -06:00
|
|
|
HMM_Vec3 pos;
|
|
|
|
HMM_Vec3 v; /* velocity */
|
2023-12-29 19:08:53 -06:00
|
|
|
float angle;
|
|
|
|
float av; /* angular velocity */
|
|
|
|
float scale;
|
|
|
|
double life;
|
|
|
|
rgba color;
|
|
|
|
} particle;
|
2022-12-28 16:50:54 -06:00
|
|
|
|
2023-12-04 13:38:37 -06:00
|
|
|
typedef struct emitter {
|
2023-11-28 17:17:40 -06:00
|
|
|
struct particle *particles;
|
2023-12-04 13:38:37 -06:00
|
|
|
transform3d t;
|
2023-12-29 19:08:53 -06:00
|
|
|
float explosiveness; /* 0 for a stream, 1 for all at once. Range of values allowed. */
|
|
|
|
int max; /* number of particles */
|
|
|
|
double life; /* how long a particle lasts */
|
|
|
|
double tte; /* time to emit */
|
|
|
|
rgba color;
|
|
|
|
float scale;
|
|
|
|
texture *texture;
|
2023-12-04 13:38:37 -06:00
|
|
|
} emitter;
|
2022-12-28 16:50:54 -06:00
|
|
|
|
2023-12-29 19:08:53 -06:00
|
|
|
void particle_init();
|
|
|
|
|
|
|
|
emitter *make_emitter();
|
|
|
|
void free_emitter(emitter *e);
|
2022-12-28 16:50:54 -06:00
|
|
|
|
2023-12-29 19:08:53 -06:00
|
|
|
void start_emitter(emitter *e);
|
|
|
|
void pause_emitter(emitter *e);
|
|
|
|
void stop_emitter(emitter *e);
|
2022-12-28 16:50:54 -06:00
|
|
|
|
2023-12-29 19:08:53 -06:00
|
|
|
void emitter_emit(emitter *e, int count);
|
|
|
|
void emitters_step(double dt);
|
|
|
|
void emitters_draw();
|
|
|
|
void emitter_step(emitter *e, double dt);
|
2022-12-28 16:50:54 -06:00
|
|
|
|
2023-11-28 17:17:40 -06:00
|
|
|
#endif
|