rev |
line source |
nuclear@67
|
1 #ifndef LIBPSYS_H_
|
nuclear@67
|
2 #define LIBPSYS_H_
|
nuclear@67
|
3
|
nuclear@67
|
4 #include <vmath/vmath.h>
|
nuclear@67
|
5 #include <anim/anim.h>
|
nuclear@67
|
6 #include "rndval.h"
|
nuclear@67
|
7 #include "pattr.h"
|
nuclear@67
|
8
|
nuclear@67
|
9 struct psys_particle;
|
nuclear@67
|
10 struct psys_emitter;
|
nuclear@67
|
11
|
nuclear@67
|
12 typedef int (*psys_spawn_func_t)(struct psys_emitter*, struct psys_particle*, void*);
|
nuclear@67
|
13 typedef void (*psys_update_func_t)(struct psys_emitter*, struct psys_particle*, float, float, void*);
|
nuclear@67
|
14
|
nuclear@67
|
15 typedef void (*psys_draw_func_t)(struct psys_emitter*, struct psys_particle*, void*);
|
nuclear@67
|
16 typedef void (*psys_draw_start_func_t)(struct psys_emitter*, void*);
|
nuclear@67
|
17 typedef void (*psys_draw_end_func_t)(struct psys_emitter*, void*);
|
nuclear@67
|
18
|
nuclear@67
|
19
|
nuclear@67
|
20 struct psys_plane {
|
nuclear@67
|
21 plane_t p;
|
nuclear@67
|
22 float elasticity;
|
nuclear@67
|
23 struct psys_plane *next;
|
nuclear@67
|
24 };
|
nuclear@67
|
25
|
nuclear@67
|
26
|
nuclear@67
|
27 struct psys_emitter {
|
nuclear@67
|
28 struct anm_node prs;
|
nuclear@67
|
29 vec3_t cur_pos;
|
nuclear@67
|
30
|
nuclear@67
|
31 struct psys_attributes attr;
|
nuclear@67
|
32
|
nuclear@67
|
33 /* list of active particles */
|
nuclear@67
|
34 struct psys_particle *plist;
|
nuclear@67
|
35 int pcount; /* number of active particles */
|
nuclear@67
|
36
|
nuclear@67
|
37 /* list of collision planes */
|
nuclear@67
|
38 struct psys_plane *planes;
|
nuclear@67
|
39
|
nuclear@67
|
40 /* custom spawn closure */
|
nuclear@67
|
41 void *spawn_cls;
|
nuclear@67
|
42 psys_spawn_func_t spawn;
|
nuclear@67
|
43
|
nuclear@67
|
44 /* custom particle update closure */
|
nuclear@67
|
45 void *upd_cls;
|
nuclear@67
|
46 psys_update_func_t update;
|
nuclear@67
|
47
|
nuclear@67
|
48 /* custom draw closure */
|
nuclear@67
|
49 void *draw_cls;
|
nuclear@67
|
50 psys_draw_func_t draw;
|
nuclear@67
|
51 psys_draw_start_func_t draw_start;
|
nuclear@67
|
52 psys_draw_end_func_t draw_end;
|
nuclear@67
|
53
|
nuclear@67
|
54 float spawn_acc; /* partial spawn accumulator */
|
nuclear@67
|
55 float last_update; /* last update time (to calc dt) */
|
nuclear@67
|
56 };
|
nuclear@67
|
57
|
nuclear@67
|
58
|
nuclear@67
|
59 struct psys_particle {
|
nuclear@67
|
60 vec3_t pos, vel;
|
nuclear@67
|
61 float life, max_life;
|
nuclear@67
|
62 float base_size;
|
nuclear@67
|
63
|
nuclear@67
|
64 struct psys_particle_attributes *pattr;
|
nuclear@67
|
65
|
nuclear@67
|
66 /* current particle attr values calculated during update */
|
nuclear@67
|
67 vec3_t color;
|
nuclear@67
|
68 float alpha, size;
|
nuclear@67
|
69
|
nuclear@67
|
70 struct psys_particle *next;
|
nuclear@67
|
71 };
|
nuclear@67
|
72
|
nuclear@67
|
73 #ifdef __cplusplus
|
nuclear@67
|
74 extern "C" {
|
nuclear@67
|
75 #endif
|
nuclear@67
|
76
|
nuclear@67
|
77 struct psys_emitter *psys_create(void);
|
nuclear@67
|
78 void psys_free(struct psys_emitter *em);
|
nuclear@67
|
79
|
nuclear@67
|
80 int psys_init(struct psys_emitter *em);
|
nuclear@67
|
81 void psys_destroy(struct psys_emitter *em);
|
nuclear@67
|
82
|
nuclear@67
|
83 /* set properties */
|
nuclear@67
|
84 void psys_set_pos(struct psys_emitter *em, vec3_t pos, float tm);
|
nuclear@67
|
85 void psys_set_rot(struct psys_emitter *em, quat_t rot, float tm);
|
nuclear@67
|
86 void psys_set_pivot(struct psys_emitter *em, vec3_t pivot);
|
nuclear@67
|
87
|
nuclear@67
|
88 vec3_t psys_get_pos(struct psys_emitter *em, float tm);
|
nuclear@67
|
89 quat_t psys_get_rot(struct psys_emitter *em, float tm);
|
nuclear@67
|
90 vec3_t psys_get_pivot(struct psys_emitter *em);
|
nuclear@67
|
91
|
nuclear@67
|
92 void psys_clear_collision_planes(struct psys_emitter *em);
|
nuclear@67
|
93 int psys_add_collision_plane(struct psys_emitter *em, plane_t plane, float elast);
|
nuclear@67
|
94
|
nuclear@67
|
95 void psys_add_particle(struct psys_emitter *em, struct psys_particle *p);
|
nuclear@67
|
96
|
nuclear@67
|
97 void psys_spawn_func(struct psys_emitter *em, psys_spawn_func_t func, void *cls);
|
nuclear@67
|
98 void psys_update_func(struct psys_emitter *em, psys_update_func_t func, void *cls);
|
nuclear@67
|
99 void psys_draw_func(struct psys_emitter *em, psys_draw_func_t draw,
|
nuclear@67
|
100 psys_draw_start_func_t start, psys_draw_end_func_t end, void *cls);
|
nuclear@67
|
101
|
nuclear@67
|
102 /* update and render */
|
nuclear@67
|
103
|
nuclear@67
|
104 void psys_update(struct psys_emitter *em, float tm);
|
nuclear@67
|
105 void psys_draw(struct psys_emitter *em);
|
nuclear@67
|
106
|
nuclear@67
|
107 #ifdef __cplusplus
|
nuclear@67
|
108 }
|
nuclear@67
|
109 #endif
|
nuclear@67
|
110
|
nuclear@67
|
111 #endif /* LIBPSYS_H_ */
|