libpsys

annotate src/psys.h @ 10:0f83e882fd04

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