From 7dd08cb735f86d1ea30418f22d5f14e2f39b6d4b Mon Sep 17 00:00:00 2001 From: Martin Ashton Date: Thu, 19 Dec 2024 13:07:08 -0500 Subject: [PATCH] Added VimModel.cs and sketched interface --- src/cs/vim/Vim.Format/VimModel.cs | 157 ++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 src/cs/vim/Vim.Format/VimModel.cs diff --git a/src/cs/vim/Vim.Format/VimModel.cs b/src/cs/vim/Vim.Format/VimModel.cs new file mode 100644 index 00000000..c87bdce9 --- /dev/null +++ b/src/cs/vim/Vim.Format/VimModel.cs @@ -0,0 +1,157 @@ +using System; +using System.IO; +using Vim.Format.ObjectModel; +using Vim.G3d; +using Vim.Math3d; +using Vim.Util; + +namespace Vim.Format +{ + public interface IVimModel + { + /// + /// The schema version contained in the header of the VIM file. + /// + SerializableVersion SchemaVersion { get; } + + /// + /// The header of the VIM file. + /// + SerializableHeader Header { get; } + + /// + /// The serializable version of the VIM model. + /// + SerializableDocument SerializableDocument { get; } + + /// + /// The VIM file path if it was loaded from a file on disk. + /// + string FilePath { get; } // not null if the VIM was loaded from a file on disk + + /// + /// The string buffer for the Entities + /// + string[] StringBuffer { get; } + + /// + /// The entities contained in the VIM. + /// + EntityTableSet Entities { get; } + + /// + /// The collection of all instances in the VIM (i.e. the renderable geometry) + /// + IVimInstance[] Instances { get; } + + /// + /// The world-space bounding box surrounding all the instances in the model. + /// + AABox BoundingBox { get; } + + /// + /// Merges this VIM model with the other VIM model and returns a new one. + /// + IVimModel Merge(IVimModel other); + + /// + /// Writes the VIM model to the given stream + /// + void Write(Stream stream); + + /// + /// Writes the VIM model to the given file path. + /// Deletes any existing file prior to writing. + /// Creates the parent directory if it does not already exist. + /// + void Write(string filePath); + } + + public interface IVimInstance + { + /// + /// The index of the instance. + /// + int Index { get; } + + /// + /// The instance flags associated to this instance. + /// + InstanceFlags InstanceFlags { get; } + + /// + /// The world transform of the instance. + /// + Matrix4x4 WorldTransform { get; } + + /// + /// The mesh associated to an instance can be null. + /// + IVimMesh Mesh { get; } + + /// + /// The Node entity related to this instance. + /// There is a 1:1 relationship between instances and nodes. + /// + Node Node { get; } + + /// + /// The world-space axis aligned bounding box of the instance. + /// + AABox BoundingBox { get; } + } + + public interface IVimMesh + { + int Index { get; } + IVimSubmesh[] Submeshes { get; } + } + + public interface IVimSubmesh + { + int Index { get; } + IVimRenderMaterial Material { get; } + Vector3[] Vertices { get; } + int[] Indices { get; } + } + + public interface IVimRenderMaterial + { + int Index { get; } + Vector4 Color { get; } // rgba + float Glossiness { get; } + float Smoothness { get; } + } + + public class VimModel : IVimModel + { + public static IVimModel Load( + Stream stream, + LoadOptions loadOptions = null) + { + throw new NotImplementedException(); + } + + public static IVimModel Load( + string filePath, + LoadOptions loadOptions = null) + { + // TODO: create a read file stream and invoke Load with the stream + throw new NotImplementedException(); + } + + public SerializableVersion SchemaVersion { get; } + public SerializableHeader Header { get; } + public SerializableDocument SerializableDocument { get; } + public string FilePath { get; } + public string[] StringBuffer { get; } + public EntityTableSet Entities { get; } + public IVimInstance[] Instances { get; } + public AABox BoundingBox { get; } + public IVimModel Merge(IVimModel other) => throw new NotImplementedException(); + + public void Write(Stream stream) => throw new NotImplementedException(); + + public void Write(string filePath) => throw new NotImplementedException(); + } +}