private void exportBtn_Click(object sender, EventArgs e) { SaveFileDialog ef = new SaveFileDialog(); ef.Title = rm.GetString("exportModelBld"); ef.Filter = rm.GetString("modelFile"); if (ef.ShowDialog() == DialogResult.OK) { if (ef.FileName.EndsWith(".obj")) { try { NsbmdGlRenderer rendererOBJ = new NsbmdGlRenderer { Model = _nsbmd.models[0] }; rendererOBJ.RipModel(ef.FileName); } catch { MessageBox.Show(rm.GetString("invalidFile"), null, MessageBoxButtons.OK, MessageBoxIcon.Stop); } return; } File.Copy(bldPath + "\\" + listBox1.SelectedIndex.ToString("D4"),ef.FileName, true); } return; }
// Export NSBMD / OBJ private void button10_Click(object sender, EventArgs e) { if (comboBox4.SelectedIndex == 0) { SaveFileDialog ef = new SaveFileDialog(); ef.Title = rm.GetString("exportModel"); ef.Filter = rm.GetString("modelFile"); if (ef.ShowDialog() == DialogResult.OK) { if (ef.FileName.EndsWith(".obj")) { try { NsbmdGlRenderer rendererOBJ = new NsbmdGlRenderer { Model = _nsbmd.models[0] }; rendererOBJ.RipModel(ef.FileName); } catch { MessageBox.Show("There was a problem when exporting. Operation aborted.", null, MessageBoxButtons.OK, MessageBoxIcon.Stop); } return; } System.IO.BinaryReader readMap = new System.IO.BinaryReader(File.OpenRead(mapFileName + "\\" + comboBox2.SelectedIndex.ToString("D4"))); if (gameID == 0x45414441 || gameID == 0x45415041 || gameID == 0x53414441 || gameID == 0x53415041 || gameID == 0x46414441 || gameID == 0x46415041 || gameID == 0x49414441 || gameID == 0x49415041 || gameID == 0x44414441 || gameID == 0x44415041 || gameID == 0x4A414441 || gameID == 0x4A415041 || gameID == 0x4B414441 || gameID == 0x4B415041 || gameID == 0x45555043 || gameID == 0x53555043 || gameID == 0x46555043 || gameID == 0x49555043 || gameID == 0x44555043 || gameID == 0x4A555043 || gameID == 0x4B555043) { readMap.BaseStream.Position = 0x10 + permissionSize + buildingsSize; } else { readMap.BaseStream.Position = 0x14 + unknownSize + permissionSize + buildingsSize; } System.IO.BinaryWriter export = new System.IO.BinaryWriter(File.OpenWrite(ef.FileName)); string exportfilename; exportfilename = ef.FileName; export.BaseStream.Position = 0x00; export.BaseStream.SetLength(modelSize); for (int i = 0; i < modelSize; i++) { export.Write(readMap.ReadByte()); // Reads byte and writes it to file } export.Close(); readMap.Close(); } return; } else { SaveFileDialog ef = new SaveFileDialog(); ef.Title = "Export Model Section with Textures as..."; ef.Filter = rm.GetString("modelFile"); if (ef.ShowDialog() == DialogResult.OK) { if (ef.FileName.EndsWith(".obj")) { try { NsbmdGlRenderer rendererOBJ = new NsbmdGlRenderer { Model = _nsbmd.models[0] }; rendererOBJ.RipModel(ef.FileName); } catch { MessageBox.Show("There was a problem when exporting. Operation aborted.", null, MessageBoxButtons.OK, MessageBoxIcon.Stop); } return; } System.IO.BinaryReader readMap = new System.IO.BinaryReader(File.OpenRead(Form1.mapFileName + "\\" + Form1.mapIndex.ToString("D4"))); if (Form1.gameID == 0x45414441 || Form1.gameID == 0x45415041 || Form1.gameID == 0x53414441 || Form1.gameID == 0x53415041 || Form1.gameID == 0x46414441 || Form1.gameID == 0x46415041 || Form1.gameID == 0x49414441 || Form1.gameID == 0x49415041 || Form1.gameID == 0x44414441 || Form1.gameID == 0x44415041 || Form1.gameID == 0x4A414441 || Form1.gameID == 0x4A415041 || Form1.gameID == 0x4B414441 || Form1.gameID == 0x4B415041 || Form1.gameID == 0x45555043 || Form1.gameID == 0x53555043 || Form1.gameID == 0x46555043 || Form1.gameID == 0x49555043 || Form1.gameID == 0x44555043 || Form1.gameID == 0x4A555043 || Form1.gameID == 0x4B555043) { readMap.BaseStream.Position = 0x10 + Form1.permissionSize + Form1.buildingsSize; } else { readMap.BaseStream.Position = 0x14 + Form1.unknownSize + Form1.permissionSize + Form1.buildingsSize; } System.IO.BinaryWriter export = new System.IO.BinaryWriter(File.OpenWrite(ef.FileName)); export.BaseStream.Position = 0x00; export.BaseStream.SetLength(Form1.modelSize); for (int i = 0; i < 0xe; i++) { export.Write(readMap.ReadByte()); // Reads header bytes and writes them to file } export.Write((Int16)0x0002); // Writes texture flag export.Write((Int16)0x0018); export.Write((Int16)0x0); export.Write(0x0); // Writes blank BTX offset readMap.BaseStream.Position += 0x6; for (int i = 0; i < Form1.modelSize - 0x14; i++) { export.Write(readMap.ReadByte()); // Writes model section } readMap.Close(); if (Form1.gameID == 0x45414441 || Form1.gameID == 0x45415041 || Form1.gameID == 0x53414441 || Form1.gameID == 0x53415041 || Form1.gameID == 0x46414441 || Form1.gameID == 0x46415041 || Form1.gameID == 0x49414441 || Form1.gameID == 0x49415041 || Form1.gameID == 0x44414441 || Form1.gameID == 0x44415041 || Form1.gameID == 0x4A414441 || Form1.gameID == 0x4A415041 || Form1.gameID == 0x4B414441 || Form1.gameID == 0x4B415041 || Form1.gameID == 0x45555043 || Form1.gameID == 0x53555043 || Form1.gameID == 0x46555043 || Form1.gameID == 0x49555043 || Form1.gameID == 0x44555043 || Form1.gameID == 0x4A555043 || Form1.gameID == 0x4B555043) { File.Copy(workingFolder + @"data\fielddata\areadata\area_map_tex\map_tex_set\" + (comboBox4.SelectedIndex - 1).ToString("D4"), ef.FileName + "tex"); } else { File.Copy(workingFolder + @"data\a\0\4\texture\" + (comboBox4.SelectedIndex - 1).ToString("D4"), ef.FileName + "tex"); } System.IO.BinaryReader readTex = new System.IO.BinaryReader(File.OpenRead(ef.FileName + "tex")); long texLength = readTex.BaseStream.Length - 0x14; readTex.BaseStream.Position = 0x14; long texOffset = export.BaseStream.Position; for (int i = 0; i < texLength; i++) { export.Write(readTex.ReadByte()); // Writes BTX section } export.BaseStream.Position = 0x8; export.Write((int)((Form1.modelSize + 0x4) + texLength)); export.BaseStream.Position = 0x14; export.Write((int)texOffset); export.Close(); readTex.Close(); File.Delete(ef.FileName + "tex"); } return; } }
// Gen V Export NSBMD / OBJ private void exportNSBMD(object sender, EventArgs e) { if (comboBox4.SelectedIndex == 0) { SaveFileDialog ef = new SaveFileDialog(); ef.Title = rm.GetString("exportModel"); ef.Filter = rm.GetString("modelFile"); if (ef.ShowDialog() == DialogResult.OK) { if (ef.FileName.EndsWith(".obj")) { try { NsbmdGlRenderer rendererOBJ = new NsbmdGlRenderer { Model = _nsbmd.models[0] }; rendererOBJ.RipModel(ef.FileName); } catch { MessageBox.Show("There was a problem when exporting. Operation aborted.", null, MessageBoxButtons.OK, MessageBoxIcon.Stop); } return; } System.IO.BinaryReader readMap = new System.IO.BinaryReader(File.OpenRead(workingFolder + @"data\a\0\0\maps" + "\\" + comboBox8.SelectedIndex.ToString("D4"))); readMap.BaseStream.Position = vmodelOffset; System.IO.BinaryWriter export = new System.IO.BinaryWriter(File.Create(ef.FileName)); string exportfilename; exportfilename = ef.FileName; export.BaseStream.Position = 0x00; for (int i = 0; i < offset2 - vmodelOffset; i++) { export.Write(readMap.ReadByte()); // Reads byte and writes it to file } export.Close(); readMap.Close(); } return; } else { SaveFileDialog ef = new SaveFileDialog(); ef.Title = "Export Model Section with Textures as..."; ef.Filter = rm.GetString("modelFile"); if (ef.ShowDialog() == DialogResult.OK) { if (ef.FileName.EndsWith(".obj")) { try { NsbmdGlRenderer rendererOBJ = new NsbmdGlRenderer { Model = _nsbmd.models[0] }; rendererOBJ.RipModel(ef.FileName); } catch { MessageBox.Show("There was a problem when exporting. Operation aborted.", null, MessageBoxButtons.OK, MessageBoxIcon.Stop); } return; } System.IO.BinaryReader readMap = new System.IO.BinaryReader(File.OpenRead(workingFolder + @"data\a\0\0\maps" + "\\" + comboBox8.SelectedIndex.ToString("D4"))); readMap.BaseStream.Position = vmodelOffset; System.IO.BinaryWriter export = new System.IO.BinaryWriter(File.Create(ef.FileName)); export.BaseStream.Position = 0x00; for (int i = 0; i < 0xe; i++) { export.Write(readMap.ReadByte()); // Reads header bytes and writes them to file } export.Write((Int16)0x0002); // Writes texture flag export.Write((Int16)0x0018); export.Write((Int16)0x0); export.Write(0x0); // Writes blank BTX offset readMap.BaseStream.Position += 0x6; for (int i = 0; i < (offset2 - vmodelOffset) - 0x14; i++) { export.Write(readMap.ReadByte()); // Writes model section } readMap.Close(); File.Copy(workingFolder + @"data\a\0\1\tilesets" + "\\" + (comboBox7.SelectedIndex - 1).ToString("D4"), ef.FileName + "tex"); System.IO.BinaryReader readTex = new System.IO.BinaryReader(File.OpenRead(ef.FileName + "tex")); long texLength = readTex.BaseStream.Length - 0x14; readTex.BaseStream.Position = 0x14; long texOffset = export.BaseStream.Position; for (int i = 0; i < texLength; i++) { export.Write(readTex.ReadByte()); // Writes BTX section } export.BaseStream.Position = 0x8; export.Write((int)((offset2 - vmodelOffset + 0x4) + texLength)); export.BaseStream.Position = 0x14; export.Write((int)texOffset); export.Close(); readTex.Close(); File.Delete(ef.FileName + "tex"); } return; } }
// Export model private void exportBtn_Click(object sender, EventArgs e) { SaveFileDialog ef = new SaveFileDialog(); ef.Title = rm.GetString("exportModelBld"); ef.Filter = rm.GetString("modelFile"); if (ef.ShowDialog() == DialogResult.OK) { if (ef.FileName.EndsWith(".obj")) { try { NsbmdGlRenderer rendererOBJ = new NsbmdGlRenderer { Model = _nsbmd.models[0] }; rendererOBJ.RipModel(ef.FileName); } catch { MessageBox.Show(rm.GetString("invalidFile"), null, MessageBoxButtons.OK, MessageBoxIcon.Stop); } return; } BinaryWriter export = new BinaryWriter(File.Create(ef.FileName)); BinaryReader read = new BinaryReader(File.OpenRead(bldPath + "\\" + "model" + "\\" + listBox1.SelectedIndex.ToString("D4"))); for (int i = 0; i < 0xe; i++) { export.Write(read.ReadByte()); // Reads header bytes and writes them to file } export.Write((Int16)0x0002); // Writes texture flag export.Write((Int16)0x0018); export.Write((Int16)0x0); export.Write(0x0); // Writes blank BTX offset read.BaseStream.Position += 0x6; for (int i = 0; i < read.BaseStream.Length - 0x14; i++) { export.Write(read.ReadByte()); // Writes model section } read.Close(); string tex; if (!checkBox1.Checked) { tex= Form1.workingFolder + @"data\a\1\7\bldtilesets" + "\\" + comboBox1.SelectedIndex.ToString("D4"); } else { tex = Form1.workingFolder + @"data\a\1\7\bld2tilesets" + "\\" + comboBox1.SelectedIndex.ToString("D4"); } System.IO.BinaryReader readTex = new System.IO.BinaryReader(File.OpenRead(tex)); long texLength = readTex.BaseStream.Length - 0x14; readTex.BaseStream.Position = 0x14; long texOffset = export.BaseStream.Position; for (int i = 0; i < texLength; i++) { export.Write(readTex.ReadByte()); // Writes BTX section } export.BaseStream.Position = 0x8; export.Write((int)(new FileInfo(bldPath + "\\" + "model" + "\\" + listBox1.SelectedIndex.ToString("D4")).Length + 0x4 + texLength)); export.BaseStream.Position = 0x14; export.Write((int)texOffset); export.Close(); readTex.Close(); } return; }