private void AssignParentToWeightedVertices(IVertexIncludingAttachment attachment, Bone[] bones) { foreach (VertexNode node in attachment.VertexCollection) { for (var i = 0; i < node.Count; i++) { if (node[i].Connected) { node[i] = new Vertex(node[i].BoneIndex, node[i].X, node[i].Y, node[i].Weight, BoneResolver.FindByIndex(bones, node[i].BoneIndex)); } } } }
public void AssignSlotDataToOther(SpineDocument document, Slot[] identical) { var other = document.Slots; document.Bones = Bones; var imageScale = CalculateImageSizeRatio(document.ActualWidth, document.ActualHeight); //BoneResolver.AdjustBonePositions(document.Bones, scale.X, scale.Y); for (int i = 0; i < identical.Length; i++) { for (int j = 0; j < other.Length; j++) { if (identical[i].Equals(other[j])) { var thisAttachment = identical[i].Attachment; var otherAttachment = other[j].Attachment; if (thisAttachment is IVertexIncludingAttachment thisMesh && otherAttachment is IVertexIncludingAttachment otherMesh) { var scale = CalculateAttachmentSizeRatio(thisMesh, otherMesh); BoneResolver.AdjustBonePositions(thisMesh.VertexCollection.GetRelativeBones(), scale.X, scale.Y, true); AssignVerticesToOther( thisMesh, otherMesh, scale); } else { AssignPositionToOther( (IVertexExcludingAttachment)thisAttachment, (IVertexExcludingAttachment)otherAttachment, imageScale); } } } }
public SpineDocument Deserialize() { using (_jsonDocument = JsonDocument.Parse(ReadFile())) { AssignJsonElements(); // Десериализация Skeleton skeletonObj = JsonSerializer.Deserialize <Skeleton>(GetRaw(_skeletonElement), _options); Bone[] boneArray = JsonSerializer.Deserialize <Bone[]> (GetRaw(_bonesElement), _options); Slot[] slots = JsonSerializer.Deserialize <Slot[]> (GetRaw(_slotsElement), _options); Skin[] skins = JsonSerializer.Deserialize <Skin[]> (GetRaw(_skinsElement), _options); object animations = JsonSerializer.Deserialize <object> (GetRaw(_animationsElement), _options); // Подстройка компонентов BoneResolver.AssignParentToBones(boneArray); SlotResolver.AssignBonesToSlots(boneArray, slots); CompileAttachmentForSlotsFromSkins(skins, slots); VerifyAttachmentInSlots(slots, boneArray); return(new SpineDocument(skeletonObj, boneArray, slots, skins, animations));; } }