libanim
diff example/test.c @ 60:8f7193d00555
set/get currently active animation name and minor enhancements in the example
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 27 Dec 2013 11:29:42 +0200 |
parents | 9758004136f8 |
children | 09e267e7ed4a |
line diff
1.1 --- a/example/test.c Fri Dec 27 10:58:23 2013 +0200 1.2 +++ b/example/test.c Fri Dec 27 11:29:42 2013 +0200 1.3 @@ -128,6 +128,7 @@ 1.4 int i; 1.5 1.6 anm_use_animation(root, idx); 1.7 + anm_set_active_animation_name(root, "walk"); 1.8 1.9 for(i=0; i<NUM_NODES; i++) { 1.10 anm_set_position(nodes[i], parts[i].pos, 0); 1.11 @@ -192,6 +193,7 @@ 1.12 int i; 1.13 1.14 anm_use_animation(root, idx); 1.15 + anm_set_active_animation_name(root, "jump"); 1.16 1.17 for(i=0; i<NUM_NODES; i++) { 1.18 anm_set_position(nodes[i], parts[i].pos, 0); 1.19 @@ -251,9 +253,14 @@ 1.20 glRotatef(cam_phi, 1, 0, 0); 1.21 glRotatef(cam_theta, 0, 1, 0); 1.22 1.23 + /* animation blending if we're in transition */ 1.24 if(cur_anim != next_anim) { 1.25 float t = (msec - trans_start_tm) / 1500.0; 1.26 1.27 + struct anm_animation *from, *to; 1.28 + from = anm_get_animation(root, cur_anim); 1.29 + to = anm_get_animation(root, next_anim); 1.30 + 1.31 if(t >= 1.0) { 1.32 t = 1.0; 1.33 cur_anim = next_anim; 1.34 @@ -261,6 +268,12 @@ 1.35 } else { 1.36 anm_use_animations(root, cur_anim, next_anim, t); 1.37 } 1.38 + 1.39 + printf("transitioning from \"%s\" to \"%s\": %.2f \r", from->name, to->name, t); 1.40 + if(cur_anim == next_anim) { 1.41 + putchar('\n'); 1.42 + } 1.43 + fflush(stdout); 1.44 } 1.45 1.46 /* first render a character with bottom-up lazy matrix calculation */