示例#1
0
        private static void HandleFile(string path)
        {
            if (Directory.Exists(path))
            {
                Console.WriteLine($"Packing {Path.GetFileName(path)}...");
                using var archive = ArchiveFile.FromDirectory(path);
                if (File.Exists(path + ".par") && !File.Exists(path + ".par.bak"))
                {
                    File.Copy(path + ".par", path + ".par.bak");
                }

                archive.Save(File.OpenWrite(path + ".par"));
            }
            else
            {
                switch (Path.GetExtension(path))
                {
                case ".par":
                    Console.WriteLine($"Extracting {Path.GetFileName(path)}");
                    using (var archive = ArchiveFile.FromFile(path))
                    {
                        archive.Extract(Path.ChangeExtension(path, null));
                    }

                    break;

                case ".gmd":
                    Console.WriteLine($"Exporting {Path.GetFileName(path)}");
                    var gmdFile = GmdFile.FromFile(path);
                    var mesh    = YakuzaMesh.FromGmdFile(gmdFile);
                    mesh.SaveToGltf2(Path.ChangeExtension(path, ".glb"), FindTextureFolder(path));
                    break;
                }
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            var ddsPath = @"D:\Program Files (x86)\Steam\steamapps\common\Yakuza Kiwami 2\data\chara_unpack\lexus2\dds";

            using var archiveIn  = ArchiveFile.FromFile(@"D:\Program Files (x86)\Steam\steamapps\common\Yakuza Kiwami 2\data\chara_original.par");
            using var archiveOut = File.OpenWrite(@"D:\Program Files (x86)\Steam\steamapps\common\Yakuza Kiwami 2\data\chara.par");

            var fileName = "c_am_kiryu.gmd";
            // var fileName = "c_am_dummy_01.gmd";
            // var fileName = "c_aw_haruka.gmd";
            // var fileName = "c_am_S03_soutenboripl.gmd";


            var kiryu = archiveIn.Find(fileName);

            using var tempFile = new MemoryStream();
            archiveIn.Read(kiryu).CopyTo(tempFile);
            tempFile.Seek(0, SeekOrigin.Begin);

            var gmd  = GmdFile.FromStream(tempFile);
            var mesh = YakuzaMesh.FromGmdFile(gmd);

            mesh.SaveToGltf2("mesh.glb", ddsPath);
            if (Directory.Exists("textures"))
            {
                Directory.Delete("textures", true);
            }

            var mesh1 = YakuzaMesh.FromGltf2("mesh_edited.glb", "textures");

            foreach (var file in Directory.EnumerateFiles("textures"))
            {
                Console.WriteLine($"Adding texture: {Path.GetFileName(file)}");
                archiveIn.AddFile("lexus2\\dds\\" + Path.GetFileName(file), File.ReadAllBytes(file));
            }

            var gmd2 = mesh1.ToGmdFile();

            tempFile.Seek(0, SeekOrigin.Begin);
            gmd2.Write(tempFile);


            tempFile.Seek(0, SeekOrigin.Begin);
            archiveIn.ReplaceFile(fileName, tempFile.ToArray());

            archiveIn.Save(archiveOut, Endianness.Big);
        }