dungeon_crawler

annotate prototype/anim/anim.h @ 75:b05ab29cd17d

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