prosperon/source/engine/particle.h

67 lines
1.7 KiB
C
Raw Normal View History

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"
2024-01-04 08:14:37 -06:00
#include "warp.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;
2024-01-04 09:46:28 -06:00
double time;
2023-12-29 19:08:53 -06:00
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 */
2024-01-04 09:46:28 -06:00
double life_var;
2024-01-04 08:14:37 -06:00
/* PARTICLE GEN */
float speed; /* initial speed of particle */
float variation; /* variation on speed */
float divergence; /* angular degree of variation from emitter normal, up to 1 */
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-04 08:14:37 -06:00
float scale_var;
float grow_for; /* seconds to grow from small until scale */
2024-01-04 09:46:28 -06:00
float shrink_for; /* seconds to shrink to small prior to its death */
2024-01-04 08:14:37 -06:00
/* PARTICLE TYPE */
2023-12-29 19:08:53 -06:00
texture *texture;
2024-01-04 08:14:37 -06:00
/* ROTATION AND COLLISION */
int collision_mask; /* mask for collision */
float bounce; /* bounce back after collision */
/* PARTICLE SPAWN */
int die_after_collision;
float persist; /* how long to linger after death */
float persist_var;
/* TRAILS */
warpmask warp_mask;
2024-01-01 17:30:42 -06:00
int on;
2024-01-04 08:14:37 -06:00
double tte; /* time to emit */
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