dungeon_crawler
diff prototype/anim/anim.h @ 67:2560a7ab0243
internalized libanim, libimago2, and libpsys
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 07 Oct 2012 02:04:00 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/prototype/anim/anim.h Sun Oct 07 02:04:00 2012 +0300 1.3 @@ -0,0 +1,99 @@ 1.4 +#ifndef LIBANIM_H_ 1.5 +#define LIBANIM_H_ 1.6 + 1.7 +#include "config.h" 1.8 + 1.9 +#ifdef ANIM_THREAD_SAFE 1.10 +#include <pthread.h> 1.11 +#endif 1.12 + 1.13 +#include <vmath/vmath.h> 1.14 +#include "track.h" 1.15 + 1.16 +enum { 1.17 + ANM_TRACK_POS_X, 1.18 + ANM_TRACK_POS_Y, 1.19 + ANM_TRACK_POS_Z, 1.20 + 1.21 + ANM_TRACK_ROT_X, 1.22 + ANM_TRACK_ROT_Y, 1.23 + ANM_TRACK_ROT_Z, 1.24 + ANM_TRACK_ROT_W, 1.25 + 1.26 + ANM_TRACK_SCL_X, 1.27 + ANM_TRACK_SCL_Y, 1.28 + ANM_TRACK_SCL_Z, 1.29 + 1.30 + ANM_NUM_TRACKS 1.31 +}; 1.32 + 1.33 +struct anm_node { 1.34 + char *name; 1.35 + 1.36 + struct anm_track tracks[ANM_NUM_TRACKS]; 1.37 + vec3_t pivot; 1.38 + 1.39 + /* matrix cache */ 1.40 + mat4_t cache_matrix; 1.41 + anm_time_t cache_time; 1.42 +#ifdef ANIM_THREAD_SAFE 1.43 + pthread_mutex_t cache_mutex; 1.44 +#endif 1.45 + 1.46 + struct anm_node *parent; 1.47 + struct anm_node *child; 1.48 + struct anm_node *next; 1.49 +}; 1.50 + 1.51 + 1.52 +/* node constructor and destructor */ 1.53 +int anm_init_node(struct anm_node *node); 1.54 +void anm_destroy_node(struct anm_node *node); 1.55 + 1.56 +/* recursively destroy an animation node tree */ 1.57 +void anm_destroy_node_tree(struct anm_node *tree); 1.58 + 1.59 +/* helper functions to allocate/construct and destroy/free with 1.60 + * a single call. They call anm_init_node and anm_destroy_node 1.61 + * internally. 1.62 + */ 1.63 +struct anm_node *anm_create_node(void); 1.64 +void anm_free_node(struct anm_node *node); 1.65 + 1.66 +/* recursively destroy and free the nodes of a node tree */ 1.67 +void anm_free_node_tree(struct anm_node *tree); 1.68 + 1.69 +int anm_set_node_name(struct anm_node *node, const char *name); 1.70 +const char *anm_get_node_name(struct anm_node *node); 1.71 + 1.72 +void anm_set_interpolator(struct anm_node *node, enum anm_interpolator in); 1.73 +void anm_set_extrapolator(struct anm_node *node, enum anm_extrapolator ex); 1.74 + 1.75 +/* link and unlink nodes with parent/child relations */ 1.76 +void anm_link_node(struct anm_node *parent, struct anm_node *child); 1.77 +int anm_unlink_node(struct anm_node *parent, struct anm_node *child); 1.78 + 1.79 +void anm_set_position(struct anm_node *node, vec3_t pos, anm_time_t tm); 1.80 +vec3_t anm_get_node_position(struct anm_node *node, anm_time_t tm); 1.81 + 1.82 +void anm_set_rotation(struct anm_node *node, quat_t rot, anm_time_t tm); 1.83 +quat_t anm_get_node_rotation(struct anm_node *node, anm_time_t tm); 1.84 + 1.85 +void anm_set_scaling(struct anm_node *node, vec3_t scl, anm_time_t tm); 1.86 +vec3_t anm_get_node_scaling(struct anm_node *node, anm_time_t tm); 1.87 + 1.88 +/* these three return the full p/r/s taking hierarchy into account */ 1.89 +vec3_t anm_get_position(struct anm_node *node, anm_time_t tm); 1.90 +quat_t anm_get_rotation(struct anm_node *node, anm_time_t tm); 1.91 +vec3_t anm_get_scaling(struct anm_node *node, anm_time_t tm); 1.92 + 1.93 +void anm_set_pivot(struct anm_node *node, vec3_t pivot); 1.94 +vec3_t anm_get_pivot(struct anm_node *node); 1.95 + 1.96 +void anm_get_matrix(struct anm_node *node, mat4_t mat, anm_time_t tm); 1.97 + 1.98 +/* those return the start and end times of the whole tree */ 1.99 +anm_time_t anm_get_start_time(struct anm_node *node); 1.100 +anm_time_t anm_get_end_time(struct anm_node *node); 1.101 + 1.102 +#endif /* LIBANIM_H_ */