private void GetSkeleton() { if (bHasAnimation) { SkeletonRoot = new LoaderSkeletonParentBone(); Int32 boneIdCounter = 0; Node rootNode = m_scene.RootNode.FindNode(GetSkeletonArmatureNode(m_scene.RootNode)); if (rootNode != null) { foreach (var node in rootNode.Children) { var bone = GetBoneByName(node.Name); if (bone != null) { LoaderSkeletonBone skeletonBone = new LoaderSkeletonBone(SkeletonRoot); skeletonBone.SetBoneId(boneIdCounter++); skeletonBone.SetBoneInfo(bone); FillHierarchyRecursive(node, skeletonBone, ref boneIdCounter); SkeletonRoot.AddChildBone(skeletonBone); } } } } }
private void FillHierarchyRecursive(Node parentNode, LoaderSkeletonBone parentBone, ref Int32 boneIdCounter) { if (parentNode.HasChildren) { foreach (Node child in parentNode.Children) { LoaderSkeletonBone childBone = new LoaderSkeletonBone(parentBone); parentBone.AddChildBone(childBone); var boneInfo = GetBoneByName(child.Name); childBone.SetBoneInfo(boneInfo); childBone.SetBoneId(boneIdCounter++); FillHierarchyRecursive(child, childBone, ref boneIdCounter); } } }
public Int32 GetIdByBone(Bone seekBone, LoaderSkeletonBone currentSkeletonBone) { Int32 id = -1; if (currentSkeletonBone.GetBoneInfo().Name == seekBone.Name) { id = currentSkeletonBone.GetBoneId(); } if (id < 0) { foreach (var skeletonBone in currentSkeletonBone.GetChildren()) { id = skeletonBone.GetIdByBone(seekBone, skeletonBone); if (id > 0) { return(id); } } } return(id); }
public void AddChildBone(LoaderSkeletonBone child) { m_children.Add(child); }