public void BulkExtractEverything() { //var fs = new InlinePackageFile(@"F:\Steam\SteamApps\common\Team Fortress 2\tf\tf2_textures_dir.vpk"); var fs = new InlinePackageFile(@"F:\Steam\SteamApps\common\dota 2 beta\dota\pak01_dir.vpk"); var files = fs.GetFiles("\\.vtf$", true).OrderBy(x => x.Name).Take(20000).GroupBy(x => x.Name).Select(x => x.First()).ToList(); //return; /*foreach (var f in files) * { * var vtf = VtfProvider.GetImage(f); * //Console.WriteLine(f.Name + " " + vtf.Height); * //vtf.Save(@"D:\Github\Chisel\_Resources\VTF\extract\" + f.Name + ".png"); * //if (i > 1) break; * }*/ Parallel.ForEach(files, x => { try { var vtf = VtfProvider.GetImage(x); //Console.WriteLine(x.Name); //vtf.Save(@"D:\Github\Chisel\_Resources\VTF\extract\" + x.Name + ".png"); } catch (Exception ex) { throw new Exception(x.Name + " " + ex.Message); } }); }
private Texture LoadTexture(ResourceLoader resourceLoader, string textureName) { var resourcePath = GetTexturePath(textureName); resourcePath = resourcePath.Replace('\\', '/'); if (!resourceLoader.ContainsFile(resourcePath)) { return(null); } var textureNameLower = textureName.ToLower(); if (_textureCache.ContainsKey(textureNameLower)) { return(_textureCache[textureNameLower]); } using (var fs = resourceLoader.OpenFile(resourcePath)) { try { var tex = VtfProvider.GetImage(fs); _textureCache.Add(textureNameLower, tex); return(tex); } catch (System.Exception e) { Debug.LogError(e); } } return(null); }
public void TestLoadVtfImage() { //var file = new NativeFile(@"D:\Github\Chisel\_Resources\VTF\mudground001_height-ssbump.vtf"); //var file = new NativeFile(@"D:\Github\Chisel\_Resources\VTF\dirtroad001a.vtf"); //var file = new NativeFile(@"D:\Github\Chisel\_Resources\VTF\rockground001.vtf"); //var file = new NativeFile(@"D:\Github\Chisel\_Resources\VTF\class_demo_dudv.vtf"); var file = new NativeFile(@"D:\Github\Chisel\_Resources\VTF\cubemap_gold001.hdr.vtf"); //var file = new NativeFile(@"D:\Github\Chisel\_Resources\VTF\800corner.vtf"); var image = VtfProvider.GetImage(file); image.Save(@"D:\Github\Chisel\_Resources\VTF\_test2.png"); }
public void BulkExtractEverything2() { var files = Directory.GetFiles(@"D:\Github\Chisel\_Resources\VTF", "*.vtf"); //return; /*foreach (var file in files) * { * var vtf = VtfProvider.GetImage(new NativeFile(file)); * //vtf.Save(@"D:\Github\Chisel\_Resources\VTF\extract\" + files[i].Name + ".png"); * //if (i > 1) break; * }*/ Parallel.ForEach(files, x => { var vtf = VtfProvider.GetImage(new NativeFile(x)); //Console.WriteLine(vtf.Height); vtf.Save(@"D:\Github\Chisel\_Resources\VTF\extract\" + Path.GetFileName(x) + ".png"); }); }