nuclear@67: #ifndef LIBANIM_H_ nuclear@67: #define LIBANIM_H_ nuclear@67: nuclear@67: #include "config.h" nuclear@67: nuclear@67: #ifdef ANIM_THREAD_SAFE nuclear@67: #include nuclear@67: #endif nuclear@67: nuclear@67: #include nuclear@67: #include "track.h" nuclear@67: nuclear@67: enum { nuclear@67: ANM_TRACK_POS_X, nuclear@67: ANM_TRACK_POS_Y, nuclear@67: ANM_TRACK_POS_Z, nuclear@67: nuclear@67: ANM_TRACK_ROT_X, nuclear@67: ANM_TRACK_ROT_Y, nuclear@67: ANM_TRACK_ROT_Z, nuclear@67: ANM_TRACK_ROT_W, nuclear@67: nuclear@67: ANM_TRACK_SCL_X, nuclear@67: ANM_TRACK_SCL_Y, nuclear@67: ANM_TRACK_SCL_Z, nuclear@67: nuclear@67: ANM_NUM_TRACKS nuclear@67: }; nuclear@67: nuclear@67: struct anm_node { nuclear@67: char *name; nuclear@67: nuclear@67: struct anm_track tracks[ANM_NUM_TRACKS]; nuclear@67: vec3_t pivot; nuclear@67: nuclear@67: /* matrix cache */ nuclear@67: mat4_t cache_matrix; nuclear@67: anm_time_t cache_time; nuclear@67: #ifdef ANIM_THREAD_SAFE nuclear@67: pthread_mutex_t cache_mutex; nuclear@67: #endif nuclear@67: nuclear@67: struct anm_node *parent; nuclear@67: struct anm_node *child; nuclear@67: struct anm_node *next; nuclear@67: }; nuclear@67: nuclear@67: nuclear@67: /* node constructor and destructor */ nuclear@67: int anm_init_node(struct anm_node *node); nuclear@67: void anm_destroy_node(struct anm_node *node); nuclear@67: nuclear@67: /* recursively destroy an animation node tree */ nuclear@67: void anm_destroy_node_tree(struct anm_node *tree); nuclear@67: nuclear@67: /* helper functions to allocate/construct and destroy/free with nuclear@67: * a single call. They call anm_init_node and anm_destroy_node nuclear@67: * internally. nuclear@67: */ nuclear@67: struct anm_node *anm_create_node(void); nuclear@67: void anm_free_node(struct anm_node *node); nuclear@67: nuclear@67: /* recursively destroy and free the nodes of a node tree */ nuclear@67: void anm_free_node_tree(struct anm_node *tree); nuclear@67: nuclear@67: int anm_set_node_name(struct anm_node *node, const char *name); nuclear@67: const char *anm_get_node_name(struct anm_node *node); nuclear@67: nuclear@67: void anm_set_interpolator(struct anm_node *node, enum anm_interpolator in); nuclear@67: void anm_set_extrapolator(struct anm_node *node, enum anm_extrapolator ex); nuclear@67: nuclear@67: /* link and unlink nodes with parent/child relations */ nuclear@67: void anm_link_node(struct anm_node *parent, struct anm_node *child); nuclear@67: int anm_unlink_node(struct anm_node *parent, struct anm_node *child); nuclear@67: nuclear@67: void anm_set_position(struct anm_node *node, vec3_t pos, anm_time_t tm); nuclear@67: vec3_t anm_get_node_position(struct anm_node *node, anm_time_t tm); nuclear@67: nuclear@67: void anm_set_rotation(struct anm_node *node, quat_t rot, anm_time_t tm); nuclear@67: quat_t anm_get_node_rotation(struct anm_node *node, anm_time_t tm); nuclear@67: nuclear@67: void anm_set_scaling(struct anm_node *node, vec3_t scl, anm_time_t tm); nuclear@67: vec3_t anm_get_node_scaling(struct anm_node *node, anm_time_t tm); nuclear@67: nuclear@67: /* these three return the full p/r/s taking hierarchy into account */ nuclear@67: vec3_t anm_get_position(struct anm_node *node, anm_time_t tm); nuclear@67: quat_t anm_get_rotation(struct anm_node *node, anm_time_t tm); nuclear@67: vec3_t anm_get_scaling(struct anm_node *node, anm_time_t tm); nuclear@67: nuclear@67: void anm_set_pivot(struct anm_node *node, vec3_t pivot); nuclear@67: vec3_t anm_get_pivot(struct anm_node *node); nuclear@67: nuclear@67: void anm_get_matrix(struct anm_node *node, mat4_t mat, anm_time_t tm); nuclear@67: nuclear@67: /* those return the start and end times of the whole tree */ nuclear@67: anm_time_t anm_get_start_time(struct anm_node *node); nuclear@67: anm_time_t anm_get_end_time(struct anm_node *node); nuclear@67: nuclear@67: #endif /* LIBANIM_H_ */