mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-06-03 06:45:10 +00:00
SkinRenderer - Add ouline color property
This commit is contained in:
26
PCK-Studio/Forms/Editor/CustomSkinEditor.Designer.cs
generated
26
PCK-Studio/Forms/Editor/CustomSkinEditor.Designer.cs
generated
@@ -44,7 +44,7 @@
|
||||
this.buttonIMPORT = new MetroFramework.Controls.MetroButton();
|
||||
this.importCustomSkinButton = new MetroFramework.Controls.MetroButton();
|
||||
this.buttonExportModel = new MetroFramework.Controls.MetroButton();
|
||||
this.OpenJSONButton = new MetroFramework.Controls.MetroButton();
|
||||
this.outlineColorButton = new MetroFramework.Controls.MetroButton();
|
||||
this.generateTextureCheckBox = new MetroFramework.Controls.MetroCheckBox();
|
||||
this.checkGuide = new MetroFramework.Controls.MetroCheckBox();
|
||||
this.checkBoxArmor = new MetroFramework.Controls.MetroCheckBox();
|
||||
@@ -190,14 +190,14 @@
|
||||
this.buttonExportModel.UseSelectable = true;
|
||||
this.buttonExportModel.Click += new System.EventHandler(this.buttonExportModel_Click);
|
||||
//
|
||||
// OpenJSONButton
|
||||
// outlineColorButton
|
||||
//
|
||||
resources.ApplyResources(this.OpenJSONButton, "OpenJSONButton");
|
||||
this.OpenJSONButton.ForeColor = System.Drawing.Color.White;
|
||||
this.OpenJSONButton.Name = "OpenJSONButton";
|
||||
this.OpenJSONButton.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.OpenJSONButton.UseSelectable = true;
|
||||
this.OpenJSONButton.Click += new System.EventHandler(this.OpenJSONButton_Click);
|
||||
resources.ApplyResources(this.outlineColorButton, "outlineColorButton");
|
||||
this.outlineColorButton.ForeColor = System.Drawing.Color.White;
|
||||
this.outlineColorButton.Name = "outlineColorButton";
|
||||
this.outlineColorButton.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.outlineColorButton.UseSelectable = true;
|
||||
this.outlineColorButton.Click += new System.EventHandler(this.outlineColorButton_Click);
|
||||
//
|
||||
// generateTextureCheckBox
|
||||
//
|
||||
@@ -379,14 +379,16 @@
|
||||
//
|
||||
// renderer3D1
|
||||
//
|
||||
resources.ApplyResources(this.renderer3D1, "renderer3D1");
|
||||
this.renderer3D1.BackColor = System.Drawing.Color.DimGray;
|
||||
this.renderer3D1.ClampModel = false;
|
||||
resources.ApplyResources(this.renderer3D1, "renderer3D1");
|
||||
this.renderer3D1.Name = "renderer3D1";
|
||||
this.renderer3D1.OutlineColor = System.Drawing.Color.Empty;
|
||||
this.renderer3D1.RefreshRate = 50;
|
||||
this.renderer3D1.ShowGuideLines = false;
|
||||
this.renderer3D1.Texture = null;
|
||||
this.renderer3D1.VSync = true;
|
||||
this.renderer3D1.TextureChanging += new System.EventHandler<PckStudio.Rendering.TextureChangingEventArgs>(renderer3D1_TextureChanging);
|
||||
this.renderer3D1.TextureChanging += new System.EventHandler<PckStudio.Rendering.TextureChangingEventArgs>(this.renderer3D1_TextureChanging);
|
||||
//
|
||||
// uvPictureBox
|
||||
//
|
||||
@@ -417,7 +419,7 @@
|
||||
this.Controls.Add(this.checkBoxArmor);
|
||||
this.Controls.Add(this.checkGuide);
|
||||
this.Controls.Add(this.generateTextureCheckBox);
|
||||
this.Controls.Add(this.OpenJSONButton);
|
||||
this.Controls.Add(this.outlineColorButton);
|
||||
this.Controls.Add(this.buttonExportModel);
|
||||
this.Controls.Add(this.importCustomSkinButton);
|
||||
this.Controls.Add(this.buttonEXPORT);
|
||||
@@ -457,7 +459,7 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem changeColorToolStripMenuItem;
|
||||
private MetroFramework.Controls.MetroButton buttonDone;
|
||||
private MetroFramework.Controls.MetroButton OpenJSONButton;
|
||||
private MetroFramework.Controls.MetroButton outlineColorButton;
|
||||
private MetroFramework.Controls.MetroButton buttonExportModel;
|
||||
private MetroFramework.Controls.MetroButton importCustomSkinButton;
|
||||
private PckStudio.ToolboxItems.InterpolationPictureBox uvPictureBox;
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
base.OnLoad(e);
|
||||
renderer3D1.InitializeGL();
|
||||
renderer3D1.OutlineColor = Color.DarkSlateBlue;
|
||||
if (_file.Size > 0)
|
||||
{
|
||||
renderer3D1.Texture = _file.GetTexture();
|
||||
@@ -116,7 +117,7 @@ namespace PckStudio.Forms.Editor
|
||||
openFileDialog.Filter = "PNG Image Files | *.png";
|
||||
openFileDialog.Title = "Select Skin Texture";
|
||||
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK) // skins can only be a 1:1 ratio (base 64x64) or a 2:1 ratio (base 64x32)
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
using (var img = Image.FromFile(openFileDialog.FileName))
|
||||
{
|
||||
@@ -162,8 +163,8 @@ namespace PckStudio.Forms.Editor
|
||||
private void importCustomSkinButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||
openFileDialog.Filter = "Custom Skin Model File (*.csm,*.CSM)|*.csm;*.CSM|Custom Skin Model Binary File (*.csmb)|*.csmb";
|
||||
openFileDialog.Title = "Select File";
|
||||
openFileDialog.Filter = "Custom Skin Model File (*.csm,*.CSM)|*.csm;*.CSM|Custom Skin Model Binary File (*.csmb)|*.csmb|JSON Model File(*.json)|*.JSON;*.json";
|
||||
openFileDialog.Title = "Select Model File";
|
||||
if (MessageBox.Show("Import custom model project file? Your current work will be lost!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes && openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string fileExtension = Path.GetExtension(openFileDialog.FileName);
|
||||
@@ -214,18 +215,14 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
}
|
||||
|
||||
// TODO: re-implement comletely
|
||||
private void OpenJSONButton_Click(object sender, EventArgs e)
|
||||
private void outlineColorButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||
openFileDialog.Filter = "JSON Model File | *.JSON";
|
||||
openFileDialog.Title = "Select JSON Model File";
|
||||
if (MessageBox.Show(
|
||||
"Import custom model project file? Your current work will be lost!", "",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes &&
|
||||
openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
ColorDialog colorDialog = new ColorDialog();
|
||||
colorDialog.SolidColorOnly = true;
|
||||
if (colorDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
|
||||
renderer3D1.OutlineColor = colorDialog.Color;
|
||||
skinPartListBox_SelectedIndexChanged(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,13 +236,14 @@ namespace PckStudio.Forms.Editor
|
||||
string PARENT = group.Name;
|
||||
foreach (int i in group.children)
|
||||
{
|
||||
string name = jsonDe.Elements[i].Name;
|
||||
float PosX = jsonDe.Elements[i].from[0] + group.origin[0];
|
||||
float PosY = jsonDe.Elements[i].from[1] + group.origin[1];
|
||||
float PosZ = jsonDe.Elements[i].from[2] + group.origin[2];
|
||||
float SizeX = jsonDe.Elements[i].to[0] - jsonDe.Elements[i].from[0];
|
||||
float SizeY = jsonDe.Elements[i].to[1] - jsonDe.Elements[i].from[1];
|
||||
float SizeZ = jsonDe.Elements[i].to[2] - jsonDe.Elements[i].from[2];
|
||||
CSMJObjectElement element = jsonDe.Elements[i];
|
||||
string name = element.Name;
|
||||
float PosX = element.from[0] + group.origin[0];
|
||||
float PosY = element.from[1] + group.origin[1];
|
||||
float PosZ = element.from[2] + group.origin[2];
|
||||
float SizeX = element.to[0] - element.from[0];
|
||||
float SizeY = element.to[1] - element.from[1];
|
||||
float SizeZ = element.to[2] - element.from[2];
|
||||
float U = 0;
|
||||
float V = 0;
|
||||
|
||||
@@ -258,6 +256,7 @@ namespace PckStudio.Forms.Editor
|
||||
private void renderer3D1_TextureChanging(object sender, Rendering.TextureChangingEventArgs e)
|
||||
{
|
||||
var img = e.NewTexture;
|
||||
// Skins can only be a 1:1 ratio (base 64x64) or a 2:1 ratio (base 64x32)
|
||||
if (img.Width != img.Height && img.Height != img.Width / 2)
|
||||
{
|
||||
e.Cancel = true;
|
||||
@@ -289,14 +288,14 @@ namespace PckStudio.Forms.Editor
|
||||
uvPictureBox.Image = new Bitmap(uvPictureBox.BackgroundImage.Width * scale, uvPictureBox.BackgroundImage.Height * scale);
|
||||
using (Graphics g = Graphics.FromImage(uvPictureBox.Image))
|
||||
{
|
||||
float penWidth = ((uvPictureBox.BackgroundImage.Width / renderer3D1.TextureSize.Width) + (uvPictureBox.BackgroundImage.Height / renderer3D1.TextureSize.Height)) / 2f;
|
||||
float lineWidth = ((uvPictureBox.BackgroundImage.Width / renderer3D1.TextureSize.Width) + (uvPictureBox.BackgroundImage.Height / renderer3D1.TextureSize.Height)) / 2f;
|
||||
GraphicsPath graphicsPath = box.GetUVGraphicsPath(
|
||||
new System.Numerics.Vector2(
|
||||
scale * renderer3D1.TillingFactor.X * uvPictureBox.BackgroundImage.Width,
|
||||
scale * renderer3D1.TillingFactor.Y * uvPictureBox.BackgroundImage.Height
|
||||
)
|
||||
);
|
||||
g.DrawPath(new Pen(Color.HotPink, penWidth), graphicsPath);
|
||||
g.DrawPath(new Pen(renderer3D1.OutlineColor, lineWidth), graphicsPath);
|
||||
}
|
||||
uvPictureBox.Invalidate();
|
||||
}
|
||||
|
||||
@@ -436,10 +436,10 @@
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="importCustomSkinButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>194, 558</value>
|
||||
<value>190, 558</value>
|
||||
</data>
|
||||
<data name="importCustomSkinButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>106, 21</value>
|
||||
<value>105, 21</value>
|
||||
</data>
|
||||
<data name="importCustomSkinButton.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>96</value>
|
||||
@@ -466,7 +466,7 @@
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="buttonExportModel.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>418, 558</value>
|
||||
<value>413, 558</value>
|
||||
</data>
|
||||
<data name="buttonExportModel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>89, 21</value>
|
||||
@@ -489,34 +489,31 @@
|
||||
<data name=">>buttonExportModel.ZOrder" xml:space="preserve">
|
||||
<value>19</value>
|
||||
</data>
|
||||
<data name="OpenJSONButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<data name="outlineColorButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Left</value>
|
||||
</data>
|
||||
<data name="OpenJSONButton.Enabled" type="System.Boolean, mscorlib">
|
||||
<value>False</value>
|
||||
<data name="outlineColorButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>301, 558</value>
|
||||
</data>
|
||||
<data name="OpenJSONButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>306, 558</value>
|
||||
</data>
|
||||
<data name="OpenJSONButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<data name="outlineColorButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>106, 21</value>
|
||||
</data>
|
||||
<data name="OpenJSONButton.TabIndex" type="System.Int32, mscorlib">
|
||||
<data name="outlineColorButton.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>145</value>
|
||||
</data>
|
||||
<data name="OpenJSONButton.Text" xml:space="preserve">
|
||||
<value>Import json</value>
|
||||
<data name="outlineColorButton.Text" xml:space="preserve">
|
||||
<value>Set Outline Color</value>
|
||||
</data>
|
||||
<data name=">>OpenJSONButton.Name" xml:space="preserve">
|
||||
<value>OpenJSONButton</value>
|
||||
<data name=">>outlineColorButton.Name" xml:space="preserve">
|
||||
<value>outlineColorButton</value>
|
||||
</data>
|
||||
<data name=">>OpenJSONButton.Type" xml:space="preserve">
|
||||
<data name=">>outlineColorButton.Type" xml:space="preserve">
|
||||
<value>MetroFramework.Controls.MetroButton, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>
|
||||
</data>
|
||||
<data name=">>OpenJSONButton.Parent" xml:space="preserve">
|
||||
<data name=">>outlineColorButton.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>OpenJSONButton.ZOrder" xml:space="preserve">
|
||||
<data name=">>outlineColorButton.ZOrder" xml:space="preserve">
|
||||
<value>18</value>
|
||||
</data>
|
||||
<data name="generateTextureCheckBox.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
@@ -877,7 +874,7 @@
|
||||
<value>Bottom, Left</value>
|
||||
</data>
|
||||
<data name="captureScreenshotButton.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>513, 558</value>
|
||||
<value>508, 558</value>
|
||||
</data>
|
||||
<data name="captureScreenshotButton.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>113, 21</value>
|
||||
@@ -1059,14 +1056,11 @@
|
||||
<data name=">>metroTabControl1.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="renderer3D1.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Bottom, Left, Right</value>
|
||||
</data>
|
||||
<data name="renderer3D1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>194, 63</value>
|
||||
<value>190, 59</value>
|
||||
</data>
|
||||
<data name="renderer3D1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>424, 484</value>
|
||||
<value>431, 488</value>
|
||||
</data>
|
||||
<data name="renderer3D1.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>167</value>
|
||||
|
||||
@@ -73,6 +73,8 @@ namespace PckStudio.Rendering
|
||||
protected override void OnSizeChanged(EventArgs e)
|
||||
{
|
||||
base.OnSizeChanged(e);
|
||||
if (DesignMode)
|
||||
return;
|
||||
MakeCurrent();
|
||||
if (Camera is not null)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace PckStudio.Rendering.Shader
|
||||
|
||||
public void AddShader(string name, ShaderProgram shader) => _shaderStorage.Add(name, shader);
|
||||
|
||||
public bool HasShader(string name) => _shaderStorage.TryGetValue(name, out _);
|
||||
|
||||
public bool HasShader(string name, out ShaderProgram shader) => _shaderStorage.TryGetValue(name, out shader);
|
||||
|
||||
public ShaderProgram GetShader(string name) => _shaderStorage[name];
|
||||
|
||||
@@ -63,6 +63,26 @@ namespace PckStudio.Rendering
|
||||
}
|
||||
}
|
||||
|
||||
[Description("The Color used for outlines")]
|
||||
[Category("Appearance")]
|
||||
public Color OutlineColor
|
||||
{
|
||||
get => _outlineColor;
|
||||
set
|
||||
{
|
||||
if (value == _outlineColor)
|
||||
return;
|
||||
_outlineColor = value;
|
||||
if (initialized && _shaders.HasShader("LineShader"))
|
||||
{
|
||||
MakeCurrent();
|
||||
var shader = _shaders.GetShader("LineShader");
|
||||
shader.Bind();
|
||||
shader.SetUniform4("baseColor", _outlineColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool ClampModel { get; set; } = false;
|
||||
public bool ShowGuideLines
|
||||
{
|
||||
@@ -88,6 +108,7 @@ namespace PckStudio.Rendering
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public SkinANIM ANIM
|
||||
{
|
||||
get => _anim;
|
||||
@@ -124,6 +145,8 @@ namespace PckStudio.Rendering
|
||||
}
|
||||
|
||||
|
||||
private Color _outlineColor;
|
||||
|
||||
private enum GuidelineMode
|
||||
{
|
||||
None = -1,
|
||||
@@ -475,7 +498,7 @@ namespace PckStudio.Rendering
|
||||
lineShader.Validate();
|
||||
_shaders.AddShader("LineShader", lineShader);
|
||||
|
||||
Color lineColor = Color.Aquamarine;
|
||||
Color lineColor = Color.White;
|
||||
|
||||
// Cubical draw context
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user