internal PrettySkeleton([NotNull] Skeleton skeleton) { var nodeCount = skeleton.m_Node.Length; Debug.Assert(nodeCount == skeleton.m_ID.Length); var ids = new uint[nodeCount]; for (var i = 0; i < nodeCount; i += 1) { ids[i] = skeleton.m_ID[i]; } var nodes = new SkeletonNode[nodeCount]; for (var i = 0; i < nodeCount; i += 1) { var n = skeleton.m_Node[i]; nodes[i] = new SkeletonNode(n.m_ParentId, n.m_AxesId); } _nodes = nodes; _nodeIDs = ids; }
private static PrettySkeleton CombineSkeletons([NotNull, ItemNotNull] IEnumerable <PrettySkeleton> skeletons) { var nodeIDList = new List <uint>(); var nodeList = new List <SkeletonNode>(); var nodeStart = 0; var counter = 0; foreach (var skeleton in skeletons) { Debug.Assert(skeleton.NodeIDs.Length == skeleton.Nodes.Length); var nodeCount = skeleton.NodeIDs.Length; foreach (var id in skeleton.NodeIDs) { if (id == 0) { if (nodeIDList.Count == 0) { nodeIDList.Add(id); } } else { nodeIDList.Add(id); } } var isFirstNode = true; foreach (var node in skeleton.Nodes) { if (isFirstNode) { if (nodeList.Count > 0) { isFirstNode = false; continue; } } int parentIndex; if (counter == 0) { parentIndex = node.ParentIndex; } else { if (node.ParentIndex <= 0) { parentIndex = node.ParentIndex; } else { parentIndex = node.ParentIndex + nodeStart - 1; } } var n = new SkeletonNode(parentIndex, node.AxisIndex); nodeList.Add(n); isFirstNode = false; } if (counter == 0) { nodeStart += nodeCount; } else { // From the second time, "" (empty name) bone is filtered out because it will duplicate. nodeStart += nodeCount - 1; } ++counter; } var result = new PrettySkeleton(nodeList.ToArray(), nodeIDList.ToArray()); return(result); }