| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Runtime.InteropServices;
- namespace OpenVIII.Battle.Dat
- {
- /// <summary>
- /// Section 2: Model geometry
- /// </summary>
- /// <see cref="http://wiki.ffrtt.ru/index.php?title=FF8/FileFormat_DAT#Header_.28data_sub_table.29"/>
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- public class Geometry
- {
- #region Fields
- /// <summary>
- /// Number of objects
- /// </summary>
- public readonly int CObjects;
- /// <summary>
- /// Object Data (see below)
- /// </summary>
- public readonly IReadOnlyList<Object> Objects;
- /// <summary>
- /// Object Positions
- /// </summary>
- public readonly IReadOnlyList<uint> PObjects;
- /// <summary>
- /// Total count of vertices
- /// </summary>
- public readonly uint CTotalVertices;
- #endregion Fields
- #region Constructors
- private Geometry(BinaryReader br, long byteOffset)
- {
- CObjects = br.ReadInt32();
- PObjects = Enumerable.Range(0, CObjects).Select(_ => br.ReadUInt32()).ToList().AsReadOnly();
- Objects = PObjects.Select(pOffset => Object.CreateInstance(br, pOffset + byteOffset)).ToList().AsReadOnly();
- CTotalVertices = br.ReadUInt32();
- }
- #endregion Constructors
- #region Methods
- public static Geometry CreateInstance(BinaryReader br, long byteOffset)
- {
- br.BaseStream.Seek(byteOffset, SeekOrigin.Begin);
- return new Geometry(br, byteOffset);
- }
- #endregion Methods
- }
- }
|