private void importBLKToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog() { Filter = "All supported files|*.bin;*.bdt|BIN files|*.bin|BDT files|*.bdt" }; if (openFile.ShowDialog() == DialogResult.OK) { if (Path.GetExtension(openFile.FileName).ToLower() == ".bdt") { visibilityFunctions.ChunkList.AddRange(VisibilityFunctions.LoadShadowVisibilityFile(new FileStream(openFile.FileName, FileMode.Open))); } else if (Path.GetExtension(openFile.FileName).ToLower() == ".bin") { visibilityFunctions.ChunkList.AddRange(VisibilityFunctions.LoadHeroesVisibilityFile(openFile.FileName)); } numericCurrentChunk.Minimum = 1; numericCurrentChunk.Maximum = visibilityFunctions.ChunkList.Count(); numericCurrentChunk.Value = visibilityFunctions.ChunkList.Count(); if (numericCurrentChunk.Maximum != 0) { numericCurrentChunk.Value = 1; } labelChunkAmount.Text = "Amount: " + visibilityFunctions.ChunkList.Count(); } }
private void buttonAutoChunk_Click(object sender, EventArgs e) { if (visibilityFunctions.ChunkList.Count > 0) { List <RenderWareModelFile> bspAndCol = new List <RenderWareModelFile>(); bspAndCol.AddRange(bspRenderer.BSPList); bspAndCol.AddRange(bspRenderer.ShadowColBSPList); VisibilityFunctions.AutoChunk((int)NumChunkNum.Value, bspAndCol, out bool success, out Vector3 Min, out Vector3 Max); if (success) { visibilityFunctions.ChunkList[(int)numericCurrentChunk.Value - 1].Min.X = (int)(Min.X - (int)numericUpDownAdd.Value); visibilityFunctions.ChunkList[(int)numericCurrentChunk.Value - 1].Min.Y = (int)(Min.Y - (int)numericUpDownAdd.Value); visibilityFunctions.ChunkList[(int)numericCurrentChunk.Value - 1].Min.Z = (int)(Min.Z - (int)numericUpDownAdd.Value); visibilityFunctions.ChunkList[(int)numericCurrentChunk.Value - 1].Max.X = (int)(Max.X + (int)numericUpDownAdd.Value); visibilityFunctions.ChunkList[(int)numericCurrentChunk.Value - 1].Max.Y = (int)(Max.Y + (int)numericUpDownAdd.Value); visibilityFunctions.ChunkList[(int)numericCurrentChunk.Value - 1].Max.Z = (int)(Max.Z + (int)numericUpDownAdd.Value); numericCurrentChunk_ValueChanged(new object(), new EventArgs()); } else { MessageBox.Show("I couldn't find any BSP with a matching chunk number."); } } }
public void initVisibilityEditor(bool isShadow, string fileName) { if (File.Exists(fileName)) { if (isShadow) { visibilityFunctions.OpenVisibilityFile = null; byte[] bytes = File.ReadAllBytes(fileName); visibilityFunctions.ChunkList = VisibilityFunctions.LoadShadowVisibilityFile(Archive.FromONEFile(ref bytes)); labelLoadedBLK.Text = ""; } else { visibilityFunctions.OpenVisibilityFile = fileName; visibilityFunctions.ChunkList = VisibilityFunctions.LoadHeroesVisibilityFile(visibilityFunctions.OpenVisibilityFile); labelLoadedBLK.Text = "Loaded " + fileName; } numericCurrentChunk.Minimum = 1; numericCurrentChunk.Maximum = visibilityFunctions.ChunkList.Count(); numericCurrentChunk.Value = visibilityFunctions.ChunkList.Count(); if (numericCurrentChunk.Maximum != 0) { numericCurrentChunk.Value = 1; } labelChunkAmount.Text = "Amount: " + visibilityFunctions.ChunkList.Count(); } }
public LevelEditor() { InitializeComponent(); visibilityFunctions = new VisibilityFunctions(); bspRenderer = new BSPRenderer(); shadowCollisionEditor = new ShadowCollisionEditor(bspRenderer); shadowSplineEditor = new ShadowSplineMenu(); }
private void saveToolStripMenuItem1_Click(object sender, EventArgs e) { if (visibilityFunctions.OpenVisibilityFile != null) { VisibilityFunctions.SaveHeroesVisibilityFile(visibilityFunctions.ChunkList, visibilityFunctions.OpenVisibilityFile); } else { saveAsToolStripMenuItem1_Click(sender, e); } }
private void ButtonAutoBuild_Click(object sender, EventArgs e) { DialogResult d = MessageBox.Show("Warning: this will overwrite the current chunk data with an automatically generated one. Continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (d != DialogResult.Yes) { return; } visibilityFunctions.ChunkList.Clear(); List <RenderWareModelFile> bspAndCol = new List <RenderWareModelFile>(); bspAndCol.AddRange(bspRenderer.BSPList); bspAndCol.AddRange(bspRenderer.ShadowColBSPList); HashSet <int> numbers = new HashSet <int>(); foreach (RenderWareModelFile rwmf in bspAndCol) { if (rwmf.ChunkNumber != -1) { numbers.Add(rwmf.ChunkNumber); } } Vector3 add = new Vector3((int)numericUpDownAdd.Value); foreach (int i in numbers) { VisibilityFunctions.AutoChunk(i, bspAndCol, out bool success, out Vector3 Min, out Vector3 Max); if (success) { visibilityFunctions.ChunkList.Add(new Chunk() { Max = Max + add, Min = Min - add, number = i }); } } visibilityFunctions.ChunkList = visibilityFunctions.ChunkList.OrderBy(c => c.number).ToList(); numericCurrentChunk.Minimum = 1; numericCurrentChunk.Maximum = visibilityFunctions.ChunkList.Count(); numericCurrentChunk.Value = visibilityFunctions.ChunkList.Count(); labelChunkAmount.Text = "Amount: " + visibilityFunctions.ChunkList.Count(); }
private void SaveShadowDATONE(string datOneFileName) { byte[] bdtBytes = VisibilityFunctions.ShadowVisibilityFileToArray(visibilityFunctions.ChunkList, bspRenderer.currentShadowFolderNamePrefix); byte[] splineBytes = shadowSplineEditor.ShadowSplinesToByteArray(bspRenderer.currentShadowFolderNamePrefix).ToArray(); Archive shadowDATONE; if (File.Exists(datOneFileName)) { byte[] fileContents = File.ReadAllBytes(datOneFileName); shadowDATONE = Archive.FromONEFile(ref fileContents); } else { shadowDATONE = new Archive(CommonRWVersions.Shadow050); } bool bdtFound = false; bool splFound = false; foreach (var file in shadowDATONE.Files) { if (Path.GetExtension(file.Name).ToLower() == ".bdt") { file.CompressedData = Prs.Compress(ref bdtBytes); bdtFound = true; } else if (file.Name == "PATH.PTP") { file.CompressedData = Prs.Compress(ref splineBytes); splFound = true; } } if (!bdtFound) { ArchiveFile file = new ArchiveFile((bspRenderer.currentShadowFolderNamePrefix + ".bdt").ToUpper(), bdtBytes); shadowDATONE.Files.Add(file); } if (!splFound) { ArchiveFile file = new ArchiveFile("PATH.PTP", splineBytes); shadowDATONE.Files.Add(file); } File.WriteAllBytes(datOneFileName, shadowDATONE.BuildShadowONEArchive(true).ToArray()); }
private void saveAsToolStripMenuItem1_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog() { Filter = "BIN files|*.bin", FileName = Path.GetFileName(visibilityFunctions.OpenVisibilityFile), AddExtension = true, DefaultExt = "bin", InitialDirectory = Path.GetDirectoryName(visibilityFunctions.OpenVisibilityFile) }; if (saveFileDialog.ShowDialog() == DialogResult.OK) { visibilityFunctions.OpenVisibilityFile = saveFileDialog.FileName; VisibilityFunctions.SaveHeroesVisibilityFile(visibilityFunctions.ChunkList, visibilityFunctions.OpenVisibilityFile); labelLoadedBLK.Text = "Loaded " + visibilityFunctions.OpenVisibilityFile; } }