private void buttonExtract_Click(object sender, EventArgs e) { TreeNode node = filesTV.SelectedNode; if (node == null) { return; } if (node.Tag is PackedFile) { PackedFile file = node.Tag as PackedFile; saveDialog.FileName = System.IO.Path.GetFileName(file.Filename); DialogResult ret = saveDialog.ShowDialog(); if ((ret == DialogResult.OK) && (saveDialog.FileName != "")) { byte[] buffer = file.GetContents(); using (BinaryWriter writer = new BinaryWriter(File.Open(saveDialog.FileName, FileMode.Create, FileAccess.Write))) { writer.Write(buffer); } MessageBox.Show("Resource extracted!"); } } }
private void showGEO(PackedFile geoFile) { if (geoFile.GetFileType() != TRFileType.GEO) { return; } using (MemoryStream memory = new MemoryStream(geoFile.GetContents())) { try { ChunkFile chunkie = new ChunkFile(); if (chunkie.Load(memory)) { GBODChunk gbod = chunkie.Chunks[0] as GBODChunk; var meshes = Viewer.ModelCreator.Generate(gbod, viewer3D.DX); viewer3D.DisplayMeshes(meshes); return; } } catch (Exception) { } MessageBox.Show("Failed to load geometry file"); } }
private void btnTest_Click(object sender, EventArgs e) { TreeNode node = filesTV.SelectedNode; if (node.Tag is PackedFile) { PackedFile file = node.Tag as PackedFile; using (MemoryStream memory = new MemoryStream(file.GetContents())) { ChunkFile chunkie = new ChunkFile(); if (chunkie.Load(memory)) { MessageBox.Show("SUCCESS"); } else { MessageBox.Show("FAIL"); } } } }
private void showImage(PackedFile imageFile) { viewer3D.DisplayTexture(imageFile.GetContents()); }