(bind-func ai_build_anim_channel
(lambda (node:aiNodeAnim* scene:aiScene* root:XTMModel*)
(println "...animNode:>" (tref-ptr node 0) "keyframes:" (tref node 1))
(let ((aires (ai_find_matching_node (tref scene 1) (tref-ptr node 0)))
(xtmres (xtm_find_bone root (toString (tref-ptr node 0)))))
(if (or (null? aires) (null? xtmres))
(begin (println ".....bone:> No bone found! " (tref-ptr node 0)) void)
(let ((aiparent (tref aires 2))
(parent:XTMBone* null)
(mat:float* (cast (tref-ptr aires 1)))
(newmat:float* (halloc 16)))
(memcpy (cast newmat i8*) (cast mat i8*) (* 4 16))
(tset! xtmres 2 newmat) ;; set transform matrix for xtmbone
(tset! xtmres 4 (tref aires 3)) ;; set num children for xtmbone
(xtm_bone_add_children xtmres aires root) ;; add children
(if (not (null? aiparent))
(set! parent (xtm_find_bone root (toString (tref-ptr aiparent 0)))))
(tset! xtmres 6 parent)
(println ".....bone:>" (tref-ptr aires 0) "parent:"
(if (null? parent) (Str "<null>") (tref parent 0))
"children:" (tref aires 3) "ptr:" (cast aires i8*))
void)))))