goat3dgfx
diff src/xform_node.cc @ 21:7c593721547f
integrated support for the multiple animation system of libanim
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 27 Dec 2013 11:59:32 +0200 |
parents | 7d6b667821cf |
children | 92bfb0206969 |
line diff
1.1 --- a/src/xform_node.cc Sun Dec 08 03:00:49 2013 +0200 1.2 +++ b/src/xform_node.cc Fri Dec 27 11:59:32 2013 +0200 1.3 @@ -90,6 +90,77 @@ 1.4 return 0; 1.5 } 1.6 1.7 + 1.8 +void XFormNode::use_animation(int idx) 1.9 +{ 1.10 + if(idx >= 0) { 1.11 + anm_use_animation(anm, idx); 1.12 + } 1.13 +} 1.14 + 1.15 +void XFormNode::use_animation(const char *name) 1.16 +{ 1.17 + anm_use_animation(anm, anm_find_animation(anm, name)); 1.18 +} 1.19 + 1.20 +void XFormNode::use_animation(int aidx, int bidx, float t) 1.21 +{ 1.22 + anm_use_animations(anm, aidx, bidx, t); 1.23 +} 1.24 + 1.25 +void XFormNode::use_animation(const char *aname, const char *bname, float t) 1.26 +{ 1.27 + int aidx = anm_find_animation(anm, aname); 1.28 + int bidx = anm_find_animation(anm, bname); 1.29 + 1.30 + if(aidx == -1) { 1.31 + use_animation(bidx); 1.32 + } 1.33 + if(bidx == -1) { 1.34 + use_animation(aidx); 1.35 + } 1.36 + anm_use_animations(anm, aidx, bidx, t); 1.37 +} 1.38 + 1.39 +int XFormNode::get_active_animation_index(int which) const 1.40 +{ 1.41 + return anm_get_active_animation_index(anm, which); 1.42 +} 1.43 + 1.44 +float XFormNode::get_active_animation_mix() const 1.45 +{ 1.46 + return anm_get_active_animation_mix(anm); 1.47 +} 1.48 + 1.49 +int XFormNode::get_animation_count() const 1.50 +{ 1.51 + return anm_get_animation_count(anm); 1.52 +} 1.53 + 1.54 +void XFormNode::add_animation(const char *name) 1.55 +{ 1.56 + int idx = get_animation_count(); 1.57 + 1.58 + anm_add_animation(anm); 1.59 + use_animation(idx); 1.60 + 1.61 + if(name) { 1.62 + set_animation_name(name); 1.63 + } 1.64 +} 1.65 + 1.66 +void XFormNode::set_animation_name(const char *name) 1.67 +{ 1.68 + anm_set_active_animation_name(anm, name); 1.69 +} 1.70 + 1.71 +const char *XFormNode::get_animation_name() const 1.72 +{ 1.73 + return anm_get_active_animation_name(anm); 1.74 +} 1.75 + 1.76 + 1.77 + 1.78 void XFormNode::set_position(const Vector3 &pos, long tmsec) 1.79 { 1.80 anm_set_position(anm, v3_cons(pos.x, pos.y, pos.z), ANM_MSEC2TM(tmsec));