public virtual void Load(BinaryReader reader) { char h0, h1, h2; bool littleEndian; ReadChunk(out h0, out h1, out h2, out littleEndian, reader); if ((h0 != 'O') && (h1 != 'P') && (h2 != 'C')) { throw new OpcodeException("Invalid 'OPC' header"); } bool platformMismatch = !littleEndian; uint version = ReadDword(reader, platformMismatch); if (version != SupportedModelVersion) { throw new OpcodeException($"Unsupported model version {version}"); } modelCode = (ModelFlag)ReadDword(reader, platformMismatch); CreateTree(); tree.Load(reader, platformMismatch); }
/// <summary> /// Initializes a new instance of the <see cref="MODL"/> class. /// </summary> /// <param name="from">The <see cref="BaseChunk" /> to use for creating this Chunk. The given data will be interpreted respectively.</param> public MODL(BaseChunk from) : base(from) { while (!EndOfData) { BaseChunk nextChunk = ReadChunk(); switch (nextChunk.ChunkName) { case "MTYP": Type = (MTYP)nextChunk.ReadInt32(); break; case "MNDX": index = nextChunk.ReadInt32(); break; case "NAME": Name = nextChunk.ReadString(nextChunk.Data.Length); break; case "PRNT": parentName = nextChunk.ReadString(nextChunk.Data.Length); break; case "FLGS": Flag = new ModelFlag(true, nextChunk.ReadInt32()); break; case "TRAN": Scale = nextChunk.ReadVector3(); Rotation = nextChunk.ReadVector3(); Translation = nextChunk.ReadVector3(); UnknownTRAN = nextChunk.ReadFloat(); break; case "GEOM": Geometry = new GEOM(nextChunk); break; } } }