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 00000000..04239105 Binary files /dev/null and b/PCK-Studio/Resources/tools.png differ