diff --git a/PCK-Studio/Classes/Utils/BedrockJSONtoCSM.cs b/PCK-Studio/Classes/Utils/BedrockJSONtoCSM.cs deleted file mode 100644 index b9989707..00000000 --- a/PCK-Studio/Classes/Utils/BedrockJSONtoCSM.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; - -namespace PckStudio.Classes.Utils.ModelConversion -{ - public class BedrockJSONtoCSM - { - public string JSONtoCSM(string JsonString) - { - dynamic jsonDe = JsonConvert.DeserializeObject(JsonString); - string NewJSON = JsonConvert.SerializeObject(jsonDe["minecraft:geometry"]); - JObject[] NewJObject = JsonConvert.DeserializeObject(NewJSON); - - string CSMData = ""; - foreach (JBone bone in NewJObject[0].bones) - { - int i = 0; - string PARENT = bone.name; - foreach (JCube Cube in bone.cubes) - { - string name = PARENT + " " + i; - - float PosXModifier = 0; - float PosYModifier = 0; - float PosZModifier = 0; - - switch (PARENT) - { - case "ARM0": - PosXModifier = 5; - PosYModifier = 22; - break; - case "ARM1": - PosXModifier = -5; - PosYModifier = 22; - break; - case "LEG0": - PosXModifier = 1.9f; - PosYModifier = 12; - break; - case "LEG1": - PosXModifier = -1.9f; - PosYModifier = 12; - break; - case "BODY": - PosYModifier = 24; - break; - case "HEAD": - PosYModifier = 24; - break; - } - - - float PosX = Cube.origin[0] + PosXModifier; - float PosY = Cube.origin[1] + PosYModifier; - float PosZ = Cube.origin[2] + PosZModifier; - float SizeX = Cube.size[0]; - float SizeY = Cube.size[1]; - float SizeZ = Cube.size[2]; - float UvX = Cube.uv[0]; - float UvY = Cube.uv[1]; - - CSMData += name + "\n" + PARENT + "\n" + name + "\n" + PosX + "\n" + PosY + "\n" + PosZ + "\n" + SizeX + "\n" + SizeY + "\n" + SizeZ + "\n" + UvX + "\n" + UvY + "\n"; - i++; - } - } - return CSMData; - } - } - - internal class WholeJSON - { - public string format_version = "1.12.0"; - public Dictionary entries = new Dictionary(); - } - - internal class JObject - { - public Dictionary description = new Dictionary(); - public JBone[] bones = { }; - } - internal class JBone - { - public string name = ""; - public int[] pivot = {0, 0, 0}; - public JCube[] cubes = { }; - } - internal class JCube - { - public float[] origin = new float[3]; - public float[] size = new float [3]; - public float[] uv = new float[2]; - } -} diff --git a/PCK-Studio/Classes/Utils/CSMtoBedrockJSON.cs b/PCK-Studio/Classes/Utils/CSMtoBedrockJSON.cs deleted file mode 100644 index 93df0546..00000000 --- a/PCK-Studio/Classes/Utils/CSMtoBedrockJSON.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; - -namespace PckStudio.Classes.Utils.ModelConversion -{ - public class CSMtoBedrockJSON - { - public string CSMtoJSON(string CSMString) - { - List CSMLIST = new List(); - CSMLIST.AddRange(CSMString.Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries)); - List> CSMS = SplitToSublists(CSMLIST, 11); - - JObject jobj = new JObject(); - List bones = new List(); - Dictionary> CubeList = new Dictionary> - { - {"HEAD", new List()}, - {"BODY", new List()}, - {"ARM0", new List()}, - {"ARM1", new List()}, - {"LEG0", new List()}, - {"LEG1", new List()} - }; - - foreach (List CSMItem in CSMS) - { - JCube NewCube = new JCube(); - - - float PosXModifier = 0; - float PosYModifier = 0; - float PosZModifier = 0; - - switch (CSMItem[1]) - { - case "ARM0": - PosXModifier = -5; - PosYModifier = -22; - break; - case "ARM1": - PosXModifier = 5; - PosYModifier = -22; - break; - case "LEG0": - PosXModifier = -1.9f; - PosYModifier = -12; - break; - case "LEG1": - PosXModifier = 1.9f; - PosYModifier = -12; - break; - case "BODY": - PosYModifier = -24; - break; - case "HEAD": - PosYModifier = -24; - break; - } - NewCube.origin[0] = float.Parse(CSMItem[3]) + PosXModifier; - NewCube.origin[1] = float.Parse(CSMItem[4]) + PosYModifier; - NewCube.origin[2] = float.Parse(CSMItem[5]) + PosZModifier; - NewCube.size[0] = float.Parse(CSMItem[6]); - NewCube.size[1] = float.Parse(CSMItem[7]); - NewCube.size[2] = float.Parse(CSMItem[8]); - NewCube.uv[0] = float.Parse(CSMItem[9]); - NewCube.uv[1] = float.Parse(CSMItem[10]); - CubeList[CSMItem[1]].Add(NewCube); - } - foreach (KeyValuePair> bone in CubeList) - { - JBone jb = new JBone(); - jb.name = bone.Key; - jb.cubes = bone.Value.ToArray(); - bones.Add(jb); - } - jobj.bones = bones.ToArray(); - jobj.description.Add("identifier", "geometry.steve"); - jobj.description.Add("texture_width", 64); - jobj.description.Add("texture_height", 64); - jobj.description.Add("visible_bounds_width", 2); - jobj.description.Add("visible_bounds_height", 3.5f); - jobj.description.Add("visible_bounds_offset", new float[] { 0, 1.25f, 0 }); - WholeJSON WJ = new WholeJSON(); - WJ.entries.Add("format_version", "1.12.0"); - WJ.entries.Add("minecraft:geometry", new JObject[] { jobj }); - string JSONDATA = JsonConvert.SerializeObject(WJ.entries, Formatting.Indented); - return JSONDATA; - } - - public List> SplitToSublists(List source, int size) - { - return source - .Select((x, i) => new { Index = i, Value = x }) - .GroupBy(x => x.Index / size) - .Select(x => x.Select(v => v.Value).ToList()) - .ToList(); - } - } - -}