goat3dgfx

view src/psyspp.h @ 21:7c593721547f

integrated support for the multiple animation system of libanim
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 27 Dec 2013 11:59:32 +0200
parents 1873dfd13f2d
children
line source
1 #ifndef PSYSPP_H_
2 #define PSYSPP_H_
4 #include "xform_node.h"
5 #include "texture.h"
6 #include <psys/psys.h>
8 namespace goatgfx {
10 class ParticleSystemAttributes {
11 private:
12 Texture *tex;
13 psys_attributes *psattr;
14 bool own_psattr;
16 public:
17 ParticleSystemAttributes();
18 ParticleSystemAttributes(psys_attributes *psattr);
19 ~ParticleSystemAttributes();
21 ParticleSystemAttributes(const ParticleSystemAttributes &rhs);
22 ParticleSystemAttributes &operator =(const ParticleSystemAttributes &rhs);
24 bool load(const char *fname);
25 bool load(FILE *fp);
26 bool save(const char *fname) const;
27 bool save(FILE *fp) const;
29 // particle attributes
30 void set_part_color(const Vector3 &color, float t = 0);
31 void set_part_alpha(float alpha, float t = 0);
32 void set_part_scale(float size, float t = 0);
34 // emmiter attributes
35 void set_texture(Texture *tex);
36 Texture *get_texture() const;
38 void set_spawn_range(const Vector3 &range, long tm = 0);
40 void set_spawn_rate(float rate, long tm = 0);
41 float get_spawn_rate(long tm = 0) const;
43 void set_life(float life, float range = 0.0, long tm = 0);
44 void set_size(float sz, float range = 0.0, long tm = 0);
45 void set_spawn_dir(const Vector3 &dir, const Vector3 &range = Vector3(0, 0, 0), long tm = 0);
47 void set_gravity(const Vector3 &grav, long tm = 0);
48 void set_drag(float drag);
50 void set_particle_limit(int lim);
51 };
53 class ParticleSystem : public XFormNode {
54 private:
55 psys_emitter psys;
56 ParticleSystemAttributes attr;
58 long start_time; // subtracted from all time calculations
59 long last_upd_time;
61 public:
62 ParticleSystem();
63 ~ParticleSystem();
65 void set_start_time(long tm);
67 bool is_active() const;
69 ParticleSystemAttributes *get_attr();
70 const ParticleSystemAttributes *get_attr() const;
72 void set_attr(const ParticleSystemAttributes &pattr);
74 bool load(const char *fname);
75 bool save(const char *fname) const;
77 void update(long tm);
78 void draw() const;
79 };
81 } // namespace goatgfx
83 #endif // PSYSPP_H_