private void LoadMapDPP(BinaryReader reader) { Nsbmd nsbmd; BinaryWriter writer; string[] materialListForNsbmd; PkmnMapDemuxer demuxer = new PkmnMapDemuxer(reader, type); mapHeader = PkmnMapHeader.FromReader(reader); streamMovement = new ClosableMemoryStream(); writer = new BinaryWriter(streamMovement); writer.Write(demuxer.DemuxMovBytes(mapHeader)); arrayMovement = MovLoader.LoadMov(streamMovement); streamObject = new ClosableMemoryStream(); writer = new BinaryWriter(streamObject); writer.Write(demuxer.DemuxObjBytes(mapHeader)); listObjects = ObjLoader.LoadObj(streamObject); streamNSBMD = new ClosableMemoryStream(); writer = new BinaryWriter(streamNSBMD); writer.Write(demuxer.DemuxBMDBytes(mapHeader, 0)); streamBDHC = new ClosableMemoryStream(); writer = new BinaryWriter(streamBDHC); writer.Write(demuxer.DemuxBdhcBytes(mapHeader)); nsbmd = new Nsbmd(); var reader2 = new BinaryReader(streamNSBMD); nsbmd.LoadBMD0(reader2, (int)mapHeader.BMDOffset); actualModel = nsbmd; getMatrixInfo(); materialListForNsbmd = actualModel.getTexNameArray(); if (actualModel.actualTex != null) { nsbmd.MatchTextures(); } }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { var fileStream = new FileStream(bldPath + "\\" + "model" + "\\" + listBox1.SelectedIndex.ToString("D4"), FileMode.Open); file_2 = bldPath + "\\" + "model" + "\\" + listBox1.SelectedIndex.ToString("D4"); _nsbmd = NsbmdLoader.LoadNsbmd(fileStream); if (!checkBox1.Checked) { _nsbmd.materials = LibNDSFormats.NSBTX.NsbtxLoader.LoadNsbtx(new MemoryStream(File.ReadAllBytes(Form1.workingFolder + @"data\a\1\7\bldtilesets" + "\\" + comboBox1.SelectedIndex.ToString("D4"))), out _nsbmd.Textures, out _nsbmd.Palettes); } else { _nsbmd.materials = LibNDSFormats.NSBTX.NsbtxLoader.LoadNsbtx(new MemoryStream(File.ReadAllBytes(Form1.workingFolder + @"data\a\1\7\bld2tilesets" + "\\" + comboBox1.SelectedIndex.ToString("D4"))), out _nsbmd.Textures, out _nsbmd.Palettes); } try { _nsbmd.MatchTextures(); } catch { } RenderBuilding(null, null); fileStream.Close(); System.IO.BinaryReader readHeader = new System.IO.BinaryReader(File.OpenRead(bldPath + "\\" + "header" + "\\" + listBox1.SelectedIndex.ToString("D4"))); numericUpDown1.Value = readHeader.ReadUInt16(); // ID readHeader.BaseStream.Position += 2; numericUpDown2.Value = readHeader.ReadUInt16(); // Door ID numericUpDown3.Value = readHeader.ReadInt16(); // X numericUpDown4.Value = readHeader.ReadInt16(); // Y numericUpDown5.Value = readHeader.ReadInt16(); // Z readHeader.Close(); }
private void LoadMapBW(BinaryReader reader) { Nsbmd nsbmd; BinaryWriter writer; string[] materialListForNsbmd; PkmnMapDemuxer_Bw bw = new PkmnMapDemuxer_Bw(reader, type); mapHeaderBW = PkmnMapHeader_Bw.FromReader(reader); streamNSBMD = new ClosableMemoryStream(); writer = new BinaryWriter(streamNSBMD); writer.Write(bw.DemuxBMDBytes(mapHeaderBW, 0)); streamMovement = new ClosableMemoryStream(); writer = new BinaryWriter(streamMovement); writer.Write(bw.DemuxMovBytes(mapHeaderBW)); arrayMovementBW = MovLoader.LoadMov_Bw(streamMovement); streamObject = new ClosableMemoryStream(); writer = new BinaryWriter(streamObject); writer.Write(bw.DemuxObjBytes(mapHeaderBW)); listObjectsBW = ObjLoader.LoadObj_Bw(streamObject); nsbmd = new Nsbmd(); var reader2 = new BinaryReader(streamNSBMD); reader2.BaseStream.Position = 0; nsbmd.LoadBMD0(reader2, (int)mapHeaderBW.BMDOffset); actualModel = nsbmd; getMatrixInfo(); materialListForNsbmd = actualModel.getTexNameArray(); if (actualModel.actualTex != null) { nsbmd.MatchTextures(); } }
public void setModel(Nsbmd model, Boolean mode) { modelList.Add(model); //if (model.actualTex != null) //{ if (polyval > 1) { if (mode) { //MapEditor.Console.AppendText("\nStart texturing(Singular mode)"); MakeTexture(model.getMDL0at(0), model.getMaterials(), idActualMaterial, true); } else { //MapEditor.Console.AppendText("\nStart texturing(Normal map)"); MakeTexture(model.getMDL0at(0), model.getMaterials(), polMatList); } } else if (polyval == 0) { //MapEditor.Console.AppendText("\nStart texturing (One polygon map)"); MakeTexture(model.getMDL0at(0), model.getMaterials(), 0, true); } }
private void LoadGenericNSBMD(BinaryReader reader) { PkmnMapDemuxer demuxer; Nsbmd nsbmd; List <NsbmdModel.MatTexPalStruct> list; Nsbtx.type = NSBMD_MODEL; demuxer = new PkmnMapDemuxer(reader, 1); PkmnMapHeader map = new PkmnMapHeader(); streamNSBMD = new ClosableMemoryStream(); new BinaryWriter(streamNSBMD).Write(demuxer.DemuxBMDBytes(map, 1)); nsbmd = new Nsbmd(); var reader2 = new BinaryReader(streamNSBMD); nsbmd.LoadBMD0(reader2, 0); actualModel = nsbmd; list = null; list = nsbmd.getMaterials(); if (actualModel.actualTex != null) { nsbmd.MatchTextures(); } }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { var fileStream = new FileStream(bldPath + "\\" + listBox1.SelectedIndex.ToString("D4"), FileMode.Open); file_2 = bldPath + "\\" + listBox1.SelectedIndex.ToString("D4"); _nsbmd = NsbmdLoader.LoadNsbmd(fileStream); #region Create texture File.Create(Path.GetTempPath() + "BLDtexture.nsbtx").Close(); BinaryWriter writeBLDtexture = new BinaryWriter(File.OpenWrite(Path.GetTempPath() + "BLDtexture.nsbtx")); writeBLDtexture.Write((UInt32)0x30585442); writeBLDtexture.Write((UInt32)0x0001FEFF); fileStream.Position = 0x8; int nsbmdSize = fileStream.ReadByte() + (fileStream.ReadByte() << 8) + (fileStream.ReadByte() << 16) + (fileStream.ReadByte() << 24); fileStream.Position = 0x14; int nsbmdTexOffset = fileStream.ReadByte() + (fileStream.ReadByte() << 8) + (fileStream.ReadByte() << 16) + (fileStream.ReadByte() << 24); int texSize = nsbmdSize - nsbmdTexOffset + 0x14; writeBLDtexture.Write((UInt32)texSize); writeBLDtexture.Write((UInt32)0x00010010); writeBLDtexture.Write((UInt32)0x00000014); fileStream.Position = nsbmdTexOffset; for (int i = 0; i < texSize - 0x14; i++) { writeBLDtexture.Write((byte)fileStream.ReadByte()); } fileStream.Close(); writeBLDtexture.Close(); _nsbmd.materials = LibNDSFormats.NSBTX.NsbtxLoader.LoadNsbtx(new MemoryStream(File.ReadAllBytes(Path.GetTempPath() + "BLDtexture.nsbtx")), out _nsbmd.Textures, out _nsbmd.Palettes); #endregion try { _nsbmd.MatchTextures(); } catch { } RenderBuilding(null, null); comboBox1.SelectedIndex = 0; }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { renderer.ClearOBJ(); if (comboBox1.SelectedIndex == 0) { var fileStream = new FileStream(bldPath + "\\" + listBox1.SelectedIndex.ToString("D4"), FileMode.Open); file_2 = bldPath + "\\" + listBox1.SelectedIndex.ToString("D4"); _nsbmd = NsbmdLoader.LoadNsbmd(fileStream); fileStream.Close(); _nsbmd.materials = LibNDSFormats.NSBTX.NsbtxLoader.LoadNsbtx(new MemoryStream(File.ReadAllBytes(Path.GetTempPath() + "BLDtexture.nsbtx")), out _nsbmd.Textures, out _nsbmd.Palettes); try { _nsbmd.MatchTextures(); } catch { } simpleOpenGlControl1.Invalidate(); RenderBuilding(null, null); } else { _nsbmd.models[0].Palettes.Clear(); _nsbmd.models[0].Textures.Clear(); var fileStream = new FileStream(bldPath + "\\" + listBox1.SelectedIndex.ToString("D4"), FileMode.Open); file_2 = bldPath + "\\" + listBox1.SelectedIndex.ToString("D4"); _nsbmd = NsbmdLoader.LoadNsbmd(fileStream); fileStream.Close(); _nsbmd.materials = LibNDSFormats.NSBTX.NsbtxLoader.LoadNsbtx(new MemoryStream(File.ReadAllBytes(editorTileset + "\\" + (comboBox1.SelectedIndex - 1).ToString("D4"))), out _nsbmd.Textures, out _nsbmd.Palettes); try { _nsbmd.MatchTextures(); } catch { } simpleOpenGlControl1.Invalidate(); RenderBuilding(null, null); } }
public MapCreator(Maps actualMap) { InitializeComponent(); actualModel = actualMap.actualModel; }
/// <summary> /// Load NSBMD from stream. /// </summary> /// <param name="stream">Stream with NSBMD data.</param> /// <returns>NSBMD object.</returns> public static Nsbmd LoadNsbmd(Stream stream) { return(Nsbmd.FromStream(stream)); }