goat3dgfx

diff src/psyspp.h @ 0:1873dfd13f2d

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 14 Nov 2013 05:27:09 +0200
parents
children 7d6b667821cf
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/psyspp.h	Thu Nov 14 05:27:09 2013 +0200
     1.3 @@ -0,0 +1,79 @@
     1.4 +#ifndef PSYSPP_H_
     1.5 +#define PSYSPP_H_
     1.6 +
     1.7 +#include "xform_node.h"
     1.8 +#include "texture.h"
     1.9 +#include <psys/psys.h>
    1.10 +
    1.11 +class ParticleSystemAttributes {
    1.12 +private:
    1.13 +	Texture *tex;
    1.14 +	psys_attributes *psattr;
    1.15 +	bool own_psattr;
    1.16 +
    1.17 +public:
    1.18 +	ParticleSystemAttributes();
    1.19 +	ParticleSystemAttributes(psys_attributes *psattr);
    1.20 +	~ParticleSystemAttributes();
    1.21 +
    1.22 +	ParticleSystemAttributes(const ParticleSystemAttributes &rhs);
    1.23 +	ParticleSystemAttributes &operator =(const ParticleSystemAttributes &rhs);
    1.24 +
    1.25 +	bool load(const char *fname);
    1.26 +	bool load(FILE *fp);
    1.27 +	bool save(const char *fname) const;
    1.28 +	bool save(FILE *fp) const;
    1.29 +
    1.30 +	// particle attributes
    1.31 +	void set_part_color(const Vector3 &color, float t = 0);
    1.32 +	void set_part_alpha(float alpha, float t = 0);
    1.33 +	void set_part_scale(float size, float t = 0);
    1.34 +
    1.35 +	// emmiter attributes
    1.36 +	void set_texture(Texture *tex);
    1.37 +	Texture *get_texture() const;
    1.38 +
    1.39 +	void set_spawn_range(const Vector3 &range, long tm = 0);
    1.40 +
    1.41 +	void set_spawn_rate(float rate, long tm = 0);
    1.42 +	float get_spawn_rate(long tm = 0) const;
    1.43 +
    1.44 +	void set_life(float life, float range = 0.0, long tm = 0);
    1.45 +	void set_size(float sz, float range = 0.0, long tm = 0);
    1.46 +	void set_spawn_dir(const Vector3 &dir, const Vector3 &range = Vector3(0, 0, 0), long tm = 0);
    1.47 +
    1.48 +	void set_gravity(const Vector3 &grav, long tm = 0);
    1.49 +	void set_drag(float drag);
    1.50 +
    1.51 +	void set_particle_limit(int lim);
    1.52 +};
    1.53 +
    1.54 +class ParticleSystem : public XFormNode {
    1.55 +private:
    1.56 +	psys_emitter psys;
    1.57 +	ParticleSystemAttributes attr;
    1.58 +
    1.59 +	long start_time;	// subtracted from all time calculations
    1.60 +	long last_upd_time;
    1.61 +
    1.62 +public:
    1.63 +	ParticleSystem();
    1.64 +	~ParticleSystem();
    1.65 +
    1.66 +	void set_start_time(long tm);
    1.67 +
    1.68 +	bool is_active() const;
    1.69 +
    1.70 +	ParticleSystemAttributes *get_attr();
    1.71 +	const ParticleSystemAttributes *get_attr() const;
    1.72 +
    1.73 +	void set_attr(const ParticleSystemAttributes &pattr);
    1.74 +
    1.75 +	bool load(const char *fname);
    1.76 +	bool save(const char *fname) const;
    1.77 +
    1.78 +	void update(long tm);
    1.79 +	void draw() const;
    1.80 +};
    1.81 +
    1.82 +#endif	// PSYSPP_H_