Exemplo n.º 1
0
 private static void RemoveChunks()
 {
     foreach (var gmd in Directory.GetFiles(Input.retargetFolder, "*.GMD", SearchOption.TopDirectoryOnly))
     {
         var modelPack    = ModuleImportUtilities.ImportFile <ModelPack>(gmd);
         var newModelPack = new ModelPack();
         newModelPack.Version       = modelPack.Version;
         newModelPack.Textures      = modelPack.Textures;
         newModelPack.Materials     = modelPack.Materials;
         newModelPack.Model         = modelPack.Model;
         newModelPack.AnimationPack = modelPack.AnimationPack;
         newModelPack.Save(gmd);
     }
 }
Exemplo n.º 2
0
 private static void ReplaceModels()
 {
     for (int i = 0; i < Input.ogModels.Length; i++)
     {
         bool foundMatch = false;
         for (int x = 0; x < Input.newModels.Length; x++)
         {
             //If filenames match except for character ID, replace new model with old one
             string renamedNewModel = Path.GetFileName(Input.newModels[x]).Replace(Path.GetFileName(Options.New), Path.GetFileName(Options.Old));
             if (Path.GetFileName(Input.ogModels[i]) == renamedNewModel)
             {
                 if (Options.GMD.Retarget)
                 {
                     //Retarget matching new model to old model's IDs, using default model when no match is found
                     var originalModelPack = ModuleImportUtilities.ImportFile <ModelPack>(Input.ogModels[i]);
                     var newModelPack      = ModuleImportUtilities.ImportFile <ModelPack>(Input.newModels[x]);
                     originalModelPack.ReplaceWith(newModelPack);
                     originalModelPack.Save(Path.Combine(Input.retargetFolder, Path.GetFileName(Input.ogModels[i])));
                     Console.WriteLine($"Retargeting {Path.GetFileName(Input.newModels[x])} to {Path.GetFileName(Input.ogModels[i])}");
                 }
                 else if (Options.GMD.Replace)
                 {
                     //If not retargeting, copy file
                     foundMatch = true;
                     File.Copy(Input.newModels[x], Path.Combine(Input.retargetFolder, Path.GetFileName(Input.ogModels[i])));
                     Console.WriteLine($"Copying {Path.GetFileName(Input.newModels[x])} to replace {Path.GetFileName(Input.ogModels[i])}");
                 }
             }
         }
         if (!foundMatch)
         {
             if (Options.GMD.Retarget)
             {
                 //Retarget default model
                 var originalModelPack = ModuleImportUtilities.ImportFile <ModelPack>(Input.ogModels[i]);
                 var newModelPack      = ModuleImportUtilities.ImportFile <ModelPack>(Input.newDefaultModel);
                 originalModelPack.ReplaceWith(newModelPack);
                 originalModelPack.Save(Path.Combine(Input.retargetFolder, Path.GetFileName(Input.ogModels[i])));
                 Console.WriteLine($"Retargeting {Path.GetFileName(Input.newDefaultModel)} to {Path.GetFileName(Input.ogModels[i])}");
             }
             else if (Options.GMD.Replace)
             {
                 //Copy default model to new location
                 File.Copy(Input.newDefaultModel, Path.Combine(Input.retargetFolder, Path.GetFileName(Input.ogModels[i])));
                 Console.WriteLine($"Copying {Path.GetFileName(Input.newDefaultModel)} to replace {Path.GetFileName(Input.ogModels[i])}");
             }
         }
     }
 }
