private void ConvertNodeTree(Transform bone, NullNodeTree nodeTree, Matrix4x4[] bindposes, Transform[] bones) { int index = GetBoneIndex(bones, bone); if (index == -1) { return; } nodeTree.SetNodeHandle(index); nodeTree.SetNodeName(bone.name); nodeTree.SetPosition(bindposes[index].GetColumn(3)); nodeTree.SetQuaternion(bindposes[index].rotation); int childCount = bone.childCount; for (int i = 0; i < childCount; ++i) { Transform child = bone.GetChild(i); NullNodeTree childNode = new NullNodeTree(); childNode.SetNodeHandle(-1); ConvertNodeTree(child, childNode, bindposes, bones); if (childNode.GetNodeHandle() != -1) { nodeTree.Children.Add(childNode); } } }
public void FindNodeRecursive(NullNodeTree node, int boneId, ref NullNodeTree result) { if (result != null) { return; } if (node.GetNodeHandle() == boneId) { result = node; return; } for (int i = 0; i < node.GetChildrenCount(); i++) { FindNodeRecursive(node[i], boneId, ref result); if (result != null) { break; } } }