diff --git a/project/code/LGS/ModelFile.cs b/project/code/LGS/ModelFile.cs index 181b28a..47bb77c 100644 --- a/project/code/LGS/ModelFile.cs +++ b/project/code/LGS/ModelFile.cs @@ -136,12 +136,31 @@ public class ModelFile } } + public struct Material + { + public string Name; + public byte Type; + public byte Slot; + public uint Handle; + public float Uv; + + public Material(BinaryReader reader) + { + Name = Encoding.UTF8.GetString(reader.ReadBytes(16)).Replace("\0", string.Empty); + Type = reader.ReadByte(); + Slot = reader.ReadByte(); + Handle = reader.ReadUInt32(); + Uv = reader.ReadSingle(); + } + } + public BHeader BinHeader { get; set; } public MHeader Header { get; set; } public Vector3[] Vertices { get; } public Vector2[] Uvs { get; } public Vector3[] Normals { get; } public Polygon[] Polygons { get; } + public Material[] Materials { get; } public ModelFile(string filename) { @@ -178,5 +197,11 @@ public class ModelFile { Polygons[i] = new Polygon(reader, BinHeader.Version); } + stream.Seek(Header.MaterialOffset, SeekOrigin.Begin); + Materials = new Material[Header.MaterialCount]; + for (var i = 0; i < Materials.Length; i++) + { + Materials[i] = new Material(reader); + } } } \ No newline at end of file