From ae074b63d0d4e8b4cba6bc58142309bbeda901ab Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:28:51 +0100 Subject: [PATCH] CustomSkinEditor - Implemented Box editing --- .../CustomSkinEditor.Designer.cs | 83 ++++-- .../Skins-And-Textures/CustomSkinEditor.cs | 70 +++-- .../Skins-And-Textures/CustomSkinEditor.resx | 252 ++++++++++++++---- .../{ModelOffset.cs => SkinPartOffset.cs} | 25 +- PCK-Studio/PckStudio.csproj | 2 +- PCK-Studio/Rendering/SkinRenderer.cs | 19 +- 6 files changed, 325 insertions(+), 126 deletions(-) rename PCK-Studio/Internal/{ModelOffset.cs => SkinPartOffset.cs} (77%) diff --git a/PCK-Studio/Forms/Skins-And-Textures/CustomSkinEditor.Designer.cs b/PCK-Studio/Forms/Skins-And-Textures/CustomSkinEditor.Designer.cs index d0463cac..090ff8ae 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/CustomSkinEditor.Designer.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/CustomSkinEditor.Designer.cs @@ -34,7 +34,7 @@ System.Windows.Forms.Label label3; System.Windows.Forms.Label label7; System.Windows.Forms.Label labelTextureMappingPreview; - PckStudio.Internal.SkinANIM skinANIM1 = new PckStudio.Internal.SkinANIM(); + PckStudio.Internal.SkinANIM skinANIM2 = new PckStudio.Internal.SkinANIM(); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.createToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.cloneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -57,12 +57,17 @@ this.PosZUpDown = new System.Windows.Forms.NumericUpDown(); this.PosYUpDown = new System.Windows.Forms.NumericUpDown(); this.PosXUpDown = new System.Windows.Forms.NumericUpDown(); - this.modelPartListBox = new System.Windows.Forms.ListBox(); + this.skinPartListBox = new System.Windows.Forms.ListBox(); this.clampToViewCheckbox = new MetroFramework.Controls.MetroCheckBox(); this.captureScreenshotButton = new MetroFramework.Controls.MetroButton(); this.showToolsCheckBox = new MetroFramework.Controls.MetroCheckBox(); this.renderer3D1 = new PckStudio.Rendering.SkinRenderer(); this.uvPictureBox = new PckStudio.ToolboxItems.InterpolationPictureBox(); + this.skinNameLabel = new MetroFramework.Controls.MetroLabel(); + this.metroTabControl1 = new MetroFramework.Controls.MetroTabControl(); + this.skinPartsTabPage = new System.Windows.Forms.TabPage(); + this.skinOffsetsTabPage = new System.Windows.Forms.TabPage(); + this.offsetListBox = new System.Windows.Forms.ListBox(); label5 = new System.Windows.Forms.Label(); label3 = new System.Windows.Forms.Label(); label7 = new System.Windows.Forms.Label(); @@ -77,6 +82,9 @@ ((System.ComponentModel.ISupportInitialize)(this.PosYUpDown)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.PosXUpDown)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.uvPictureBox)).BeginInit(); + this.metroTabControl1.SuspendLayout(); + this.skinPartsTabPage.SuspendLayout(); + this.skinOffsetsTabPage.SuspendLayout(); this.SuspendLayout(); // // label5 @@ -300,15 +308,15 @@ -2147483648}); this.PosXUpDown.Name = "PosXUpDown"; // - // modelPartListBox + // skinPartListBox // - this.modelPartListBox.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.modelPartListBox.ContextMenuStrip = this.contextMenuStrip1; - this.modelPartListBox.FormattingEnabled = true; - resources.ApplyResources(this.modelPartListBox, "modelPartListBox"); - this.modelPartListBox.Name = "modelPartListBox"; - this.modelPartListBox.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged); - this.modelPartListBox.DoubleClick += new System.EventHandler(this.listBox1_DoubleClick); + this.skinPartListBox.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.skinPartListBox.ContextMenuStrip = this.contextMenuStrip1; + resources.ApplyResources(this.skinPartListBox, "skinPartListBox"); + this.skinPartListBox.FormattingEnabled = true; + this.skinPartListBox.Name = "skinPartListBox"; + this.skinPartListBox.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged); + this.skinPartListBox.DoubleClick += new System.EventHandler(this.listBox1_DoubleClick); // // clampToViewCheckbox // @@ -337,10 +345,11 @@ // renderer3D1 // resources.ApplyResources(this.renderer3D1, "renderer3D1"); - this.renderer3D1.ANIM = skinANIM1; + this.renderer3D1.ANIM = skinANIM2; this.renderer3D1.BackColor = System.Drawing.Color.DimGray; this.renderer3D1.ClampModel = false; this.renderer3D1.Name = "renderer3D1"; + this.renderer3D1.RefreshRate = 50; this.renderer3D1.Texture = null; this.renderer3D1.VSync = true; this.renderer3D1.TextureChanging += new System.EventHandler(this.renderer3D1_TextureChanging); @@ -353,14 +362,50 @@ this.uvPictureBox.Name = "uvPictureBox"; this.uvPictureBox.TabStop = false; // - // CustomModelEditor + // skinNameLabel + // + resources.ApplyResources(this.skinNameLabel, "skinNameLabel"); + this.skinNameLabel.Name = "skinNameLabel"; + this.skinNameLabel.Theme = MetroFramework.MetroThemeStyle.Dark; + // + // metroTabControl1 + // + resources.ApplyResources(this.metroTabControl1, "metroTabControl1"); + this.metroTabControl1.Controls.Add(this.skinPartsTabPage); + this.metroTabControl1.Controls.Add(this.skinOffsetsTabPage); + this.metroTabControl1.Name = "metroTabControl1"; + this.metroTabControl1.SelectedIndex = 0; + this.metroTabControl1.Style = MetroFramework.MetroColorStyle.Pink; + this.metroTabControl1.Theme = MetroFramework.MetroThemeStyle.Dark; + this.metroTabControl1.UseSelectable = true; + // + // skinPartsTabPage + // + resources.ApplyResources(this.skinPartsTabPage, "skinPartsTabPage"); + this.skinPartsTabPage.Controls.Add(this.skinPartListBox); + this.skinPartsTabPage.Name = "skinPartsTabPage"; + // + // skinOffsetsTabPage + // + this.skinOffsetsTabPage.Controls.Add(this.offsetListBox); + resources.ApplyResources(this.skinOffsetsTabPage, "skinOffsetsTabPage"); + this.skinOffsetsTabPage.Name = "skinOffsetsTabPage"; + // + // offsetListBox + // + resources.ApplyResources(this.offsetListBox, "offsetListBox"); + this.offsetListBox.FormattingEnabled = true; + this.offsetListBox.Name = "offsetListBox"; + // + // CustomSkinEditor // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.metroTabControl1); + this.Controls.Add(this.skinNameLabel); this.Controls.Add(this.showToolsCheckBox); this.Controls.Add(this.captureScreenshotButton); this.Controls.Add(this.clampToViewCheckbox); - this.Controls.Add(this.modelPartListBox); this.Controls.Add(this.renderer3D1); this.Controls.Add(this.PosZUpDown); this.Controls.Add(this.PosYUpDown); @@ -384,7 +429,7 @@ this.Controls.Add(label3); this.Controls.Add(label5); this.Controls.Add(this.uvPictureBox); - this.Name = "CustomModelEditor"; + this.Name = "CustomSkinEditor"; this.Style = MetroFramework.MetroColorStyle.Silver; this.Theme = MetroFramework.MetroThemeStyle.Dark; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.generateModel_FormClosing); @@ -398,6 +443,9 @@ ((System.ComponentModel.ISupportInitialize)(this.PosYUpDown)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.PosXUpDown)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.uvPictureBox)).EndInit(); + this.metroTabControl1.ResumeLayout(false); + this.skinPartsTabPage.ResumeLayout(false); + this.skinOffsetsTabPage.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -428,9 +476,14 @@ private System.Windows.Forms.NumericUpDown PosYUpDown; private System.Windows.Forms.NumericUpDown PosXUpDown; private Rendering.SkinRenderer renderer3D1; - private System.Windows.Forms.ListBox modelPartListBox; + private System.Windows.Forms.ListBox skinPartListBox; private MetroFramework.Controls.MetroCheckBox clampToViewCheckbox; private MetroFramework.Controls.MetroButton captureScreenshotButton; private MetroFramework.Controls.MetroCheckBox showToolsCheckBox; + private MetroFramework.Controls.MetroLabel skinNameLabel; + private MetroFramework.Controls.MetroTabControl metroTabControl1; + private System.Windows.Forms.TabPage skinPartsTabPage; + private System.Windows.Forms.TabPage skinOffsetsTabPage; + private System.Windows.Forms.ListBox offsetListBox; } } \ No newline at end of file diff --git a/PCK-Studio/Forms/Skins-And-Textures/CustomSkinEditor.cs b/PCK-Studio/Forms/Skins-And-Textures/CustomSkinEditor.cs index d4a3934e..4beb4dd9 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/CustomSkinEditor.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/CustomSkinEditor.cs @@ -25,14 +25,15 @@ namespace PckStudio.Forms private PckFileData _file; + private BindingSource skinPartListBindingSource; + private BindingSource skinOffsetListBindingSource; + private static GraphicsConfig _graphicsConfig = new GraphicsConfig() { InterpolationMode = InterpolationMode.NearestNeighbor, PixelOffsetMode = PixelOffsetMode.HighQuality, }; - List modelOffsets = new List(); - public CustomSkinEditor(PckFileData file) { InitializeComponent(); @@ -50,15 +51,23 @@ namespace PckStudio.Forms { renderer3D1.ANIM = properties.GetPropertyValue("ANIM", SkinANIM.FromString); var boxProperties = properties.GetProperties("BOX"); + var offsetProperties = properties.GetProperties("OFFSETS"); + + skinNameLabel.Text = properties.HasProperty("DISPLAYNAME") ? properties.GetPropertyValue("DISPLAYNAME") : ""; Array.ForEach(boxProperties, kv => renderer3D1.ModelData.Add(SkinBOX.FromString(kv.Value))); + Array.ForEach(offsetProperties, kv => renderer3D1.SetPartOffset(SkinPartOffset.FromString(kv.Value))); - modelPartListBox.DataSource = renderer3D1.ModelData; - modelPartListBox.DisplayMember = "Type"; + skinPartListBindingSource = new BindingSource(renderer3D1.ModelData, null); + skinPartListBox.DataSource = skinPartListBindingSource; + skinPartListBox.DisplayMember = "Type"; - Array.ForEach(properties.GetProperties("OFFSET"), kv => renderer3D1.SetPartOffset(ModelOffset.FromString(kv.Value))); + skinOffsetListBindingSource = new BindingSource(renderer3D1.PartOffsets, null); + offsetListBox.DataSource = skinOffsetListBindingSource; + //offsetListBox.DisplayMember = "" } + // TODO private void GenerateUVTextureMap() { Random rng = new Random(); @@ -90,22 +99,22 @@ namespace PckStudio.Forms { var boxEditor = new BoxEditor(SkinBOX.Empty, false); if (boxEditor.ShowDialog() == DialogResult.OK) + { renderer3D1.ModelData.Add(boxEditor.Result); + skinPartListBindingSource.ResetBindings(false); + } } - //Export Current Skin Texture private void buttonEXPORT_Click(object sender, EventArgs e) { - Bitmap bitmap = new Bitmap(uvPictureBox.BackgroundImage, 64, 64); using SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "PNG Image Files | *.png"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { - bitmap.Save(saveFileDialog.FileName, ImageFormat.Png); + uvPictureBox.BackgroundImage.Save(saveFileDialog.FileName, ImageFormat.Png); } } - //Imports Skin Texture private void buttonIMPORT_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); @@ -116,15 +125,7 @@ namespace PckStudio.Forms { using (var img = Image.FromFile(openFileDialog.FileName)) { - if (img.Width == img.Height || img.Height == img.Width / 2) - { - generateTextureCheckBox.Checked = false; - renderer3D1.Texture = img; - } - else - { - MessageBox.Show(this, "Not a valid skin file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } + renderer3D1.Texture = img; } } } @@ -187,22 +188,25 @@ namespace PckStudio.Forms var UvY = reader.ReadLine(); renderer3D1.ModelData.Add(SkinBOX.FromString($"{part} {PosX} {PosY} {PosZ} {SizeX} {SizeY} {SizeZ} {UvX} {UvY}")); } + skinPartListBindingSource.ResetBindings(false); } } private void cloneToolStripMenuItem_Click(object sender, EventArgs e) { - if (modelPartListBox.SelectedItem is SkinBOX box) + if (skinPartListBox.SelectedItem is SkinBOX box) { renderer3D1.ModelData.Add((SkinBOX)box.Clone()); + skinPartListBindingSource.ResetBindings(false); } } private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { - if (modelPartListBox.SelectedItem is SkinBOX box) + if (skinPartListBox.SelectedItem is SkinBOX box) { renderer3D1.ModelData.Remove(box); + skinPartListBindingSource.ResetBindings(false); } } @@ -216,17 +220,6 @@ namespace PckStudio.Forms e.Cancel = false;*/ } - //Del stuff using key - private void delStuffUsingDelKey(object sender, KeyEventArgs e) - { - //if (e.KeyCode == Keys.Delete && listViewBoxes.SelectedItems.Count != 0 && - // listViewBoxes.SelectedItems[0].Tag is SkinBOX part) - //{ - // if (modelBoxes.Remove(part)) - // listViewBoxes.SelectedItems[0].Remove(); - //} - } - private void OpenJSONButton_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); @@ -320,35 +313,36 @@ namespace PckStudio.Forms MessageBox.Show("Invalid image dimensions.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } + generateTextureCheckBox.Checked = false; uvPictureBox.BackgroundImage = img; } private void listBox1_DoubleClick(object sender, EventArgs e) { - if (modelPartListBox.SelectedItem is SkinBOX box) + if (skinPartListBox.SelectedItem is SkinBOX box) { var boxEditor = new BoxEditor(box, false); if (boxEditor.ShowDialog() == DialogResult.OK) { - renderer3D1.ModelData[modelPartListBox.SelectedIndex] = boxEditor.Result; - modelPartListBox.Update(); + renderer3D1.ModelData[skinPartListBox.SelectedIndex] = boxEditor.Result; + skinPartListBindingSource.ResetItem(skinPartListBox.SelectedIndex); } } } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { - if (modelPartListBox.SelectedItem is SkinBOX box) + if (skinPartListBox.SelectedItem is SkinBOX box) { int scale = 3; uvPictureBox.Image = new Bitmap(uvPictureBox.BackgroundImage.Width * scale, uvPictureBox.BackgroundImage.Height * scale); using (Graphics g = Graphics.FromImage(uvPictureBox.Image)) { - float penWidth = renderer3D1.UvTranslation.X * uvPictureBox.BackgroundImage.Width + renderer3D1.UvTranslation.Y * uvPictureBox.BackgroundImage.Height / 2f; + float penWidth = uvPictureBox.BackgroundImage.Width / renderer3D1.TextureSize.Width + uvPictureBox.BackgroundImage.Height / renderer3D1.TextureSize.Height / 2f; GraphicsPath graphicsPath = box.GetUVGraphicsPath( new System.Numerics.Vector2( - scale * renderer3D1.UvTranslation.X * uvPictureBox.BackgroundImage.Width, - scale * renderer3D1.UvTranslation.Y * uvPictureBox.BackgroundImage.Height + scale * (1f / renderer3D1.TextureSize.Width) * uvPictureBox.BackgroundImage.Width, + scale * (1f / renderer3D1.TextureSize.Height) * uvPictureBox.BackgroundImage.Height ) ); g.DrawPath(new Pen(Color.HotPink, penWidth), graphicsPath); diff --git a/PCK-Studio/Forms/Skins-And-Textures/CustomSkinEditor.resx b/PCK-Studio/Forms/Skins-And-Textures/CustomSkinEditor.resx index b9fb72b5..d5936e57 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/CustomSkinEditor.resx +++ b/PCK-Studio/Forms/Skins-And-Textures/CustomSkinEditor.resx @@ -154,7 +154,7 @@ $this - 26 + 27 False @@ -190,7 +190,7 @@ $this - 25 + 26 False @@ -226,7 +226,7 @@ $this - 23 + 24 False @@ -262,11 +262,20 @@ $this - 21 + 22 17, 17 + + 152, 108 + + + contextMenuStrip1 + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO @@ -339,15 +348,6 @@ Change Color - - 152, 108 - - - contextMenuStrip1 - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Bottom, Right @@ -373,7 +373,7 @@ $this - 24 + 25 Top, Right @@ -400,7 +400,7 @@ $this - 20 + 21 Top, Right @@ -427,7 +427,7 @@ $this - 22 + 23 Bottom, Left @@ -457,7 +457,7 @@ $this - 19 + 20 Bottom, Left @@ -487,7 +487,7 @@ $this - 18 + 19 Bottom, Left @@ -517,7 +517,7 @@ $this - 17 + 18 Top, Right @@ -547,7 +547,7 @@ $this - 16 + 17 Top, Right @@ -577,7 +577,7 @@ $this - 15 + 16 Top, Right @@ -607,13 +607,13 @@ $this - 14 + 15 Top, Right - 685, 372 + 674, 371 53, 20 @@ -634,13 +634,13 @@ $this - 13 + 14 Top, Right - 744, 372 + 733, 371 53, 20 @@ -661,13 +661,13 @@ $this - 12 + 13 Top, Right - 803, 372 + 792, 371 58, 20 @@ -688,7 +688,7 @@ $this - 11 + 12 Top, Right @@ -712,7 +712,7 @@ $this - 10 + 11 Top, Right @@ -736,13 +736,13 @@ $this - 9 + 10 Top, Right - 803, 404 + 792, 403 58, 20 @@ -763,13 +763,13 @@ $this - 6 + 7 Top, Right - 744, 404 + 733, 403 53, 20 @@ -790,13 +790,13 @@ $this - 7 + 8 Top, Right - 685, 404 + 674, 403 53, 20 @@ -817,28 +817,31 @@ $this - 8 + 9 - - 23, 59 + + Fill - - 165, 481 + + 0, 0 - + + 157, 440 + + 161 - - modelPartListBox + + skinPartListBox - + System.Windows.Forms.ListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - $this + + skinPartsTabPage - - 4 + + 0 Top, Right @@ -868,7 +871,7 @@ $this - 3 + 5 Bottom, Left @@ -895,7 +898,7 @@ $this - 2 + 4 Top, Right @@ -925,7 +928,7 @@ $this - 1 + 3 Top, Bottom, Left, Right @@ -949,7 +952,7 @@ $this - 5 + 6 Top, Right @@ -982,7 +985,148 @@ $this - 27 + 28 + + + Bottom, Left + + + True + + + 23, 549 + + + 73, 19 + + + 165 + + + nameLabel + + + skinNameLabel + + + MetroFramework.Controls.MetroLabel, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a + + + $this + + + 2 + + + Top, Bottom, Left + + + Center + + + 4, 38 + + + 157, 440 + + + 0 + + + Parts + + + skinPartsTabPage + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + metroTabControl1 + + + 0 + + + offsetListBox + + + System.Windows.Forms.ListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + skinOffsetsTabPage + + + 0 + + + 4, 38 + + + 157, 440 + + + 1 + + + Offsets + + + skinOffsetsTabPage + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + metroTabControl1 + + + 1 + + + 23, 59 + + + 165, 482 + + + 166 + + + metroTabControl1 + + + MetroFramework.Controls.MetroTabControl, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a + + + $this + + + 1 + + + Fill + + + 0, 0 + + + 157, 440 + + + 0 + + + offsetListBox + + + System.Windows.Forms.ListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + skinOffsetsTabPage + + + 0 True @@ -3536,7 +3680,7 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - CustomModelEditor + CustomSkinEditor MetroFramework.Forms.MetroForm, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a diff --git a/PCK-Studio/Internal/ModelOffset.cs b/PCK-Studio/Internal/SkinPartOffset.cs similarity index 77% rename from PCK-Studio/Internal/ModelOffset.cs rename to PCK-Studio/Internal/SkinPartOffset.cs index 26a70bae..3d574e6d 100644 --- a/PCK-Studio/Internal/ModelOffset.cs +++ b/PCK-Studio/Internal/SkinPartOffset.cs @@ -7,7 +7,7 @@ using System.Text.RegularExpressions; namespace PckStudio.Internal { - internal readonly struct ModelOffset + internal readonly struct SkinPartOffset { private static readonly Regex sWhitespace = new Regex(@"\s+"); internal static string ReplaceWhitespace(string input, string replacement) @@ -24,12 +24,19 @@ namespace PckStudio.Internal "ARM1", "LEG0", "LEG1", + "PANTS0", + "PANTS1", + "BOOTS0", + "BOOTS1", // Armor Offsets "HELMET", - "CHEST", "BODYARMOR", - "SHOULDER0", "ARMARMOR0", - "SHOULDER1", "ARMARMOR1", + "CHEST", + "BODYARMOR", + "SHOULDER0", + "SHOULDER1", + "ARMARMOR0", + "ARMARMOR1", "BELT", "LEGGING0", "LEGGING1", @@ -43,13 +50,13 @@ namespace PckStudio.Internal public readonly string Name; public readonly float Value; - public ModelOffset(string name, float value) + public SkinPartOffset(string name, float value) { Name = name; Value = value; } - public static ModelOffset FromString(string offsetFormatString) + public static SkinPartOffset FromString(string offsetFormatString) { string[] offset = ReplaceWhitespace(offsetFormatString.TrimEnd('\n', '\r', ' '), ",").Split(','); if (offset.Length < 3) @@ -59,7 +66,7 @@ namespace PckStudio.Internal if (!ValidModelOffsetTypes.Contains(name)) { - Debug.WriteLine($"'{name}' is an invalid offset type."); + Debug.WriteLine($"'{name}' is an invalid offset type.", category: nameof(SkinPartOffset)); } // Ignore => Y assumed @@ -67,9 +74,9 @@ namespace PckStudio.Internal if (!float.TryParse(offset[2], out float value)) { - Debug.WriteLine($"Failed to parse y offset for: '{name}'"); + Debug.WriteLine($"Failed to parse y offset for: '{name}'", category: nameof(SkinPartOffset)); } - return new ModelOffset(name, value); + return new SkinPartOffset(name, value); } public (string, string) ToProperty() diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index 6bf48180..61ec8eee 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -140,7 +140,7 @@ - + diff --git a/PCK-Studio/Rendering/SkinRenderer.cs b/PCK-Studio/Rendering/SkinRenderer.cs index 31054ab6..e2da9928 100644 --- a/PCK-Studio/Rendering/SkinRenderer.cs +++ b/PCK-Studio/Rendering/SkinRenderer.cs @@ -80,7 +80,8 @@ namespace PckStudio.Rendering } public ObservableCollection ModelData { get; } - + public ReadOnlyDictionary PartOffsets => new ReadOnlyDictionary(partOffset); + /// /// Captures the currently displayed frame /// @@ -190,12 +191,12 @@ namespace PckStudio.Rendering private bool showWireFrame = false; - internal Matrix4 HeadMatrix { get; set; } = Matrix4.Identity; - internal Matrix4 BodyMatrix { get; set; } = Matrix4.Identity; - internal Matrix4 RightArmMatrix { get; set; } = Matrix4.CreateFromAxisAngle(Vector3.UnitZ, 25f); - internal Matrix4 LeftArmMatrix { get; set; } = Matrix4.CreateFromAxisAngle(Vector3.UnitZ, -25f); - internal Matrix4 RightLegMatrix { get; set; } = Matrix4.Identity; - internal Matrix4 LeftLegMatrix { get; set; } = Matrix4.Identity; + private Matrix4 HeadMatrix { get; set; } = Matrix4.Identity; + private Matrix4 BodyMatrix { get; set; } = Matrix4.Identity; + private Matrix4 RightArmMatrix { get; set; } = Matrix4.CreateFromAxisAngle(Vector3.UnitZ, 25f); + private Matrix4 LeftArmMatrix { get; set; } = Matrix4.CreateFromAxisAngle(Vector3.UnitZ, -25f); + private Matrix4 RightLegMatrix { get; set; } = Matrix4.Identity; + private Matrix4 LeftLegMatrix { get; set; } = Matrix4.Identity; public SkinRenderer() : base() { @@ -257,7 +258,7 @@ namespace PckStudio.Rendering }; } - public void SetPartOffset(ModelOffset offset) + public void SetPartOffset(SkinPartOffset offset) { SetPartOffset(offset.Name, offset.Value); } @@ -739,7 +740,7 @@ namespace PckStudio.Rendering animationCurrentRotationAngle += animationRotationStep; if (animationCurrentRotationAngle >= animationMaxAngleInDegrees || animationCurrentRotationAngle <= -animationMaxAngleInDegrees) animationRotationStep = -animationRotationStep; - } + } private void ReInitialzeSkinData() {