diff --git a/PCK-Studio/Classes/FileTypes/ModelFile.cs b/PCK-Studio/Classes/FileTypes/ModelFile.cs deleted file mode 100644 index cdc0dd9f..00000000 --- a/PCK-Studio/Classes/FileTypes/ModelFile.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Documents; - -namespace PckStudio.Classes.FileTypes -{ - [Serializable] - internal class ModelNotFoundException : Exception - { - public ModelNotFoundException() - { - } - - public ModelNotFoundException(string message) : base(message) - { - } - - public ModelNotFoundException(string message, Exception innerException) : base(message, innerException) - { - } - - protected ModelNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - } - public class ModelFile - { - public List Models { get; } = new List(); - - public void AddModel(Model model) - { - Models.Add(model); - } - - bool Contains(string name) => Models.FindIndex(m => m.name == name) > -1; - - /// - Model GetModelByName(string name) - { - return Contains(name) ? Models.First(m => m.name.Equals(name)) : throw new ModelNotFoundException(nameof(name)); - } - - public struct Model - { - public readonly string name; - public Size textureSize; - public List parts { get; } = new List(); - - public Model(string name, int textureWidth, int textureHeight) - { - this.name = name; - textureSize = new Size(textureWidth, textureHeight); - } - - public struct Part - { - public string name; - public (float x, float y, float z) position; - public (float yaw, float pitch, float roll) rotation; - public List Boxes { get; } = new List(); - - public struct Box - { - public (float x, float y, float z) Position; - public (int width, int height, int length) Size; - public float U, V; - public float Scale; - public bool Mirror; - - public Box((float x, float y, float z) position, - (int width, int height, int length) size, - float u, float v, float scale, bool mirror) - { - Position = position; - Size = size; - U = u; - V = v; - Scale = scale; - Mirror = mirror; - } - } - - public Part(string name, - (float x, float y, float z) pos, - (float yaw, float pitch, float roll) rot) : this(name) - { - position = pos; - rotation = rot; - } - - public Part(string name) - { - this.name = name; - this.position = (0, 0, 0); - this.rotation = (0, 0, 0); - } - - public void AddBox((float x, float y, float z) position, - (int width, int height, int length) size, - float u, float v, float scale, bool mirror) - { - Boxes.Add(new Box(position, size, u, v, scale, mirror)); - } - - } - - public void AddPart(Part part) - { - parts.Add(part); - } - } - } -} diff --git a/PCK-Studio/Classes/IO/Model/ModelFileReader.cs b/PCK-Studio/Classes/IO/Model/ModelFileReader.cs deleted file mode 100644 index 615aa9eb..00000000 --- a/PCK-Studio/Classes/IO/Model/ModelFileReader.cs +++ /dev/null @@ -1,82 +0,0 @@ -using PckStudio.Classes.FileTypes; -using System; -using System.Diagnostics; -using System.IO; -using System.Text; - -namespace PckStudio.Classes.IO.Model -{ - public class ModelFileReader : StreamDataReader - { - public static ModelFile Read(Stream stream) - { - return new ModelFileReader().ReadFromStream(stream); - } - - private ModelFileReader() : base(false) - { - } - - protected override ModelFile ReadFromStream(Stream stream) - { - var modelFile = new ModelFile(); - int version = ReadInt(stream); - int modelCount = ReadInt(stream); - for (; 0 < modelCount; modelCount--) - { - string name = ReadString(stream); - int width = ReadInt(stream); - int height = ReadInt(stream); - var model = new ModelFile.Model(name, width, height); - - int partCount = ReadInt(stream); - for (; 0 < partCount; partCount--) - { - string partName = ReadString(stream); - if (version > 1) - { - string partParentName = ReadString(stream); - Debug.WriteLineIf(partParentName.Length > 0, partParentName, category: nameof(ModelFileReader)); - } - float x = ReadFloat(stream); - float y = ReadFloat(stream); - float z = ReadFloat(stream); - - float yaw = ReadFloat(stream); - float pitch = ReadFloat(stream); - float roll = ReadFloat(stream); - var part = new ModelFile.Model.Part(partName, (x, y, z), (yaw, pitch, roll)); - if (version > 0) - { - float _1 = ReadFloat(stream); - float _2 = ReadFloat(stream); - float _3 = ReadFloat(stream); - Debug.WriteLine(string.Format("{0}, {1}, {2}", _1, _2, _3), category: nameof(ModelFileReader)); - } - - int boxCount = ReadInt(stream); - for (; 0 < boxCount; boxCount--) - { - var pos = (ReadFloat(stream), ReadFloat(stream), ReadFloat(stream)); - var size = (ReadInt(stream), ReadInt(stream), ReadInt(stream)); - float u = ReadFloat(stream), v = ReadFloat(stream); - float scale = ReadFloat(stream); - bool mirrored = ReadBool(stream); - part.AddBox(pos, size, u, v, scale, mirrored); - } - model.AddPart(part); - } - modelFile.AddModel(model); - - } - return modelFile; - } - - private string ReadString(Stream stream) - { - short length = ReadShort(stream); - return ReadString(stream, length, Encoding.ASCII); - } - - } -} diff --git a/PCK-Studio/Classes/IO/Model/ModelFileWriter.cs b/PCK-Studio/Classes/IO/Model/ModelFileWriter.cs deleted file mode 100644 index 93b1afca..00000000 --- a/PCK-Studio/Classes/IO/Model/ModelFileWriter.cs +++ /dev/null @@ -1,89 +0,0 @@ -using PckStudio.Classes.FileTypes; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace PckStudio.Classes.IO.Model -{ - internal class ModelFileWriter : StreamDataWriter - { - private ModelFile _modelFile; - private int _fileVersion; - public static void Write(Stream stream, ModelFile modelFile, int fileVersion = 1) - { - new ModelFileWriter(modelFile, fileVersion).WriteToStream(stream); - } - - public ModelFileWriter(ModelFile modelFile, int fileVersion) : base(false) - { - _modelFile = modelFile; - if (fileVersion < 0 || fileVersion > 2) - throw new InvalidDataException(nameof(fileVersion)); - _fileVersion = fileVersion; - } - - protected override void WriteToStream(Stream stream) - { - WriteInt(stream, _fileVersion); - WriteInt(stream, _modelFile.Models.Count); - foreach (var model in _modelFile.Models) - { - WriteString(stream, model.name); - WriteInt(stream, model.textureSize.Width); - WriteInt(stream, model.textureSize.Height); - WriteInt(stream, model.parts.Count); - foreach (var part in model.parts) - { - WriteString(stream, part.name); - - if (_fileVersion > 1) - { - WriteString(stream, model.parts[0].name.Equals(part.name) ? string.Empty : model.parts[0].name); - } - - WriteFloat(stream, part.position.x); - WriteFloat(stream, part.position.y); - WriteFloat(stream, part.position.z); - - WriteFloat(stream, part.rotation.yaw); - WriteFloat(stream, part.rotation.pitch); - WriteFloat(stream, part.rotation.roll); - - if (_fileVersion > 0) - { - WriteFloat(stream, 0.0f); - WriteFloat(stream, 0.0f); - WriteFloat(stream, 0.0f); - } - - WriteInt(stream, part.Boxes.Count); - foreach (var box in part.Boxes) - { - WriteFloat(stream, box.Position.x); - WriteFloat(stream, box.Position.y); - WriteFloat(stream, box.Position.z); - - WriteInt(stream, box.Size.width); - WriteInt(stream, box.Size.height); - WriteInt(stream, box.Size.length); - - WriteFloat(stream, box.U); - WriteFloat(stream, box.V); - WriteFloat(stream, box.Scale); - - WriteBool(stream, box.Mirror); - } - } - } - } - - private void WriteString(Stream stream, string s) - { - WriteShort(stream, (short)s.Length); - WriteString(stream, s, Encoding.ASCII); - } - } -} diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index cd70f98a..5b66860c 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -172,7 +172,6 @@ - @@ -180,8 +179,6 @@ - - diff --git a/Vendor/OMI-Lib b/Vendor/OMI-Lib index f9460502..c2207ce4 160000 --- a/Vendor/OMI-Lib +++ b/Vendor/OMI-Lib @@ -1 +1 @@ -Subproject commit f94605028c0af00ffbe2989f286b8c9b6a87bcaf +Subproject commit c2207ce4dbbba0323776d07d2eb50c9cad603446