public override void ViewWillDisappear(bool animated) { base.ViewWillDisappear(animated); Filesystem.RemoveObserver(this); if (NavigationController.ViewControllers.Count() == 1) { Filesystem.Dispose(); } }
static void Main(string[] args) { string[] files = { @"E:\Projects\Modding\Drome Racers\ARENA_CAR_textures\ARENA CAR\COLOUR_4\ARENA_CAR.XBX TEXTURE", @"E:\Projects\Modding\Drome Racers\ARENA_CAR_textures\ARENA CAR\COLOUR_4\COPY OF COLOUR_4\ARENA_CAR.XBX TEXTURE", @"E:\Projects\Modding\Drome Racers\ARENA_CAR_textures\ARENA CAR\COLOUR_4\COPY (2) OF COLOUR_4\ARENA_CAR.XBX TEXTURE" }; foreach (string p in files) { using (System.IO.FileStream s = new System.IO.FileStream(p, System.IO.FileMode.Open)) using (System.IO.BinaryReader reader = new System.IO.BinaryReader(s)) { Texture t = new Texture(reader); t.DumpTGA(p + ".tga"); } } System.Console.WriteLine("Done."); System.Console.ReadLine(); return; System.IO.StreamWriter log = new System.IO.StreamWriter("log.txt", false); /*LR2ModelExport(log); * log.Dispose(); * return;*/ Filesystem fs = new Filesystem(); fs.LoadArchive(BaseDir); /*foreach (FileEntry file in fs.Files.Values) * { * log.WriteLine(file); * } * log.WriteLine(); * foreach (BlockEntry block in fs.Blocks) * { * log.WriteLine(block); * }*/ //System.Console.WriteLine("Ready to parse MD2."); //System.Console.ReadKey(); /*FileEntry entry = fs.GetFileEntry(texFile); * * using (System.IO.MemoryStream ms = new System.IO.MemoryStream(fs.GetFileData(entry))) * using (System.IO.BinaryReader reader = new System.IO.BinaryReader(ms)) * { * ///MD2File model = new MD2File(reader); * //(model.Blocks["GEO2"] as GEO2Block).ExportOBJ("export.obj"); * * * Texture texture = new Texture(reader); * string path = System.IO.Path.ChangeExtension("dump\\" + entry.Filename.ToLower(), ".tga"); * string directory = System.IO.Path.GetDirectoryName(path); * System.IO.Directory.CreateDirectory(directory); * if (texture.PCTFormat != Texture.ImageFormat.DXT3) * { * texture.DumpTGA(path); * System.Console.WriteLine("Converted " + entry.Filename); * } * else * System.Console.WriteLine("Skipping DXT3"); * //(model.Blocks["GEO2"] as GEO2Block).ExportOBJ(path); * * //log.WriteLine(texture.ToString()); * }*/ ClassRegistry.Initialize(); foreach (FileEntry e in fs.FileEntries) { /*if (System.IO.Path.GetExtension(e.Filename).ToLower() == ".md2") * { * System.Console.WriteLine("Exporting model \"" + e.Filename + "\""); * using (System.IO.MemoryStream ms = new System.IO.MemoryStream(fs.GetFileData(e))) * using (System.IO.BinaryReader reader = new System.IO.BinaryReader(ms)) * { * MD2File model = new MD2File(reader); * //string path = System.IO.Path.ChangeExtension("dump\\" + e.Filename.ToLower(), ".obj"); * //string directory = System.IO.Path.GetDirectoryName(path); * //System.IO.Directory.CreateDirectory(directory); * //(model.Blocks["GEO2"] as GEO2Block).ExportOBJ(path); * * //log.WriteLine(e.Filename); * //if (model.Blocks.ContainsKey(BlockHeader.MAGIC_ANCHOR)) * //{ * // AnchorBlock ab = model.Blocks[BlockHeader.MAGIC_ANCHOR] as AnchorBlock; * // log.WriteLine(" " + ab.Anchors.Count + " anchors:"); * // foreach (Anchor a in ab.Anchors) * // { * // log.WriteLine(" " + a.MaterialIndex.ToString("X8") + ": " + a.Name + " (" + a.LinkedFilename + ")"); * // } * //} * } * } * if (System.IO.Path.GetExtension(e.Filename).ToLower() == ".pc texture") * { * try * { * //log.WriteLine("Exporting texture \"" + e.Filename + "\""); * //System.Console.WriteLine("Exporting texture \"" + e.Filename + "\""); * using (System.IO.MemoryStream ms = new System.IO.MemoryStream(fs.GetFileData(e))) * using (System.IO.BinaryReader reader = new System.IO.BinaryReader(ms)) * { * Texture texture = new Texture(reader); * string path = System.IO.Path.ChangeExtension("dump\\" + e.Filename.ToLower(), ".tga"); * string directory = System.IO.Path.GetDirectoryName(path); * log.WriteLine(texture.Unk08.ToString("X8") + " [GOOD]: " + e.Filename); * System.IO.Directory.CreateDirectory(directory); * if (texture.PCTFormat == Texture.ImageFormat.DXT3) * { * texture.DumpTGA(path); * System.Console.WriteLine("Converted " + e.Filename); * } * //else * // System.Console.WriteLine("Skipping DXT3"); * * * //(model.Blocks["GEO2"] as GEO2Block).ExportOBJ(path); * * //log.WriteLine(texture.ToString()); * } * } * catch * { * //System.Console.WriteLine("[ERROR]: other"); * using (System.IO.MemoryStream ms = new System.IO.MemoryStream(fs.GetFileData(e))) * { * System.IO.Directory.CreateDirectory("error/" + System.IO.Path.GetDirectoryName(e.Filename)); * System.IO.File.WriteAllBytes("error/" + e.Filename, ms.ToArray()); * } * } * } * if (System.IO.Path.GetExtension(e.Filename).ToLower() == ".ifl") * { * using (System.IO.MemoryStream ms = new System.IO.MemoryStream(fs.GetFileData(e))) * { * IFLFile ifl = new IFLFile(ms, e.Filename); * System.Console.WriteLine(e.Filename + " - " + ifl.Frames.Count + " frames"); * foreach (IFLFile.IFLFrame frame in ifl.Frames) * { * System.Console.WriteLine(" " + frame.ToString()); * } * } * }*/ if (System.IO.Path.GetExtension(e.Filename).ToLower() == ".wrl") { using (System.IO.MemoryStream ms = new System.IO.MemoryStream(fs.GetFileData(e))) using (System.IO.BinaryReader reader = new System.IO.BinaryReader(ms)) { World w = new World(reader); System.Console.WriteLine("World '" + e.Filename + "' - " + w.Objects.Count + " Objects:"); log.WriteLine("World '" + e.Filename + "' - " + w.Objects.Count + " Objects:"); foreach (Drome.Object o in w.Objects) { //log.WriteLine("[" + o.GetType().Name + "] " + o.Header.ClassName + " '" + o.InstanceName + (o.ParentInstanceName.Length > 0 ? "' (parent '" + o.ParentInstanceName + "')" : "'")); } } } /*if (System.IO.Path.GetExtension(e.Filename).ToLower() == ".oli") * { * using (System.IO.MemoryStream ms = new System.IO.MemoryStream(fs.GetFileData(e))) * using (System.IO.BinaryReader reader = new System.IO.BinaryReader(ms)) * { * OLIFile oli = new OLIFile(reader); * oli.DumpOBJ("olidump_" + System.IO.Path.GetFileNameWithoutExtension(e.Filename) + ".obj"); * } * }*/ } System.Console.WriteLine("Done."); System.Console.ReadKey(); fs.Dispose(); log.Dispose(); }