added cgmath, libanim, and libpsys
[andemo] / libs / psys / pstrack.h
1 /*
2 libpsys - reusable particle system library.
3 Copyright (C) 2011-2018  John Tsiombikas <nuclear@member.fsf.org>
4
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.
9
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.
14
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/>.
17 */
18 #ifndef PSTRACK_H_
19 #define PSTRACK_H_
20
21 #include <anim/anim.h>
22
23 struct psys_track {
24         struct anm_track trk;
25
26         anm_time_t cache_tm;
27         float cache_val;
28 };
29
30 struct psys_track3 {
31         struct anm_track x, y, z;
32
33         anm_time_t cache_tm;
34         float cache_vec[3];
35 };
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 int psys_init_track(struct psys_track *track);
42 void psys_destroy_track(struct psys_track *track);
43
44 int psys_init_track3(struct psys_track3 *track);
45 void psys_destroy_track3(struct psys_track3 *track);
46
47 /* XXX dest must have been initialized first */
48 void psys_copy_track(struct psys_track *dest, const struct psys_track *src);
49 void psys_copy_track3(struct psys_track3 *dest, const struct psys_track3 *src);
50
51 void psys_eval_track(struct psys_track *track, anm_time_t tm);
52 void psys_set_value(struct psys_track *track, anm_time_t tm, float v);
53 float psys_get_value(struct psys_track *track, anm_time_t tm);
54 float psys_get_cur_value(struct psys_track *track);
55
56 void psys_eval_track3(struct psys_track3 *track, anm_time_t tm);
57 void psys_set_value3(struct psys_track3 *track, anm_time_t tm, float x, float y, float z);
58 /* returns pointer to the internal cached value, and if vec is not null, also copies it there */
59 float *psys_get_value3(struct psys_track3 *track, anm_time_t tm, float *vec);
60 float *psys_get_cur_value3(struct psys_track3 *track, float *vec);
61
62 #ifdef __cplusplus
63 }
64 #endif
65
66 #endif  /* PSTRACK_H_ */