1
0

71 lines
1.1 KiB
C
Raw Normal View History

2019-12-16 19:22:52 +01:00
/*
* A vector with three floats
*/
2019-12-17 22:29:36 +01:00
typedef struct vector3f
2019-12-16 19:22:52 +01:00
{
float x;
float y;
float z;
2019-12-17 22:29:36 +01:00
} vector3f;
2019-12-16 19:22:52 +01:00
/*
* A particle has a position and a direction
*/
2019-12-17 22:29:36 +01:00
typedef struct particle
2019-12-16 19:22:52 +01:00
{
2019-12-17 22:29:36 +01:00
vector3f *position;
vector3f *direction;
} particle;
2019-12-16 19:22:52 +01:00
/*
* An emitter has a position and contains an array of particles
*/
2019-12-17 22:29:36 +01:00
typedef struct emitter
2019-12-16 19:22:52 +01:00
{
2019-12-17 22:29:36 +01:00
vector3f *position;
particle **particles;
2019-12-16 19:22:52 +01:00
int pamount;
2019-12-17 22:29:36 +01:00
} emitter;
2019-12-16 19:22:52 +01:00
/*
* A particle system consists of one or more emitter
*/
2019-12-17 22:29:36 +01:00
typedef struct particle_system
2019-12-16 19:22:52 +01:00
{
2019-12-17 22:29:36 +01:00
emitter **emitters;
2019-12-16 19:22:52 +01:00
int eamount;
2019-12-17 22:29:36 +01:00
} particle_system;
2019-12-16 19:22:52 +01:00
/*
2019-12-17 22:29:36 +01:00
* Initializes a particle
2019-12-16 19:22:52 +01:00
*/
2019-12-17 22:29:36 +01:00
particle *initParticle(vector3f *pos, vector3f *dir);
2019-12-16 19:22:52 +01:00
/*
2019-12-17 22:29:36 +01:00
* Initializes an emitter
2019-12-16 19:22:52 +01:00
*/
2019-12-17 22:29:36 +01:00
emitter *initEmitter(vector3f *pos, int pamount);
/*
* Initializes a particle system
*/
particle_system *initParticleSystem(int eamount);
/*
* Updates particle
*/
int updateParticles(float dt, particle_system *particleSystem);
/*
* Updates particle
*/
int drawParticles(particle_system *particleSystem);
/*
* Initializes a vector
* For that it allocates memory that must be freed later
*/
vector3f *initVector3f(float x, float y, float z);
2019-12-16 19:22:52 +01:00