From 817c8faa7bfc42c0aa06eb749f0e154e3a70c133 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Tue, 20 Aug 2024 20:43:41 +0200 Subject: [PATCH] SkinModelImporter - Update 'AddBone' function inside 'ExportBedrockJson' --- PCK-Studio/Internal/SkinModelImporter.cs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/PCK-Studio/Internal/SkinModelImporter.cs b/PCK-Studio/Internal/SkinModelImporter.cs index dd30a9ce..f7944ede 100644 --- a/PCK-Studio/Internal/SkinModelImporter.cs +++ b/PCK-Studio/Internal/SkinModelImporter.cs @@ -328,23 +328,25 @@ namespace PckStudio.Internal Dictionary bones = new Dictionary(5); Dictionary offsetLookUp = new Dictionary(5); - void AddElement(SkinBOX box) + void AddBone(SkinBOX box) { - Vector3 offset = GetOffsetForPart(box.Type, ref offsetLookUp, modelInfo.PartOffsets); + string offsetType = box.IsOverlayPart() ? box.GetBaseType() : box.Type; - if (!bones.ContainsKey(box.Type)) + Vector3 offset = GetOffsetForPart(offsetType, ref offsetLookUp, modelInfo.PartOffsets); + + if (!bones.ContainsKey(offsetType)) { - Bone bone = new Bone(box.Type) + Bone bone = new Bone(offsetType) { - Pivot = GetSkinBoxPivot(box.Type, new Vector3(0, 1, 0)) + offset + Pivot = GetSkinBoxPivot(offsetType, new Vector3(0, 1, 0)) + offset }; - bones.Add(box.Type, bone); + bones.Add(offsetType, bone); } - Vector3 pivot = bones.ContainsKey(box.Type) ? bones[box.Type].Pivot : Vector3.Zero; + Vector3 pivot = bones.ContainsKey(offsetType) ? bones[offsetType].Pivot : Vector3.Zero; Vector3 pos = TranslateFromInternalPosistion(box, new Vector3(1, 1, 0)); pos = TransformSpace(pos, box.Size, new Vector3(1, 0, 0)); - bones[box.Type].Cubes.Add(new External.Format.Cube() + bones[offsetType].Cubes.Add(new External.Format.Cube() { Origin = pos + offset, Size = box.Size, @@ -354,11 +356,11 @@ namespace PckStudio.Internal }); } - ANIM2BOX(modelInfo.ANIM, AddElement); + ANIM2BOX(modelInfo.ANIM, AddBone); foreach (SkinBOX box in modelInfo.AdditionalBoxes) { - AddElement(box); + AddBone(box); } Geometry selectedGeometry = new Geometry();