solstice-anim

Geometry animation library of the solstice app
git clone git://git.meso-star.com/solstice-anim.git
Log | Files | Refs | README | LICENSE

commit 354b81789c7838643a54dff8f964284f5d23cae9
parent 47d16eabcceb44d8048a340b967ab2df8553c812
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Thu, 10 Nov 2016 11:13:53 +0100

Add getters for translation and rotations into API.

Diffstat:
Msrc/sanim.h | 13++++++++++++-
Msrc/sanim_node.c | 20++++++++++++++++++++
Msrc/test_sanim_node.c | 12+++++++++++-
Msrc/test_sanim_utils.c | 12++++++++++++
Msrc/test_sanim_utils.h | 6++++++
5 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/src/sanim.h b/src/sanim.h @@ -151,7 +151,8 @@ sanim_node_visit_tree (struct sanim_node* node, const double in_dir[3], void* data, - res_T (*visitor)(const struct sanim_node* n, const double transform[12], void* data)); + res_T (*visitor)( + const struct sanim_node* n, const double transform[12], void* data)); SANIM_API res_T sanim_node_release @@ -168,11 +169,21 @@ sanim_node_set_translation const double translation[3]); SANIM_API res_T +sanim_node_get_translation + (const struct sanim_node* node, + double translation[3]); + +SANIM_API res_T sanim_node_set_rotations (struct sanim_node* node, const double rotations[3]); /* XYZ convention */ SANIM_API res_T +sanim_node_get_rotations + (const struct sanim_node* node, + double rotations[3]); + +SANIM_API res_T sanim_node_get_transform (struct sanim_node* node, double transform[12]); /* 3x4 column major matrix */ diff --git a/src/sanim_node.c b/src/sanim_node.c @@ -952,6 +952,16 @@ sanim_node_set_translation } res_T +sanim_node_get_translation +(const struct sanim_node* node, + double translation[3]) +{ + if (!node || !node->data || !translation) return RES_BAD_ARG; + d3_set(translation, node->data->translation); + return RES_OK; +} + +res_T sanim_node_set_rotations (struct sanim_node* node, const double rotations[3]) @@ -962,6 +972,16 @@ sanim_node_set_rotations } res_T +sanim_node_get_rotations +(const struct sanim_node* node, + double rotations[3]) +{ + if (!node || !node->data || !rotations) return RES_BAD_ARG; + d3_set(rotations, node->data->rotations); + return RES_OK; +} + +res_T sanim_node_get_transform(struct sanim_node* node, double transform[12]) { if (!node || !node->data || !transform) diff --git a/src/test_sanim_node.c b/src/test_sanim_node.c @@ -28,7 +28,7 @@ main(int argc, char** argv) size_t count; int p; double transform1[12], transform2[12]; - double transl[3], rot[3]; + double transl[3], transl_[3], rot[3], rot_[3]; (void) argc, (void) argv; tracking.policy = TRACKING_SUN; @@ -97,10 +97,20 @@ main(int argc, char** argv) CHECK(my_type_set_translation(t1, NULL), RES_BAD_ARG); CHECK(my_type_set_translation(t1, transl), RES_OK); + CHECK(my_type_get_translation(NULL, transl_), RES_BAD_ARG); + CHECK(my_type_get_translation(t1, NULL), RES_BAD_ARG); + CHECK(my_type_get_translation(t1, transl_), RES_OK); + CHECK(d3_eq(transl, transl_), 1); + CHECK(my_type_set_rotations(NULL, rot), RES_BAD_ARG); CHECK(my_type_set_rotations(t1, NULL), RES_BAD_ARG); CHECK(my_type_set_rotations(t1, rot), RES_OK); + CHECK(my_type_get_rotations(NULL, rot_), RES_BAD_ARG); + CHECK(my_type_get_rotations(t1, NULL), RES_BAD_ARG); + CHECK(my_type_get_rotations(t1, rot_), RES_OK); + CHECK(d3_eq(rot, rot_), 1); + CHECK(my_type_get_transform(NULL, transform1), RES_BAD_ARG); CHECK(my_type_get_transform(t1, NULL), RES_BAD_ARG); CHECK(my_type_get_transform(t1, transform1), RES_OK); diff --git a/src/test_sanim_utils.c b/src/test_sanim_utils.c @@ -281,12 +281,24 @@ my_type_set_translation(struct my_type* t, const double translation[3]) { } res_T +my_type_get_translation(const struct my_type* t, double translation[3]) { + if (!t || !translation) return RES_BAD_ARG; + return sanim_node_get_translation(&t->node, translation); +} + +res_T my_type_set_rotations(struct my_type* t, const double rotations[3]) { if (!t || !rotations) return RES_BAD_ARG; return sanim_node_set_rotations(&t->node, rotations); } res_T +my_type_get_rotations(const struct my_type* t, double rotations[3]) { + if (!t || !rotations) return RES_BAD_ARG; + return sanim_node_get_rotations(&t->node, rotations); +} + +res_T my_type_get_transform(struct my_type* t, double transform[12]) { if (!t || !transform) return RES_BAD_ARG; return sanim_node_get_transform(&t->node, transform); diff --git a/src/test_sanim_utils.h b/src/test_sanim_utils.h @@ -64,9 +64,15 @@ res_T my_type_set_translation(struct my_type* t, const double translation[3]); res_T +my_type_get_translation(const struct my_type* t, double translation[3]); + +res_T my_type_set_rotations(struct my_type* t, const double rotations[3]); res_T +my_type_get_rotations(const struct my_type* t, double rotations[3]); + +res_T my_type_get_transform(struct my_type* t, double transform[12]); res_T