libpsys

diff src/psys.h @ 3:133094e2f5a5

reorganizing
author John Tsiombikas <nuclear@mutantstargoat.com>
date Mon, 26 Sep 2011 18:20:11 +0300
parents 6e5342a2529a
children 613d2bf3ea1f
line diff
     1.1 --- a/src/psys.h	Sun Sep 25 04:26:51 2011 +0300
     1.2 +++ b/src/psys.h	Mon Sep 26 18:20:11 2011 +0300
     1.3 @@ -1,9 +1,79 @@
     1.4  #ifndef LIBPSYS_H_
     1.5  #define LIBPSYS_H_
     1.6  
     1.7 -struct psys_emitter;
     1.8 +#include <vmath.h>
     1.9 +#include <anim/anim.h>
    1.10 +#include "rndval.h"
    1.11 +
    1.12 +struct anm_track_vec3 {
    1.13 +	struct anm_track x, y, z;
    1.14 +};
    1.15 +
    1.16 +struct psys_plane {
    1.17 +	plane_t p;
    1.18 +	float elasticity;
    1.19 +	struct psys_plane *next;
    1.20 +};
    1.21 +
    1.22  struct psys_particle;
    1.23  
    1.24 +struct psys_emitter {
    1.25 +	float last_update;
    1.26 +
    1.27 +	unsigned int tex;
    1.28 +
    1.29 +	struct anm_node prs;
    1.30 +	struct anm_track_vec3 pos_range;
    1.31 +
    1.32 +	struct anm_track rate;
    1.33 +	struct anm_track life, life_range;
    1.34 +	struct anm_track size, size_range;
    1.35 +	struct anm_track_vec3 dir, dir_range;
    1.36 +	struct anm_track_vec3 grav;
    1.37 +
    1.38 +	float drag;	/* I don't think this needs to animate */
    1.39 +
    1.40 +	/* list of active particles */
    1.41 +	struct psys_particle *plist;
    1.42 +
    1.43 +	/* list of collision planes */
    1.44 +	struct col_plane *planes;
    1.45 +
    1.46 +	/* custom spawn closure */
    1.47 +	void *spawn_cls;
    1.48 +	psys_spawn_func_t spawn;
    1.49 +
    1.50 +	/* custom particle update closure */
    1.51 +	void *upd_cls;
    1.52 +	psys_update_func_t update;
    1.53 +
    1.54 +	/* custom draw closure */
    1.55 +	void *draw_cls;
    1.56 +	psys_draw_func_t draw;
    1.57 +	psys_draw_start_func_t draw_start;
    1.58 +	psys_draw_end_func_t draw_end;
    1.59 +
    1.60 +	/* calculated on update */
    1.61 +	vec3_t cur_pos, cur_pos_range;
    1.62 +	quat_t cur_rot;
    1.63 +	float cur_rate, cur_life;
    1.64 +	float cur_size, cur_size_range;
    1.65 +	vec3_t cur_dir;
    1.66 +	vec3_t cur_grav;
    1.67 +
    1.68 +	/* partial spawn accumulator */
    1.69 +	float spawn_acc;
    1.70 +};
    1.71 +
    1.72 +
    1.73 +struct psys_particle {
    1.74 +	vec3_t pos, vel;
    1.75 +	float life, size;
    1.76 +
    1.77 +	struct psys_particle *next;
    1.78 +};
    1.79 +
    1.80 +
    1.81  typedef int (*psys_spawn_func_t)(struct psys_emitter*, struct psys_particle*, void*);
    1.82  typedef void (*psys_update_func_t)(struct psys_emitter*, struct psys_particle*, float, float, void*);
    1.83  
    1.84 @@ -21,13 +91,14 @@
    1.85  /* set properties */
    1.86  void psys_set_texture(struct psys_emitter *em, unsigned int tex);
    1.87  
    1.88 -void psys_set_pos(struct psys_emitter *em, vec3_t pos, float tm);
    1.89 +void psys_set_pos(struct psys_emitter *em, vec3_t pos, vec3_t range, float tm);
    1.90  void psys_set_rot(struct psys_emitter *em, quat_t rot, float tm);
    1.91  void psys_set_pivot(struct psys_emitter *em, vec3_t pivot);
    1.92  
    1.93  void psys_set_rate(struct psys_emitter *em, float rate, float tm);
    1.94 -void psys_set_life(struct psys_emitter *em, float life, float tm);
    1.95 -void psys_set_dir(struct psys_emitter *em, vec3_t dir, float tm);
    1.96 +void psys_set_life(struct psys_emitter *em, float life, float range, float tm);
    1.97 +void psys_set_size(struct psys_emitter *em, float size, float range, float tm);
    1.98 +void psys_set_dir(struct psys_emitter *em, vec3_t dir, vec3_t range, float tm);
    1.99  void psys_set_grav(struct psys_emitter *em, vec3_t grav, float tm);
   1.100  
   1.101  void psys_clear_collision_planes(struct psys_emitter *em);
   1.102 @@ -40,16 +111,6 @@
   1.103  void psys_draw_func(struct psys_emitter *em, psys_draw_func_t draw,
   1.104  		psys_draw_start_func_t start, psys_draw_end_func_t end, void *cls);
   1.105  
   1.106 -
   1.107 -/* query emitter state */
   1.108 -unsigned int psys_get_texture(struct psys_emitter *em);
   1.109 -vec3_t psys_get_pos(struct psys_emitter *em);
   1.110 -quat_t psys_get_rot(struct psys_emitter *em);
   1.111 -float psys_get_rate(struct psys_emitter *em);
   1.112 -float psys_get_life(struct psys_emitter *em);
   1.113 -vec3_t psys_get_dir(struct psys_emitter *em);
   1.114 -vec3_t psys_get_grav(struct psys_emitter *em);
   1.115 -
   1.116  /* update and render */
   1.117  
   1.118  void psys_update(struct psys_emitter *em, float tm);