Exemplo n.º 3
0
        private static void ReplaceAnimations()
        {
            var newCharDefaultModel = ModuleImportUtilities.ImportFile <ModelPack>(Input.newDefaultModel);
            var ogCharDefaultModel  = ModuleImportUtilities.ImportFile <ModelPack>(Input.ogDefaultModel);

            for (int i = 0; i < Input.ogAnims.Length; i++)
            {
                bool foundMatch = false;
                //Set destination to GMD folder if name contains emt
                string newDestination = "";
                if (Input.ogAnims[i].Contains("emt"))
                {
                    newDestination = Path.Combine(Input.retargetFolder, Path.GetFileName(Input.ogAnims[i]));
                }
                else
                {
                    string gapFolder = Path.Combine(Input.retargetFolder, Path.GetFileName(Path.GetDirectoryName(Input.ogAnims[i])));
                    if (!Directory.Exists(gapFolder))
                    {
                        Directory.CreateDirectory(gapFolder);
                    }
                    newDestination = Path.Combine(gapFolder, Path.GetFileName(Input.ogAnims[i]));
                }

                for (int x = 0; x < Input.newAnims.Length; x++)
                {
                    //If filenames match except for character ID, replace new animation with old one
                    string renamedNewAnim = Path.GetFileName(Input.newAnims[x]).Replace(Path.GetFileName(Options.New), Path.GetFileName(Options.Old));
                    if (Path.GetFileName(Input.ogAnims[i]) == renamedNewAnim)
                    {
                        foundMatch = true;
                        //Delete new gap if it exists
                        if (File.Exists(newDestination))
                        {
                            File.Delete(newDestination);
                        }

                        if (Options.GAP.Replace)
                        {
                            //Copy gap to new location
                            File.Copy(Input.newAnims[x], newDestination);
                            Console.WriteLine($"Copying {Path.GetFileName(Input.newAnims[x])} to replace {Path.GetFileName(Input.ogAnims[i])}");
                        }
                        else if (Options.GAP.Retarget)
                        {
                            //Save new retargeted gap
                            var animationPack = Resource.Load <AnimationPack>(Input.ogAnims[i]);
                            animationPack.Retarget(ogCharDefaultModel.Model, newCharDefaultModel.Model, Options.GAP.FixArms);
                            animationPack.Save(newDestination);
                            Console.WriteLine($"Retargeting {Path.GetFileName(Input.ogAnims[i])} comparing {Path.GetFileName(Input.ogDefaultModel)} to {Path.GetFileName(Input.newDefaultModel)}");
                        }
                    }
                }
                if (!foundMatch && Options.GAP.Retarget)
                {
                    //Delete new gap if it exists
                    if (File.Exists(newDestination))
                    {
                        File.Delete(newDestination);
                    }
                    //Save new retargeted gap
                    var animationPack = Resource.Load <AnimationPack>(Input.ogAnims[i]);
                    animationPack.Retarget(ogCharDefaultModel.Model, newCharDefaultModel.Model, Options.GAP.FixArms);
                    animationPack.Save(newDestination);
                    Console.WriteLine($"Retargeting {Path.GetFileName(Input.ogDefaultModel)} to {Path.GetFileName(Input.ogAnims[i])}");
                }
            }
        }
Exemplo n.º 4
0
        private void copyP5SplitGAPToMultipleModelsInDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var aGap = ModuleImportUtilities.SelectImportFile <AnimationPack>("Select the gap file ending with a.");

            if (aGap == null)
            {
                return;
            }

            var bGap = ModuleImportUtilities.SelectImportFile <AnimationPack>("Select the gap file ending with b.");

            if (bGap == null)
            {
                return;
            }

            var cGap = ModuleImportUtilities.SelectImportFile <AnimationPack>("Select the gap file ending with c.");

            if (cGap == null)
            {
                return;
            }

            bool isGAP52 = MessageBox.Show("GAP ID 52? If unsure, select No.", "Question", MessageBoxButtons.YesNo,
                                           MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes;

            string directoryPath;
            var    browserDialog = new VistaFolderBrowserDialog();
            {
                browserDialog.Description =
                    "Select a directory containing Model files, or subdirectories containing model files to make the new GAP files for.\n" +
                    "Note that this will replace the original files.";

                if (browserDialog.ShowDialog() != true)
                {
                    return;
                }

                directoryPath = browserDialog.SelectedPath;
            }

            var failures = new ConcurrentBag <string>();

            string GAP_ID = "_051_";

            if (isGAP52)
            {
                GAP_ID = "_052_";
            }

            var filePaths = Directory.EnumerateFiles(directoryPath, "*.GMD", SearchOption.AllDirectories).ToList();

            foreach (string filePath in filePaths)
            {
                var targetCharID  = Path.GetFileName(filePath).Split("_")[0].Remove(0, 1); // get character ID from model
                var targetGAPname = Path.GetFileName(filePath).Split("_")[1];              // get model ID from model
                var targetGAPDir  = Path.Join(Path.GetDirectoryName(filePath), "battle");  // directory of model
                try
                {
                    var targetModel = ModuleImportUtilities.ImportFile <ModelPack>(filePath)?.Model;

                    if (targetModel == null)
                    {
                        return;
                    }

                    aGap.FixTargetIds(targetModel);
                    aGap.Save(Path.Join(targetGAPDir, "bb" + targetCharID + GAP_ID + targetGAPname + "a.GAP"));

                    bGap.FixTargetIds(targetModel);
                    bGap.Save(Path.Join(targetGAPDir, "bb" + targetCharID + GAP_ID + targetGAPname + "b.GAP"));

                    cGap.FixTargetIds(targetModel);
                    cGap.Save(Path.Join(targetGAPDir, "bb" + targetCharID + GAP_ID + targetGAPname + "c.GAP"));
                }
                catch (Exception)
                {
                    failures.Add(filePath);
                }
            }

            if (failures.Count > 0)
            {
                MessageBox.Show("An error occured while processing the following files:\n" + string.Join("\n", failures));
            }
            else
            {
                MessageBox.Show("All split GAPs successfully generated!");
            }
        }