From 3b050105936978d1f125743acd551b31b0562020 Mon Sep 17 00:00:00 2001 From: MayNL Date: Tue, 5 May 2026 23:39:11 -0400 Subject: [PATCH] Added tools to custom skin editor --- .../Forms/Editor/CustomSkinEditor.Designer.cs | 1 + PCK-Studio/Forms/Editor/CustomSkinEditor.cs | 5 ++ PCK-Studio/Forms/Editor/CustomSkinEditor.resx | 4 +- PCK-Studio/Properties/Resources.Designer.cs | 10 ++++ PCK-Studio/Properties/Resources.resx | 3 ++ PCK-Studio/Rendering/SkinRenderer.cs | 46 +++++++++++++++--- PCK-Studio/Resources/tools.png | Bin 0 -> 1137 bytes 7 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 PCK-Studio/Resources/tools.png diff --git a/PCK-Studio/Forms/Editor/CustomSkinEditor.Designer.cs b/PCK-Studio/Forms/Editor/CustomSkinEditor.Designer.cs index 4e235dba..74cc6659 100644 --- a/PCK-Studio/Forms/Editor/CustomSkinEditor.Designer.cs +++ b/PCK-Studio/Forms/Editor/CustomSkinEditor.Designer.cs @@ -203,6 +203,7 @@ this.showToolsCheckBox.Name = "showToolsCheckBox"; this.showToolsCheckBox.Theme = MetroFramework.MetroThemeStyle.Dark; this.showToolsCheckBox.UseSelectable = true; + this.showToolsCheckBox.CheckedChanged += new System.EventHandler(this.showToolsCheckBox_CheckedChanged); // // skinNameLabel // diff --git a/PCK-Studio/Forms/Editor/CustomSkinEditor.cs b/PCK-Studio/Forms/Editor/CustomSkinEditor.cs index 78ea1124..c5b1f396 100644 --- a/PCK-Studio/Forms/Editor/CustomSkinEditor.cs +++ b/PCK-Studio/Forms/Editor/CustomSkinEditor.cs @@ -331,6 +331,11 @@ namespace PckStudio.Forms.Editor renderer3D1.ShowArmor = showArmorCheckbox.Checked; } + private void showToolsCheckBox_CheckedChanged(object sender, EventArgs e) + { + renderer3D1.ShowTools = showToolsCheckBox.Checked; + } + private void skinPartListBox_KeyUp(object sender, KeyEventArgs e) { switch (e.KeyCode) diff --git a/PCK-Studio/Forms/Editor/CustomSkinEditor.resx b/PCK-Studio/Forms/Editor/CustomSkinEditor.resx index 01a5733d..455e68fd 100644 --- a/PCK-Studio/Forms/Editor/CustomSkinEditor.resx +++ b/PCK-Studio/Forms/Editor/CustomSkinEditor.resx @@ -566,7 +566,7 @@ 0, 0 - 157, 128 + 157, 113 0 @@ -587,7 +587,7 @@ 4, 38 - 157, 128 + 157, 113 1 diff --git a/PCK-Studio/Properties/Resources.Designer.cs b/PCK-Studio/Properties/Resources.Designer.cs index 992038ff..d35cd56f 100644 --- a/PCK-Studio/Properties/Resources.Designer.cs +++ b/PCK-Studio/Properties/Resources.Designer.cs @@ -1125,6 +1125,16 @@ namespace PckStudio.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap tools { + get { + object obj = ResourceManager.GetObject("tools", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/PCK-Studio/Properties/Resources.resx b/PCK-Studio/Properties/Resources.resx index dcec626b..ac42842f 100644 --- a/PCK-Studio/Properties/Resources.resx +++ b/PCK-Studio/Properties/Resources.resx @@ -427,4 +427,7 @@ ..\Resources\iconImageList\empty.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\tools.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/PCK-Studio/Rendering/SkinRenderer.cs b/PCK-Studio/Rendering/SkinRenderer.cs index dc09a792..25e77c06 100644 --- a/PCK-Studio/Rendering/SkinRenderer.cs +++ b/PCK-Studio/Rendering/SkinRenderer.cs @@ -114,6 +114,7 @@ namespace PckStudio.Rendering public bool CenterOnSelect { get; set; } = false; public bool ShowBoundingBox { get; set; } public bool ShowArmor { get; set; } = false; + public bool ShowTools { get; set; } = false; public bool Animate { get; set; } = true; public bool RenderCape { get; set; } = true; public bool ShowGuideLines @@ -202,6 +203,7 @@ namespace PckStudio.Rendering private Texture2D skinTexture; private Texture2D capeTexture; private Texture2D armorTexture; + private Texture2D toolsTexture; private DrawContext _cubicalDrawContext; private DrawContext _skeletonDrawContext; @@ -221,6 +223,8 @@ namespace PckStudio.Rendering private CubeMeshCollection leftArm; private CubeMeshCollection rightLeg; private CubeMeshCollection leftLeg; + private CubeMeshCollection tool0; + private CubeMeshCollection tool1; private float animationCurrentRotationAngle; private float animationRotationSpeed = 16f; @@ -370,12 +374,18 @@ namespace PckStudio.Rendering var pants1 = new CubeMeshCollection("PANTS1", leftLeg.Translation, leftLeg.Pivot); pants1.Add(new(-2, 0, -2), new(4, 12, 4), new(0, 48), inflate: armorInflation, mirrorTexture: true); - var boot0 = new CubeMeshCollection("BOOT0", rightLeg.Translation, rightLeg.Pivot); + var boot0 = new CubeMeshCollection("BOOT0", rightLeg.Translation, rightLeg.Pivot); boot0.Add(new(-2, 0, -2), new(4, 12, 4), new(0, 16), inflate: armorInflation + 0.25f); - var boot1 = new CubeMeshCollection("BOOT1", leftLeg.Translation, leftLeg.Pivot); + var boot1 = new CubeMeshCollection("BOOT1", leftLeg.Translation, leftLeg.Pivot); boot1.Add(new(-2, 0, -2), new(4, 12, 4), new(0, 16), inflate: armorInflation + 0.25f, mirrorTexture: true); + // Tool boxes handled by UpdateANIM method - May + tool0 = new CubeMeshCollection("TOOL0", rightArm.Translation, rightArm.Pivot); + tool0.Add(new(0), new(0), new(0)); + tool1 = new CubeMeshCollection("TOOL1", leftArm.Translation, leftArm.Pivot); + tool1.Add(new(0), new(0), new(0)); + offsetSpecificMeshStorage = new Dictionary { { helmet.Name, helmet }, @@ -386,12 +396,10 @@ namespace PckStudio.Rendering { pants0.Name, pants0 }, { pants1.Name, pants1 }, { boot0.Name, boot0 }, - { boot1.Name, boot1 } + { boot1.Name, boot1 }, + { tool0.Name, tool0 }, + { tool1.Name, tool1 }, }; - - //// TODO - //{ "TOOL0" , new CubeGroupMesh("TOOL0") }, - //{ "TOOL1" , new CubeGroupMesh("TOOL1") }, } private void InitializeShaders() @@ -423,6 +431,16 @@ namespace PckStudio.Rendering armorTexture.SetTexture(Resources.armor); GLErrorCheck(); + toolsTexture = new Texture2D(); + toolsTexture.PixelFormat = OpenTK.Graphics.OpenGL.PixelFormat.Bgra; + toolsTexture.InternalPixelFormat = PixelInternalFormat.Rgba8; + toolsTexture.MinFilter = TextureMinFilter.Nearest; + toolsTexture.MagFilter = TextureMagFilter.Nearest; + toolsTexture.WrapS = TextureWrapMode.Repeat; + toolsTexture.WrapT = TextureWrapMode.Repeat; + toolsTexture.SetTexture(Resources.tools); + GLErrorCheck(); + capeTexture = new Texture2D(); capeTexture.PixelFormat = OpenTK.Graphics.OpenGL.PixelFormat.Bgra; capeTexture.InternalPixelFormat = PixelInternalFormat.Rgba8; @@ -728,6 +746,9 @@ namespace PckStudio.Rendering bool slim = ANIM.GetFlag(SkinAnimFlag.SLIM_MODEL); + tool0.ReplaceCube(0, new(slim ? -0.75f : -1.75f, -5.35f, -18.35f), new(0, 16, 16), new(0, -16)); + tool1.ReplaceCube(0, new(slim ? 0.75f : 1.75f, -5.35f, -18.35f), new(0, 16, 16), new(0, -16)); + head.FlipZMapping = true; if (slim || ANIM.GetFlag(SkinAnimFlag.MODERN_WIDE_MODEL)) { @@ -968,6 +989,17 @@ namespace PckStudio.Rendering RenderPart(cubeShader, offsetSpecificMeshStorage["WAIST"], Matrix4.Identity, renderTransform); } + if(ShowTools) + { + toolsTexture.Bind(); + cubeShader.SetUniform2("TexSize", Resources.tools.Size); + + Matrix4 handheldRotation = Matrix4.CreateRotationX(MathHelper.DegreesToRadians(45f)); + + RenderPart(cubeShader, offsetSpecificMeshStorage["TOOL0"], armRightMatrix * handheldRotation, renderTransform); + RenderPart(cubeShader, offsetSpecificMeshStorage["TOOL1"], armLeftMatrix * handheldRotation, renderTransform); + } + if (showWireFrame) GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); diff --git a/PCK-Studio/Resources/tools.png b/PCK-Studio/Resources/tools.png new file mode 100644 index 0000000000000000000000000000000000000000..0423910593114e2c9c0fcdbfbe4d34219e6d11bb GIT binary patch literal 1137 zcmV-%1djWOP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!T}W@c8BWE9&P!1S9q`)ZUcC*8Tflwc=l+^?oeGY%nHp4t!At){||ru>WXPp0Z6&s`L;QUQVkps5voD1;1UUO zB#sj?4rs}Vk{3!z)RKEJwP02;Gu+z;;W4PBs-&vKpz{3H)tySXH_QyPdh55AOesfZ zPQ3*s^_Nl$r5d?3%$zX_%LlTX#wf-BI)P3Y1JfAq1hM4iV-(DsTpFcXXXJEbE@&;O zXIzVWYYvVG#31aKyYLWHa#bXZgken>)<_u1RS6%c#C~ZWgCGLncx!I8c&|o6t@hCZ zINPph4d0wZQt>GZo0CXu_}O*^K(mU~f={CS=4z*Uiy8;&3nZ~~%zzMXK~6H;!dawmvCud`pAZ+LUH5ESVZX=qeu zjIf@423Pw?ZF2P!&>f2YBc6 ztIyZ6X%Rz;#JaTpk;HF3I!jvoWi@-;QxP|{2-h1wde^*+QPGDhKK z3VgH<{PxG}Prv(wmzQsQLht(X^71VYPe-}FsT_`iYt0dmpe{pzVGzbai9rb=5P}{p z5Q8!f$}k8+fS@h{(vHGBWaIj#^6+$&mzQt3INt#8RRCZ$sx>zZCb3i1L^Hi6;%4|`i}W8L`w>DJCfS&00000NkvXXu0mjf DEJYGU literal 0 HcmV?d00001