goat3d

annotate libs/anim/anim.h @ 30:0fe02696fb1e

yeeay, the max plugin works :)
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 29 Sep 2013 23:05:44 +0300
parents
children 0ecb788a87f7
rev   line source
nuclear@27 1 #ifndef LIBANIM_H_
nuclear@27 2 #define LIBANIM_H_
nuclear@27 3
nuclear@27 4 #include "config.h"
nuclear@27 5
nuclear@27 6 #include <vmath/vector.h>
nuclear@27 7 #include <vmath/quat.h>
nuclear@27 8 #include <vmath/matrix.h>
nuclear@27 9 #include "track.h"
nuclear@27 10
nuclear@27 11 enum {
nuclear@27 12 ANM_TRACK_POS_X,
nuclear@27 13 ANM_TRACK_POS_Y,
nuclear@27 14 ANM_TRACK_POS_Z,
nuclear@27 15
nuclear@27 16 ANM_TRACK_ROT_X,
nuclear@27 17 ANM_TRACK_ROT_Y,
nuclear@27 18 ANM_TRACK_ROT_Z,
nuclear@27 19 ANM_TRACK_ROT_W,
nuclear@27 20
nuclear@27 21 ANM_TRACK_SCL_X,
nuclear@27 22 ANM_TRACK_SCL_Y,
nuclear@27 23 ANM_TRACK_SCL_Z,
nuclear@27 24
nuclear@27 25 ANM_NUM_TRACKS
nuclear@27 26 };
nuclear@27 27
nuclear@27 28 struct anm_node {
nuclear@27 29 char *name;
nuclear@27 30
nuclear@27 31 struct anm_track tracks[ANM_NUM_TRACKS];
nuclear@27 32 vec3_t pivot;
nuclear@27 33
nuclear@27 34 /* matrix cache */
nuclear@27 35 struct mat_cache {
nuclear@27 36 mat4_t matrix, inv_matrix;
nuclear@27 37 anm_time_t time, inv_time;
nuclear@27 38 } cache;
nuclear@27 39
nuclear@27 40 struct anm_node *parent;
nuclear@27 41 struct anm_node *child;
nuclear@27 42 struct anm_node *next;
nuclear@27 43 };
nuclear@27 44
nuclear@27 45 #ifdef __cplusplus
nuclear@27 46 extern "C" {
nuclear@27 47 #endif
nuclear@27 48
nuclear@27 49 /* node constructor and destructor */
nuclear@27 50 int anm_init_node(struct anm_node *node);
nuclear@27 51 void anm_destroy_node(struct anm_node *node);
nuclear@27 52
nuclear@27 53 /* recursively destroy an animation node tree */
nuclear@27 54 void anm_destroy_node_tree(struct anm_node *tree);
nuclear@27 55
nuclear@27 56 /* helper functions to allocate/construct and destroy/free with
nuclear@27 57 * a single call. They call anm_init_node and anm_destroy_node
nuclear@27 58 * internally.
nuclear@27 59 */
nuclear@27 60 struct anm_node *anm_create_node(void);
nuclear@27 61 void anm_free_node(struct anm_node *node);
nuclear@27 62
nuclear@27 63 /* recursively destroy and free the nodes of a node tree */
nuclear@27 64 void anm_free_node_tree(struct anm_node *tree);
nuclear@27 65
nuclear@27 66 int anm_set_node_name(struct anm_node *node, const char *name);
nuclear@27 67 const char *anm_get_node_name(struct anm_node *node);
nuclear@27 68
nuclear@27 69 void anm_set_interpolator(struct anm_node *node, enum anm_interpolator in);
nuclear@27 70 void anm_set_extrapolator(struct anm_node *node, enum anm_extrapolator ex);
nuclear@27 71
nuclear@27 72 /* link and unlink nodes with parent/child relations */
nuclear@27 73 void anm_link_node(struct anm_node *parent, struct anm_node *child);
nuclear@27 74 int anm_unlink_node(struct anm_node *parent, struct anm_node *child);
nuclear@27 75
nuclear@27 76 void anm_set_position(struct anm_node *node, vec3_t pos, anm_time_t tm);
nuclear@27 77 vec3_t anm_get_node_position(struct anm_node *node, anm_time_t tm);
nuclear@27 78
nuclear@27 79 void anm_set_rotation(struct anm_node *node, quat_t rot, anm_time_t tm);
nuclear@27 80 quat_t anm_get_node_rotation(struct anm_node *node, anm_time_t tm);
nuclear@27 81
nuclear@27 82 void anm_set_scaling(struct anm_node *node, vec3_t scl, anm_time_t tm);
nuclear@27 83 vec3_t anm_get_node_scaling(struct anm_node *node, anm_time_t tm);
nuclear@27 84
nuclear@27 85 /* these three return the full p/r/s taking hierarchy into account */
nuclear@27 86 vec3_t anm_get_position(struct anm_node *node, anm_time_t tm);
nuclear@27 87 quat_t anm_get_rotation(struct anm_node *node, anm_time_t tm);
nuclear@27 88 vec3_t anm_get_scaling(struct anm_node *node, anm_time_t tm);
nuclear@27 89
nuclear@27 90 void anm_set_pivot(struct anm_node *node, vec3_t pivot);
nuclear@27 91 vec3_t anm_get_pivot(struct anm_node *node);
nuclear@27 92
nuclear@27 93 /* these calculate the matrix and inverse matrix of this node alone */
nuclear@27 94 void anm_get_node_matrix(struct anm_node *node, mat4_t mat, anm_time_t tm);
nuclear@27 95 void anm_get_node_inv_matrix(struct anm_node *node, mat4_t mat, anm_time_t tm);
nuclear@27 96
nuclear@27 97 /* These calculate the matrix and inverse matrix of this node taking hierarchy
nuclear@27 98 * into account. The results are cached in thread-specific storage and returned
nuclear@27 99 * if there's no change in time or tracks from the last query...
nuclear@27 100 */
nuclear@27 101 void anm_get_matrix(struct anm_node *node, mat4_t mat, anm_time_t tm);
nuclear@27 102 void anm_get_inv_matrix(struct anm_node *node, mat4_t mat, anm_time_t tm);
nuclear@27 103
nuclear@27 104 /* those return the start and end times of the whole tree */
nuclear@27 105 anm_time_t anm_get_start_time(struct anm_node *node);
nuclear@27 106 anm_time_t anm_get_end_time(struct anm_node *node);
nuclear@27 107
nuclear@27 108 #ifdef __cplusplus
nuclear@27 109 }
nuclear@27 110 #endif
nuclear@27 111
nuclear@27 112 #endif /* LIBANIM_H_ */