libanim

diff src/anim.h @ 58:fe017bde08bc

implemented multiple animations per node, and blending between two animations
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 27 Dec 2013 06:28:43 +0200
parents 3c2428cb38f7
children 9758004136f8
line diff
     1.1 --- a/src/anim.h	Mon Dec 09 04:06:30 2013 +0200
     1.2 +++ b/src/anim.h	Fri Dec 27 06:28:43 2013 +0200
     1.3 @@ -27,10 +27,18 @@
     1.4  	ANM_NUM_TRACKS
     1.5  };
     1.6  
     1.7 +struct anm_animation {
     1.8 +	char *name;
     1.9 +	struct anm_track tracks[ANM_NUM_TRACKS];
    1.10 +};
    1.11 +
    1.12  struct anm_node {
    1.13  	char *name;
    1.14  
    1.15 -	struct anm_track tracks[ANM_NUM_TRACKS];
    1.16 +	int cur_anim[2];
    1.17 +	float cur_mix;
    1.18 +
    1.19 +	struct anm_animation *animations;
    1.20  	vec3_t pivot;
    1.21  
    1.22  	/* matrix cache */
    1.23 @@ -54,6 +62,9 @@
    1.24  extern "C" {
    1.25  #endif
    1.26  
    1.27 +int anm_init_animation(struct anm_animation *anim);
    1.28 +void anm_destroy_animation(struct anm_animation *anim);
    1.29 +
    1.30  /* node constructor and destructor */
    1.31  int anm_init_node(struct anm_node *node);
    1.32  void anm_destroy_node(struct anm_node *node);
    1.33 @@ -74,13 +85,46 @@
    1.34  int anm_set_node_name(struct anm_node *node, const char *name);
    1.35  const char *anm_get_node_name(struct anm_node *node);
    1.36  
    1.37 -void anm_set_interpolator(struct anm_node *node, enum anm_interpolator in);
    1.38 -void anm_set_extrapolator(struct anm_node *node, enum anm_extrapolator ex);
    1.39 -
    1.40  /* link and unlink nodes with parent/child relations */
    1.41  void anm_link_node(struct anm_node *parent, struct anm_node *child);
    1.42  int anm_unlink_node(struct anm_node *parent, struct anm_node *child);
    1.43  
    1.44 +void anm_set_pivot(struct anm_node *node, vec3_t pivot);
    1.45 +vec3_t anm_get_pivot(struct anm_node *node);
    1.46 +
    1.47 +/* set active animation(s) */
    1.48 +int anm_use_node_animation(struct anm_node *node, int aidx);
    1.49 +int anm_use_node_animations(struct anm_node *node, int aidx, int bidx, float t);
    1.50 +/* recursive variants */
    1.51 +int anm_use_animation(struct anm_node *node, int aidx);
    1.52 +int anm_use_animations(struct anm_node *node, int aidx, int bidx, float t);
    1.53 +
    1.54 +/* returns the requested current animation index, which can be 0 or 1 */
    1.55 +int anm_get_active_animation_index(struct anm_node *node, int which);
    1.56 +/* returns the requested current animation, which can be 0 or 1 */
    1.57 +struct anm_animation *anm_get_active_animation(struct anm_node *node, int which);
    1.58 +float anm_get_active_animation_mix(struct anm_node *node);
    1.59 +
    1.60 +int anm_get_animation_count(struct anm_node *node);
    1.61 +
    1.62 +/* add/remove an animation to the specified node */
    1.63 +int anm_add_node_animation(struct anm_node *node);
    1.64 +int anm_remove_node_animation(struct anm_node *node, int idx);
    1.65 +
    1.66 +/* add/remove an animation to the specified node and all it's descendants */
    1.67 +int anm_add_animation(struct anm_node *node);
    1.68 +int anm_remove_animation(struct anm_node *node, int idx);
    1.69 +
    1.70 +struct anm_animation *anm_get_animation(struct anm_node *node, int idx);
    1.71 +struct anm_animation *anm_get_animation_by_name(struct anm_node *node, const char *name);
    1.72 +
    1.73 +int anm_find_animation(struct anm_node *node, const char *name);
    1.74 +
    1.75 +/* set the interpolator for the (first) currently active animation */
    1.76 +void anm_set_interpolator(struct anm_node *node, enum anm_interpolator in);
    1.77 +/* set the extrapolator for the (first) currently active animation */
    1.78 +void anm_set_extrapolator(struct anm_node *node, enum anm_extrapolator ex);
    1.79 +
    1.80  void anm_set_position(struct anm_node *node, vec3_t pos, anm_time_t tm);
    1.81  vec3_t anm_get_node_position(struct anm_node *node, anm_time_t tm);
    1.82  
    1.83 @@ -95,9 +139,6 @@
    1.84  quat_t anm_get_rotation(struct anm_node *node, anm_time_t tm);
    1.85  vec3_t anm_get_scaling(struct anm_node *node, anm_time_t tm);
    1.86  
    1.87 -void anm_set_pivot(struct anm_node *node, vec3_t pivot);
    1.88 -vec3_t anm_get_pivot(struct anm_node *node);
    1.89 -
    1.90  /* those return the start and end times of the whole tree */
    1.91  anm_time_t anm_get_start_time(struct anm_node *node);
    1.92  anm_time_t anm_get_end_time(struct anm_node *node);