mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-06-01 10:55:24 +00:00
SkinRenderer - Added overlay inflation when pck file has xmlversion string
This commit is contained in:
@@ -50,5 +50,19 @@ namespace PckStudio.Extensions
|
||||
{
|
||||
return skinBOX.GetUVGraphicsPath(Vector2.One);
|
||||
}
|
||||
|
||||
public static bool IsOverlayPart(this SkinBOX skinBOX)
|
||||
{
|
||||
return skinBOX.Type switch
|
||||
{
|
||||
"HEADWEAR" or
|
||||
"JACKET" or
|
||||
"SLEEVE0" or
|
||||
"SLEEVE1" or
|
||||
"PANTS0" or
|
||||
"PANTS1" => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace PckStudio.Forms.Editor
|
||||
private Image _previewImage;
|
||||
private Skin _skin;
|
||||
private Random rng;
|
||||
private bool _inflateOverlayParts;
|
||||
private bool _allowInflate;
|
||||
|
||||
private BindingSource skinPartListBindingSource;
|
||||
private BindingSource skinOffsetListBindingSource;
|
||||
@@ -44,15 +46,17 @@ namespace PckStudio.Forms.Editor
|
||||
rng = new Random();
|
||||
}
|
||||
|
||||
public CustomSkinEditor(Skin skin) : this()
|
||||
public CustomSkinEditor(Skin skin, bool inflateOverlayParts = false, bool allowInflate = false) : this()
|
||||
{
|
||||
_skin = skin;
|
||||
_allowInflate = allowInflate;
|
||||
_inflateOverlayParts = inflateOverlayParts;
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
renderer3D1.InitializeGL();
|
||||
renderer3D1.InitializeGL(_inflateOverlayParts);
|
||||
if (_skin.Texture is not null)
|
||||
{
|
||||
renderer3D1.Texture = _skin.Texture;
|
||||
@@ -102,7 +106,7 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void createToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var boxEditor = new BoxEditor(SkinBOX.Empty, true);
|
||||
var boxEditor = new BoxEditor(SkinBOX.Empty, _allowInflate);
|
||||
if (boxEditor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var newBox = boxEditor.Result;
|
||||
@@ -162,19 +166,6 @@ namespace PckStudio.Forms.Editor
|
||||
"Custom Skin Model Binary File (*.csmb)|*.csmb|";
|
||||
if (saveFileDialog.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
//string contents = "";
|
||||
//foreach (ListViewItem listViewItem in listViewBoxes.Items)
|
||||
//{
|
||||
// string str = "";
|
||||
// foreach (ListViewItem.ListViewSubItem subItem in listViewItem.SubItems)
|
||||
// {
|
||||
// if (subItem.Text != "unchecked")
|
||||
// str = str + subItem.Text + Environment.NewLine;
|
||||
// }
|
||||
// contents += (listViewItem.Text + Environment.NewLine + listViewItem.Tag) + Environment.NewLine + str;
|
||||
//}
|
||||
|
||||
//File.WriteAllText(saveFileDialog.FileName, contents);
|
||||
}
|
||||
|
||||
[Obsolete("Kept for backwards compatibility.")]
|
||||
@@ -289,7 +280,7 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
if (skinPartListBox.SelectedItem is SkinBOX box)
|
||||
{
|
||||
var boxEditor = new BoxEditor(box, true);
|
||||
var boxEditor = new BoxEditor(box, _allowInflate);
|
||||
if (boxEditor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
renderer3D1.ModelData[skinPartListBox.SelectedIndex] = boxEditor.Result;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace PckStudio.Forms
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
ModelView.InitializeGL();
|
||||
ModelView.InitializeGL(true);
|
||||
foreach (var item in data)
|
||||
{
|
||||
ModelView.ModelData.Add(item);
|
||||
|
||||
@@ -28,13 +28,23 @@ namespace PckStudio.Rendering
|
||||
internal class CubeGroupMesh : GenericMesh<TextureVertex>
|
||||
{
|
||||
private List<CubeMesh> cubes;
|
||||
|
||||
public bool FlipZMapping
|
||||
{
|
||||
get => _flipZMapping;
|
||||
set
|
||||
{
|
||||
_flipZMapping = value;
|
||||
UpdateCollection();
|
||||
}
|
||||
}
|
||||
|
||||
public float Inflate { get; set; } = 0f;
|
||||
public bool FlipZMapping { get; set; } = false;
|
||||
public Vector3 Translation { get; set; } = Vector3.Zero;
|
||||
public Vector3 Pivot { get; set; } = Vector3.Zero;
|
||||
public Vector3 Offset { get; set; } = Vector3.Zero;
|
||||
|
||||
private bool _flipZMapping = false;
|
||||
|
||||
internal CubeGroupMesh(string name) : base(name, PrimitiveType.Triangles)
|
||||
{
|
||||
cubes = new List<CubeMesh>(5);
|
||||
@@ -46,12 +56,6 @@ namespace PckStudio.Rendering
|
||||
FlipZMapping = flipZMapping;
|
||||
}
|
||||
|
||||
internal CubeGroupMesh(string name, float inflate)
|
||||
: this(name)
|
||||
{
|
||||
Inflate = inflate;
|
||||
}
|
||||
|
||||
public static VertexBufferLayout GetLayout()
|
||||
{
|
||||
var layout = new VertexBufferLayout();
|
||||
@@ -60,10 +64,11 @@ namespace PckStudio.Rendering
|
||||
return layout;
|
||||
}
|
||||
|
||||
internal void AddSkinBox(SkinBOX skinBox)
|
||||
internal void AddSkinBox(SkinBOX skinBox, float inflate = 0f)
|
||||
{
|
||||
var cube = CubeMesh.Create(skinBox);
|
||||
cube.FlipZMapping = FlipZMapping;
|
||||
cube.Inflate += inflate;
|
||||
cubes.Add(cube);
|
||||
}
|
||||
|
||||
@@ -94,9 +99,9 @@ namespace PckStudio.Rendering
|
||||
Submit();
|
||||
}
|
||||
|
||||
internal void AddCube(Vector3 position, Vector3 size, Vector2 uv, float inflate = 0f, bool mirrorTexture = false, bool flipZMapping = false)
|
||||
internal void AddCube(Vector3 position, Vector3 size, Vector2 uv, float inflate = 0f, bool mirrorTexture = false)
|
||||
{
|
||||
var cube = new CubeMesh(position, size, uv, Inflate + inflate, mirrorTexture, flipZMapping || FlipZMapping);
|
||||
var cube = new CubeMesh(position, size, uv, inflate, mirrorTexture, FlipZMapping);
|
||||
cubes.Add(cube);
|
||||
}
|
||||
|
||||
@@ -118,10 +123,18 @@ namespace PckStudio.Rendering
|
||||
cube.Position = position;
|
||||
cube.Size = size;
|
||||
cube.Uv = uv;
|
||||
cube.Inflate = Inflate + inflate;
|
||||
cube.Inflate = inflate;
|
||||
cube.MirrorTexture = mirrorTexture;
|
||||
}
|
||||
|
||||
private void UpdateCollection()
|
||||
{
|
||||
foreach (var cube in cubes)
|
||||
{
|
||||
cube.FlipZMapping = FlipZMapping;
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 Transform
|
||||
{
|
||||
get
|
||||
|
||||
@@ -181,8 +181,6 @@ namespace PckStudio.Rendering
|
||||
|
||||
private DrawContext _skyboxRenderBuffer;
|
||||
private CubeTexture _skyboxTexture;
|
||||
private float skyboxRotation = 0f;
|
||||
private float skyboxRotationStep = 0.5f;
|
||||
|
||||
private Dictionary<string, CubeGroupMesh> meshStorage;
|
||||
private Dictionary<string, CubeGroupMesh> offsetSpecificMeshStorage;
|
||||
@@ -199,6 +197,7 @@ namespace PckStudio.Rendering
|
||||
private float animationMaxAngleInDegrees = 5f;
|
||||
|
||||
private bool showWireFrame = false;
|
||||
private bool autoInflateOverlayParts;
|
||||
|
||||
private Matrix4 RightArmMatrix { get; set; } = Matrix4.CreateFromAxisAngle(Vector3.UnitZ, 25f);
|
||||
private Matrix4 LeftArmMatrix { get; set; } = Matrix4.CreateFromAxisAngle(Vector3.UnitZ, -25f);
|
||||
@@ -260,8 +259,11 @@ namespace PckStudio.Rendering
|
||||
ModelData.CollectionChanged += ModelData_CollectionChanged;
|
||||
}
|
||||
|
||||
public void InitializeGL()
|
||||
public void InitializeGL(bool inflateOverlayParts)
|
||||
{
|
||||
if (initialized)
|
||||
Debug.Fail("Already Initialized!");
|
||||
autoInflateOverlayParts = inflateOverlayParts;
|
||||
MakeCurrent();
|
||||
InitializeShaders();
|
||||
InitializeFramebuffer();
|
||||
@@ -329,44 +331,44 @@ namespace PckStudio.Rendering
|
||||
{
|
||||
const float armorInflation = 0.75f;
|
||||
|
||||
var helmet = new CubeGroupMesh("HELMET", armorInflation);
|
||||
helmet.AddCube(new(-4, -8, -4), new(8, 8, 8), new(0, 0));
|
||||
var helmet = new CubeGroupMesh("HELMET");
|
||||
helmet.AddCube(new(-4, -8, -4), new(8, 8, 8), new(0, 0), inflate: armorInflation);
|
||||
|
||||
var chest = new CubeGroupMesh("CHEST", armorInflation);
|
||||
chest.AddCube(new(-4, 0, -2), new(8, 12, 4), new(16, 16));
|
||||
var chest = new CubeGroupMesh("CHEST");
|
||||
chest.AddCube(new(-4, 0, -2), new(8, 12, 4), new(16, 16), inflate: armorInflation + 0.01f);
|
||||
|
||||
var shoulder0 = new CubeGroupMesh("SHOULDER0", armorInflation);
|
||||
var shoulder0 = new CubeGroupMesh("SHOULDER0");
|
||||
shoulder0.Pivot = new Vector3(4f, 2f, 0f);
|
||||
shoulder0.Translation = new Vector3(-5f, -2f, 0f);
|
||||
shoulder0.AddCube(new(-3, -2, -2), new(4, 12, 4), new(40, 16));
|
||||
shoulder0.AddCube(new(-3, -2, -2), new(4, 12, 4), new(40, 16), inflate: armorInflation);
|
||||
|
||||
var shoulder1 = new CubeGroupMesh("SHOULDER1", armorInflation);
|
||||
var shoulder1 = new CubeGroupMesh("SHOULDER1");
|
||||
shoulder1.Pivot = new Vector3(-4f, 2f, 0f);
|
||||
shoulder1.Translation = new Vector3(5f, -2f, 0f);
|
||||
shoulder1.AddCube(new(-1, -2, -2), new(4, 12, 4), new(40, 16), mirrorTexture: true);
|
||||
shoulder1.AddCube(new(-1, -2, -2), new(4, 12, 4), new(40, 16), inflate: armorInflation, mirrorTexture: true);
|
||||
|
||||
var waist = new CubeGroupMesh("WAIST", armorInflation - 0.1f);
|
||||
waist.AddCube(new(-4, 0, -2), new(8, 12, 4), new(16, 48));
|
||||
var waist = new CubeGroupMesh("WAIST");
|
||||
waist.AddCube(new(-4, 0, -2), new(8, 12, 4), new(16, 48), inflate: armorInflation);
|
||||
|
||||
var pants0 = new CubeGroupMesh("PANTS0", armorInflation);
|
||||
var pants0 = new CubeGroupMesh("PANTS0");
|
||||
pants0.Pivot = new Vector3(0f, 12f, 0f);
|
||||
pants0.Translation = new Vector3(-2f, -12f, 0f);
|
||||
pants0.AddCube(new(-2, 0, -2), new(4, 12, 4), new(0, 48));
|
||||
pants0.AddCube(new(-2, 0, -2), new(4, 12, 4), new(0, 48), inflate: armorInflation);
|
||||
|
||||
var pants1 = new CubeGroupMesh("PANTS1", armorInflation);
|
||||
var pants1 = new CubeGroupMesh("PANTS1");
|
||||
pants1.Pivot = new Vector3(0f, 12f, 0f);
|
||||
pants1.Translation = new Vector3(2f, -12f, 0f);
|
||||
pants1.AddCube(new(-2, 0, -2), new(4, 12, 4), new(0, 48), mirrorTexture: true);
|
||||
pants1.AddCube(new(-2, 0, -2), new(4, 12, 4), new(0, 48), inflate: armorInflation, mirrorTexture: true);
|
||||
|
||||
var boot0 = new CubeGroupMesh("BOOT0", armorInflation + 0.25f);
|
||||
var boot0 = new CubeGroupMesh("BOOT0");
|
||||
boot0.Pivot = new Vector3(0f, 12f, 0f);
|
||||
boot0.Translation = new Vector3(-2f, -12f, 0f);
|
||||
boot0.AddCube(new(-2, 0, -2), new(4, 12, 4), new(0, 16));
|
||||
boot0.AddCube(new(-2, 0, -2), new(4, 12, 4), new(0, 16), inflate: armorInflation + 0.25f);
|
||||
|
||||
var boot1 = new CubeGroupMesh("BOOT1", armorInflation + 0.25f);
|
||||
var boot1 = new CubeGroupMesh("BOOT1");
|
||||
boot1.Pivot = new Vector3(0f, 12f, 0f);
|
||||
boot1.Translation = new Vector3(2f, -12f, 0f);
|
||||
boot1.AddCube(new(-2, 0, -2), new(4, 12, 4), new(0, 16), mirrorTexture: true);
|
||||
boot1.AddCube(new(-2, 0, -2), new(4, 12, 4), new(0, 16), inflate: armorInflation + 0.25f, mirrorTexture: true);
|
||||
|
||||
offsetSpecificMeshStorage = new Dictionary<string, CubeGroupMesh>
|
||||
{
|
||||
@@ -423,8 +425,6 @@ namespace PckStudio.Rendering
|
||||
skinTexture.WrapS = TextureWrapMode.Repeat;
|
||||
skinTexture.WrapT = TextureWrapMode.Repeat;
|
||||
|
||||
Texture ??= Resources.classic_template;
|
||||
|
||||
GLErrorCheck();
|
||||
}
|
||||
|
||||
@@ -613,7 +613,6 @@ namespace PckStudio.Rendering
|
||||
d_debugDrawContext = new DrawContext(vao, debugVBO.GenIndexBuffer(), PrimitiveType.Points);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
private DrawContext GetGuidelineDrawContext()
|
||||
@@ -752,7 +751,7 @@ namespace PckStudio.Rendering
|
||||
throw new KeyNotFoundException(skinBox.Type);
|
||||
|
||||
CubeGroupMesh cubeMesh = meshStorage[skinBox.Type];
|
||||
cubeMesh.AddSkinBox(skinBox);
|
||||
cubeMesh.AddSkinBox(skinBox, autoInflateOverlayParts && skinBox.IsOverlayPart() ? OverlayScale : 0f);
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
|
||||
Reference in New Issue
Block a user