-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxparticle.h
89 lines (73 loc) · 2.2 KB
/
xparticle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* This file belongs to the 'xlab' game engine.
* Copyright 2009 xfacter
* Copyright 2016 wickles
* This work is licensed under the LGPLv3
* subject to all terms as reproduced in the included LICENSE file.
*/
#pragma once
#include "xconfig.h"
#ifdef __cplusplus
extern "C" {
#endif
#define X_PARTICLE_SPRITES (0)
#define X_PARTICLE_LINE_SPRITES (1)
#define X_PARTICLE_LINES (2)
#define X_PARTICLE_POINTS (3)
/* TODO:
- particle trails
- rotation
- radial movement -- theta, r, omega, alpha -- rotates about axis using a rotation/position matrix
*/
typedef struct xParticle {
xVector3f pos;
xVector3f vel;
float size_rand;
float age;
float inv_life;
} xParticle;
typedef struct xParticleSystem xParticleSystem;
typedef void (*xParticleRender)(xParticleSystem* s, xParticle* p, ScePspFMatrix4* view);
//not fully implemented yet
typedef struct xParticleEmitter {
xVector3f particle_pos;
xVector3f particle_vel;
xVector3f emitter_pos;
xVector3f emitter_vel;
float age;
float inv_life;
int new_velocity;
} xParticleEmitter;
struct xParticleSystem {
xVector3f pos;
xVector3f pos_rand;
xVector3f vel;
xVector3f vel_rand;
xVector3f accel;
//xVector3f emitter_accel;
xColor4f colors[8]; // colors - interpolates between num_cols colors during its life
u16 num_cols;
float sizes[8]; //sizes to interpolate between during the life of the particle
u16 num_sizes;
float size_rand; //size variance
float life; // life between lifemax-life_rand and lifemax+life_rand
float life_rand;
float friction; //air friction
u16 rate; // particles emitted per second
int prim; // see above. sprite, line sprite, line, or point
//internal variables - do not edit
float time;
u16 num_particles;
u16 max_particles;
xParticle* particles;
u16* particle_stack;
xParticleRender render;
};
xParticleSystem* xParticleSystemConstruct(u16 max);
void xParticleSystemDestroy(xParticleSystem* s);
void xParticleSystemBurst(xParticleSystem* s, xParticleEmitter* e, int num);
void xParticleSystemUpdate(xParticleSystem* s, float dt);
void xParticleSystemRender(xParticleSystem* s, ScePspFMatrix4* view);
#ifdef __cplusplus
}
#endif