public void ImportMapModel(Stream newData) { using (BinaryReader reader = new BinaryReader(newData)) { reader.BaseStream.Position = 0xE; if (reader.ReadInt16() > 1) // If there is more than one file, it means there are embedded textures we must remove { using (BinaryWriter writer = new BinaryWriter(new MemoryStream())) { reader.BaseStream.Position = 0x1C; uint mdl0Size = reader.ReadUInt32(); // Read mdl0 file size reader.BaseStream.Position = 0x0; writer.Write(reader.ReadBytes(0x8)); // Write firt header bytes, same for all NSBMD. writer.Write(mdl0Size + 0x14); writer.Write((short)0x10); // Writes BMD0 header size (always 16) writer.Write((short)0x1); // Write new number of sub-files, since embedded textures are removed writer.Write(0x14); // Writes new start offset of MDL0 reader.BaseStream.Position = 0x18; writer.Write(reader.ReadBytes((int)mdl0Size)); // Writes MDL0; mapModelData = ((MemoryStream)writer.BaseStream).ToArray(); } } else { reader.BaseStream.Position = 0x0; mapModelData = reader.ReadBytes((int)newData.Length); } mapModel = NSBMDLoader.LoadNSBMD(new MemoryStream(mapModelData)); } }
private void LoadBuildingModel(int modelID, bool interior) { string path = folder + rom.GetBuildingModelsDirPath(interior) + "\\" + modelID.ToString("D4"); using (Stream fs = new FileStream(path, FileMode.Open)) currentNSBMD = NSBMDLoader.LoadNSBMD(fs); }