protected void getChildren(ModelBone parent, ref ModelBoneCollection list) { foreach (var child in parent.children) { list.Add(child); child.getChildren(child, ref list); } }
public ModelBoneCollection AllChildren(bool bIncludeSelf = true) { var childs = new ModelBoneCollection(); if (bIncludeSelf) { childs.Add(this); } getChildren(this, ref childs); return(childs); }
public int AddMesh(ModelMesh mesh, int ParentBoneIndex = 0) { bool bAddBone = true; ModelBone b = new ModelBone(); b.Index = -1; if (bones.Count > 0) { b.Parent = bones[ParentBoneIndex]; bones[ParentBoneIndex].Children.Add(b); int childBoneCount = countChildrenOf(ParentBoneIndex); if (ParentBoneIndex + childBoneCount < bones.Count) { int index = ParentBoneIndex + childBoneCount; bAddBone = false; bones.Insert(index, b); b.Index = index; } } if (bAddBone) { bones.Add(b); b.Index = bones.Count - 1; } else { bones.ReIndex(); } if (mesh != null) { b.Type = BoneType.Mesh; b.Attachment = mesh; mesh.Parent = bones[b.Index]; meshes.Add(mesh); } else { // Just a bone } return(b.Index); }