|
| 1 | +using System; |
| 2 | +using System.IO; |
| 3 | +using Vim.Format.ObjectModel; |
| 4 | +using Vim.G3d; |
| 5 | +using Vim.Math3d; |
| 6 | +using Vim.Util; |
| 7 | + |
| 8 | +namespace Vim.Format |
| 9 | +{ |
| 10 | + public interface IVimModel |
| 11 | + { |
| 12 | + /// <summary> |
| 13 | + /// The schema version contained in the header of the VIM file. |
| 14 | + /// </summary> |
| 15 | + SerializableVersion SchemaVersion { get; } |
| 16 | + |
| 17 | + /// <summary> |
| 18 | + /// The header of the VIM file. |
| 19 | + /// </summary> |
| 20 | + SerializableHeader Header { get; } |
| 21 | + |
| 22 | + /// <summary> |
| 23 | + /// The serializable version of the VIM model. |
| 24 | + /// </summary> |
| 25 | + SerializableDocument SerializableDocument { get; } |
| 26 | + |
| 27 | + /// <summary> |
| 28 | + /// The VIM file path if it was loaded from a file on disk. |
| 29 | + /// </summary> |
| 30 | + string FilePath { get; } // not null if the VIM was loaded from a file on disk |
| 31 | + |
| 32 | + /// <summary> |
| 33 | + /// The string buffer for the Entities |
| 34 | + /// </summary> |
| 35 | + string[] StringBuffer { get; } |
| 36 | + |
| 37 | + /// <summary> |
| 38 | + /// The entities contained in the VIM. |
| 39 | + /// </summary> |
| 40 | + EntityTableSet Entities { get; } |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// The collection of all instances in the VIM (i.e. the renderable geometry) |
| 44 | + /// </summary> |
| 45 | + IVimInstance[] Instances { get; } |
| 46 | + |
| 47 | + /// <summary> |
| 48 | + /// The world-space bounding box surrounding all the instances in the model. |
| 49 | + /// </summary> |
| 50 | + AABox BoundingBox { get; } |
| 51 | + |
| 52 | + /// <summary> |
| 53 | + /// Merges this VIM model with the other VIM model and returns a new one. |
| 54 | + /// </summary> |
| 55 | + IVimModel Merge(IVimModel other); |
| 56 | + |
| 57 | + /// <summary> |
| 58 | + /// Writes the VIM model to the given stream |
| 59 | + /// </summary> |
| 60 | + void Write(Stream stream); |
| 61 | + |
| 62 | + /// <summary> |
| 63 | + /// Writes the VIM model to the given file path. |
| 64 | + /// Deletes any existing file prior to writing. |
| 65 | + /// Creates the parent directory if it does not already exist. |
| 66 | + /// </summary> |
| 67 | + void Write(string filePath); |
| 68 | + } |
| 69 | + |
| 70 | + public interface IVimInstance |
| 71 | + { |
| 72 | + /// <summary> |
| 73 | + /// The index of the instance. |
| 74 | + /// </summary> |
| 75 | + int Index { get; } |
| 76 | + |
| 77 | + /// <summary> |
| 78 | + /// The instance flags associated to this instance. |
| 79 | + /// </summary> |
| 80 | + InstanceFlags InstanceFlags { get; } |
| 81 | + |
| 82 | + /// <summary> |
| 83 | + /// The world transform of the instance. |
| 84 | + /// </summary> |
| 85 | + Matrix4x4 WorldTransform { get; } |
| 86 | + |
| 87 | + /// <summary> |
| 88 | + /// The mesh associated to an instance can be null. |
| 89 | + /// </summary> |
| 90 | + IVimMesh Mesh { get; } |
| 91 | + |
| 92 | + /// <summary> |
| 93 | + /// The Node entity related to this instance. |
| 94 | + /// There is a 1:1 relationship between instances and nodes. |
| 95 | + /// </summary> |
| 96 | + Node Node { get; } |
| 97 | + |
| 98 | + /// <summary> |
| 99 | + /// The world-space axis aligned bounding box of the instance. |
| 100 | + /// </summary> |
| 101 | + AABox BoundingBox { get; } |
| 102 | + } |
| 103 | + |
| 104 | + public interface IVimMesh |
| 105 | + { |
| 106 | + int Index { get; } |
| 107 | + IVimSubmesh[] Submeshes { get; } |
| 108 | + } |
| 109 | + |
| 110 | + public interface IVimSubmesh |
| 111 | + { |
| 112 | + int Index { get; } |
| 113 | + IVimRenderMaterial Material { get; } |
| 114 | + Vector3[] Vertices { get; } |
| 115 | + int[] Indices { get; } |
| 116 | + } |
| 117 | + |
| 118 | + public interface IVimRenderMaterial |
| 119 | + { |
| 120 | + int Index { get; } |
| 121 | + Vector4 Color { get; } // rgba |
| 122 | + float Glossiness { get; } |
| 123 | + float Smoothness { get; } |
| 124 | + } |
| 125 | + |
| 126 | + public class VimModel : IVimModel |
| 127 | + { |
| 128 | + public static IVimModel Load( |
| 129 | + Stream stream, |
| 130 | + LoadOptions loadOptions = null) |
| 131 | + { |
| 132 | + throw new NotImplementedException(); |
| 133 | + } |
| 134 | + |
| 135 | + public static IVimModel Load( |
| 136 | + string filePath, |
| 137 | + LoadOptions loadOptions = null) |
| 138 | + { |
| 139 | + // TODO: create a read file stream and invoke Load with the stream |
| 140 | + throw new NotImplementedException(); |
| 141 | + } |
| 142 | + |
| 143 | + public SerializableVersion SchemaVersion { get; } |
| 144 | + public SerializableHeader Header { get; } |
| 145 | + public SerializableDocument SerializableDocument { get; } |
| 146 | + public string FilePath { get; } |
| 147 | + public string[] StringBuffer { get; } |
| 148 | + public EntityTableSet Entities { get; } |
| 149 | + public IVimInstance[] Instances { get; } |
| 150 | + public AABox BoundingBox { get; } |
| 151 | + public IVimModel Merge(IVimModel other) => throw new NotImplementedException(); |
| 152 | + |
| 153 | + public void Write(Stream stream) => throw new NotImplementedException(); |
| 154 | + |
| 155 | + public void Write(string filePath) => throw new NotImplementedException(); |
| 156 | + } |
| 157 | +} |
0 commit comments