From c2da34cd8cd59e8455cbf7eade4233fead3a1f4b Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Tue, 30 Jul 2024 22:11:43 +0200 Subject: [PATCH] ModelImporter - Update BedrockModel json class --- PCK-Studio/External/Format/BedrockModel.cs | 26 ++++++++++++++++++---- PCK-Studio/Internal/ModelImporter.cs | 4 ++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/PCK-Studio/External/Format/BedrockModel.cs b/PCK-Studio/External/Format/BedrockModel.cs index c6e52902..ce9cc8f5 100644 --- a/PCK-Studio/External/Format/BedrockModel.cs +++ b/PCK-Studio/External/Format/BedrockModel.cs @@ -15,7 +15,7 @@ namespace PckStudio.External.Format public string FormatVersion { get; set; } [JsonProperty("minecraft:geometry")] - public List Models; + public List Models { get; } = new List(); } internal class Geometry @@ -24,7 +24,7 @@ namespace PckStudio.External.Format public GeometryDescription Description { get; set; } [JsonProperty("bones")] - public List Bones; + public List Bones { get; } = new List(); } internal class GeometryDescription @@ -61,6 +61,10 @@ namespace PckStudio.External.Format Cubes = new List(); } + + [JsonProperty("parent", NullValueHandling = NullValueHandling.Ignore)] + public string Parent { get; set; } = ""; + [JsonIgnore] public Vector3 Pivot { @@ -99,6 +103,20 @@ namespace PckStudio.External.Format origin[2] = value.Z; } } + + [JsonProperty("rotation")] + private float[] rotation { get; set; } = new float[3]; + [JsonIgnore] + public Vector3 Rotation + { + get => rotation.Length < 3 ? Vector3.Zero : new Vector3(rotation[0], rotation[1], rotation[2]); + set + { + rotation[0] = value.X; + rotation[1] = value.Y; + rotation[2] = value.Z; + } + } [JsonProperty("size")] private float[] size { get; set; } = new float[3]; @@ -134,7 +152,7 @@ namespace PckStudio.External.Format [JsonProperty("inflate")] public float Inflate { get; set; } = 0f; - [JsonProperty("mirror", DefaultValueHandling = DefaultValueHandling.Ignore)] - public bool Mirror; + [JsonProperty("mirror", NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool Mirror { get; set; } = false; } } diff --git a/PCK-Studio/Internal/ModelImporter.cs b/PCK-Studio/Internal/ModelImporter.cs index 9c0ed7f0..95268365 100644 --- a/PCK-Studio/Internal/ModelImporter.cs +++ b/PCK-Studio/Internal/ModelImporter.cs @@ -523,7 +523,7 @@ namespace PckStudio.Internal } Geometry selectedGeometry = new Geometry(); - selectedGeometry.Bones = bones.Values.ToList(); + selectedGeometry.Bones.AddRange(bones.Values); object bedrockModel = null; // Bedrock Entity (Model) if (fileName.EndsWith(".geo.json")) @@ -536,7 +536,7 @@ namespace PckStudio.Internal bedrockModel = new BedrockModel { FormatVersion = "1.12.0", - Models = new List() { selectedGeometry } + Models = { selectedGeometry } }; } // Bedrock Legacy Model