2 libpsys - reusable particle system library.
3 Copyright (C) 2011-2018 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 /* the particle attributes vary from 0 to 1 during its lifetime */
26 struct psys_particle_attributes {
27 struct psys_track3 color;
28 struct psys_track alpha;
29 struct psys_track size;
32 enum psys_blending { PSYS_ADD, PSYS_ALPHA };
34 struct psys_attributes {
35 unsigned int tex; /* OpenGL texture to use for the billboard */
37 struct psys_track3 spawn_range; /* radius of emmiter */
38 struct psys_track rate; /* spawn rate particles per sec */
39 struct psys_anm_rnd life; /* particle life in seconds */
40 struct psys_anm_rnd size; /* base particle size */
41 struct psys_anm_rnd3 dir; /* particle shoot direction */
43 struct psys_track3 grav; /* external force (usually gravity) */
44 float drag; /* I don't think this needs to animate */
46 enum psys_blending blending;
48 /* particle attributes */
49 struct psys_particle_attributes part_attr;
59 void psys_texture_loader(unsigned int (*load)(const char*, void*), void (*unload)(unsigned int, void*), void *cls);
61 struct psys_attributes *psys_create_attr(void);
62 void psys_free_attr(struct psys_attributes *attr);
64 int psys_init_attr(struct psys_attributes *attr);
65 void psys_destroy_attr(struct psys_attributes *attr);
67 /* copies particle system attributes src to dest
68 * XXX: dest must have been initialized first
70 void psys_copy_attr(struct psys_attributes *dest, const struct psys_attributes *src);
72 void psys_eval_attr(struct psys_attributes *attr, anm_time_t tm);
74 int psys_load_attr(struct psys_attributes *attr, const char *fname);
75 int psys_load_attr_stream(struct psys_attributes *attr, FILE *fp);
77 int psys_save_attr(const struct psys_attributes *attr, const char *fname);
78 int psys_save_attr_stream(const struct psys_attributes *attr, FILE *fp);