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"
|
2024-01-01 17:30:42 -06:00
|
|
|
#include "anim.h"
|
2022-12-28 16:50:54 -06:00
|
|
|
|
2023-12-29 19:08:53 -06:00
|
|
|
typedef struct particle {
|
2024-01-03 12:29:27 -06:00
|
|
|
HMM_Vec4 pos;
|
|
|
|
HMM_Vec4 v; /* velocity */
|
2023-12-29 19:08:53 -06:00
|
|
|
float angle;
|
|
|
|
float av; /* angular velocity */
|
|
|
|
float scale;
|
|
|
|
double life;
|
2024-01-01 17:30:42 -06:00
|
|
|
HMM_Vec4 color;
|
2023-12-29 19:08:53 -06:00
|
|
|
} 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 */
|
2024-01-01 17:30:42 -06:00
|
|
|
sampler color; /* color over particle lifetime */
|
2023-12-29 19:08:53 -06:00
|
|
|
float scale;
|
2024-01-01 17:30:42 -06:00
|
|
|
float speed;
|
|
|
|
int gravity; /* true if affected by gravity */
|
2023-12-29 19:08:53 -06:00
|
|
|
texture *texture;
|
2024-01-01 17:30:42 -06:00
|
|
|
int on;
|
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
|