dungeon_crawler

view prototype/anim/anim.h @ 72:a27528035e20

- re-organized the renderer classes a bit wrt final render-target - implemented identity color-grading palette for now - broke particle systems.... - removed multipass renderer
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 19 Oct 2012 02:45:57 +0300
parents
children
line source
1 #ifndef LIBANIM_H_
2 #define LIBANIM_H_
4 #include "config.h"
6 #ifdef ANIM_THREAD_SAFE
7 #include <pthread.h>
8 #endif
10 #include <vmath/vmath.h>
11 #include "track.h"
13 enum {
14 ANM_TRACK_POS_X,
15 ANM_TRACK_POS_Y,
16 ANM_TRACK_POS_Z,
18 ANM_TRACK_ROT_X,
19 ANM_TRACK_ROT_Y,
20 ANM_TRACK_ROT_Z,
21 ANM_TRACK_ROT_W,
23 ANM_TRACK_SCL_X,
24 ANM_TRACK_SCL_Y,
25 ANM_TRACK_SCL_Z,
27 ANM_NUM_TRACKS
28 };
30 struct anm_node {
31 char *name;
33 struct anm_track tracks[ANM_NUM_TRACKS];
34 vec3_t pivot;
36 /* matrix cache */
37 mat4_t cache_matrix;
38 anm_time_t cache_time;
39 #ifdef ANIM_THREAD_SAFE
40 pthread_mutex_t cache_mutex;
41 #endif
43 struct anm_node *parent;
44 struct anm_node *child;
45 struct anm_node *next;
46 };
49 /* node constructor and destructor */
50 int anm_init_node(struct anm_node *node);
51 void anm_destroy_node(struct anm_node *node);
53 /* recursively destroy an animation node tree */
54 void anm_destroy_node_tree(struct anm_node *tree);
56 /* helper functions to allocate/construct and destroy/free with
57 * a single call. They call anm_init_node and anm_destroy_node
58 * internally.
59 */
60 struct anm_node *anm_create_node(void);
61 void anm_free_node(struct anm_node *node);
63 /* recursively destroy and free the nodes of a node tree */
64 void anm_free_node_tree(struct anm_node *tree);
66 int anm_set_node_name(struct anm_node *node, const char *name);
67 const char *anm_get_node_name(struct anm_node *node);
69 void anm_set_interpolator(struct anm_node *node, enum anm_interpolator in);
70 void anm_set_extrapolator(struct anm_node *node, enum anm_extrapolator ex);
72 /* link and unlink nodes with parent/child relations */
73 void anm_link_node(struct anm_node *parent, struct anm_node *child);
74 int anm_unlink_node(struct anm_node *parent, struct anm_node *child);
76 void anm_set_position(struct anm_node *node, vec3_t pos, anm_time_t tm);
77 vec3_t anm_get_node_position(struct anm_node *node, anm_time_t tm);
79 void anm_set_rotation(struct anm_node *node, quat_t rot, anm_time_t tm);
80 quat_t anm_get_node_rotation(struct anm_node *node, anm_time_t tm);
82 void anm_set_scaling(struct anm_node *node, vec3_t scl, anm_time_t tm);
83 vec3_t anm_get_node_scaling(struct anm_node *node, anm_time_t tm);
85 /* these three return the full p/r/s taking hierarchy into account */
86 vec3_t anm_get_position(struct anm_node *node, anm_time_t tm);
87 quat_t anm_get_rotation(struct anm_node *node, anm_time_t tm);
88 vec3_t anm_get_scaling(struct anm_node *node, anm_time_t tm);
90 void anm_set_pivot(struct anm_node *node, vec3_t pivot);
91 vec3_t anm_get_pivot(struct anm_node *node);
93 void anm_get_matrix(struct anm_node *node, mat4_t mat, anm_time_t tm);
95 /* those return the start and end times of the whole tree */
96 anm_time_t anm_get_start_time(struct anm_node *node);
97 anm_time_t anm_get_end_time(struct anm_node *node);
99 #endif /* LIBANIM_H_ */