From 0cabf9115b6e2e6108daa36b03f579088b4c77a1 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sun, 12 May 2024 14:48:29 +0200 Subject: [PATCH] Add ModelPartSpecifics.cs --- PCK-Studio/Internal/ModelPartSpecifics.cs | 32 +++++++++++++++++++++++ PCK-Studio/PckStudio.csproj | 1 + PCK-Studio/Rendering/SkinRenderer.cs | 12 ++++++--- 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 PCK-Studio/Internal/ModelPartSpecifics.cs diff --git a/PCK-Studio/Internal/ModelPartSpecifics.cs b/PCK-Studio/Internal/ModelPartSpecifics.cs new file mode 100644 index 00000000..f974b521 --- /dev/null +++ b/PCK-Studio/Internal/ModelPartSpecifics.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; +using System.Text; +using System.Threading.Tasks; +using PckStudio.Extensions; + +namespace PckStudio.Internal +{ + internal static class ModelPartSpecifics + { + private static Dictionary posisioningInfos = new Dictionary() + { + ["HEAD"] = new PositioningInfo(), + ["BODY"] = new PositioningInfo(), + ["ARM0"] = new PositioningInfo(new(-5f, -2f, 0f), new( 4f, 2f, 0f)), + ["ARM1"] = new PositioningInfo(new( 5f, -2f, 0f), new(-4f, 2f, 0f)), + ["LEG0"] = new PositioningInfo(new(-2f, -12f, 0f), new(-2f, 12f, 0f)), + ["LEG1"] = new PositioningInfo(new( 2f, -12f, 0f), new( 2f, 12f, 0f)), + }; + + internal record struct PositioningInfo(Vector3 Translation, Vector3 Pivot); + + internal static PositioningInfo GetPositioningInfo(string partName) + { + if (SkinBOX.IsOverlayPart(partName)) + partName = SkinBOXExtensions.GetBaseType(partName); + return posisioningInfos.ContainsKey(partName) ? posisioningInfos[partName] : default; + } + } +} diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index b5124c39..67da5984 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -149,6 +149,7 @@ + diff --git a/PCK-Studio/Rendering/SkinRenderer.cs b/PCK-Studio/Rendering/SkinRenderer.cs index fb00c045..0d06d361 100644 --- a/PCK-Studio/Rendering/SkinRenderer.cs +++ b/PCK-Studio/Rendering/SkinRenderer.cs @@ -332,19 +332,23 @@ namespace PckStudio.Rendering body.AddCube(new(-4, 0, -2), new(8, 12, 4), new(16, 16)); body.AddCube(new(-4, 0, -2), new(8, 12, 4), new(16, 32), OverlayScale); - rightArm ??= new CubeGroupMesh("Right Arm", new Vector3(-5f, -2f, 0f), new Vector3(4f, 2f, 0f)); + var rightArmInfo = ModelPartSpecifics.GetPositioningInfo("ARM0"); + rightArm ??= new CubeGroupMesh("Right Arm", rightArmInfo.Translation.ToOpenTKVector(), rightArmInfo.Pivot.ToOpenTKVector()); rightArm.AddCube(new(-3, -2, -2), new(4, 12, 4), new(40, 16)); rightArm.AddCube(new(-3, -2, -2), new(4, 12, 4), new(40, 32), OverlayScale); - leftArm ??= new CubeGroupMesh("Left Arm", new Vector3(5f, -2f, 0f), new Vector3(-4f, 2f, 0f)); + var leftArmInfo = ModelPartSpecifics.GetPositioningInfo("ARM1"); + leftArm ??= new CubeGroupMesh("Left Arm", leftArmInfo.Translation.ToOpenTKVector(), leftArmInfo.Pivot.ToOpenTKVector()); leftArm.AddCube(new(-1, -2, -2), new(4, 12, 4), new(32, 48)); leftArm.AddCube(new(-1, -2, -2), new(4, 12, 4), new(48, 48), inflate: OverlayScale); - rightLeg ??= new CubeGroupMesh("Right Leg", new Vector3(-2f, -12f, 0f), new Vector3(-2f, 12f, 0f)); + var rightLegInfo = ModelPartSpecifics.GetPositioningInfo("LEG0"); + rightLeg ??= new CubeGroupMesh("Right Leg", rightLegInfo.Translation.ToOpenTKVector(), rightLegInfo.Pivot.ToOpenTKVector()); rightLeg.AddCube(new(-2, 0, -2), new(4, 12, 4), new(0, 16)); rightLeg.AddCube(new(-2, 0, -2), new(4, 12, 4), new(0, 32), OverlayScale); - leftLeg ??= new CubeGroupMesh("Left Leg", new Vector3(2f, -12f, 0f), new Vector3(2f, 12f, 0f)); + var leftLegInfo = ModelPartSpecifics.GetPositioningInfo("LEG1"); + leftLeg ??= new CubeGroupMesh("Left Leg", leftLegInfo.Translation.ToOpenTKVector(), leftLegInfo.Pivot.ToOpenTKVector()); leftLeg.AddCube(new(-2, 0, -2), new(4, 12, 4), new(16, 48)); leftLeg.AddCube(new(-2, 0, -2), new(4, 12, 4), new(0, 48), OverlayScale); }