(bind-func xtm_find_bone
(lambda (root:XTMModel* str:String*)
(let ((num_children (tref root 3))
(children (tref root 4))
(num_meshes (tref root 5))
(meshes (tref root 6))
(found:XTMBone* null)
(i 0) (j:i32 0))
(dotimes (i num_meshes)
(let ((mesh (pref meshes i))
(num_bones (tref mesh 12))
(bones (tref mesh 13)))
(dotimes (j num_bones)
(if (equal (tref (pref-ptr bones j) 0) str)
(set! found (pref-ptr bones j))))))
(set! i 0)
(while (and (null? found) (< i num_children))
(set! found (xtm_find_bone (pref-ptr children i) str))
(set! i (+ i 1)))
found)))