//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Gets the output file from the input file path. </summary> /// /// <param name="tagsDirectory"> Pathname of the tags directory. </param> /// <param name="dataDirectory"> Pathname of the data directory. </param> /// <param name="inputFile"> The input file path. </param> /// /// <returns> The output file path. </returns> private string GetOutputFile(string tagsDirectory, string dataDirectory, string inputFile) { var input = new BlamTagPath(tagsDirectory); input.SetPath(inputFile); var outputFile = Path.Combine(dataDirectory, input.TagPath); outputFile = Path.ChangeExtension(outputFile, ".dae"); return(outputFile); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Adds a job to the extraction queue</summary> /// /// <param name="modelFile"> The path of the model tag. </param> /// <param name="extractionData"> The extraction data to use. </param> public void AddJob(string modelFile, IExtractionData extractionData) { // Clone the extraction data, then override the model extraction data values var clonedData = extractionData.Clone() as IExtractionData; var modelExtractionData = clonedData.Get <ModelExtractionData>(); var outputFile = GetOutputFile(modelExtractionData.TagsDirectory.AbsoluteFolder, modelExtractionData.DataDirectory.AbsoluteFolder, modelFile); var tagPath = new BlamTagPath(modelExtractionData.TagsDirectory.AbsoluteFolder); tagPath.SetPath(modelFile); modelExtractionData.TagFile = tagPath; modelExtractionData.OutputFile = outputFile; // Add an extraction job to the extraction manager var modelExtractor = mExtractorFactory.GetExtractionJob(Path.GetExtension(modelFile), clonedData); mExtractionManager.Add(modelExtractor); }
/// <summary> Imports lightmap coordinates into a bsp. </summary> public void ImportLightmap() { // Verify the directory settings are correct var importerSettings = GetImporterSettings(); if (!Directory.Exists(importerSettings.DataFolder)) { mMessageHandler.SendMessage("The selected data directory does not exist"); return; } if (!Directory.Exists(importerSettings.TagsFolder)) { mMessageHandler.SendMessage("The selected tags directory does not exist"); return; } var tagsDir = new BlamPath(importerSettings.TagsFolder); var dataDir = new BlamPath(importerSettings.DataFolder); // Get the input files string structureBSPPath = GetInputFile(GetImporterSettings().TagsFolder, "Select the BSP tag", "Structure BSP (*.scenario_structure_bsp)|*.scenario_structure_bsp"); if (String.IsNullOrEmpty(structureBSPPath)) { mMessageHandler.SendMessage("No BSP tag was selected"); return; } string colladaPath = GetInputFile(GetImporterSettings().DataFolder, "Select the COLLADA file", "COLLADA (*.dae)|*.dae"); if (String.IsNullOrEmpty(colladaPath)) { mMessageHandler.SendMessage("No COLLADA file was selected"); return; } // Verify the selected files are under the right directories var absoluteBSPFile = Path.GetFullPath(structureBSPPath); if (System.String.Compare(absoluteBSPFile, 0, tagsDir.AbsoluteFolder, 0, tagsDir.AbsoluteFolder.Length, true) != 0) { System.Windows.Forms.MessageBox.Show("The selected BSP file is not under the tags directory", "Invalid File Path", System.Windows.Forms.MessageBoxButtons.OK); return; } var absoluteCOLLADAFile = Path.GetFullPath(colladaPath); if (System.String.Compare(absoluteCOLLADAFile, 0, dataDir.AbsoluteFolder, 0, dataDir.AbsoluteFolder.Length, true) != 0) { System.Windows.Forms.MessageBox.Show("The selected COLLADA file is not under the data directory", "Invalid File Path", System.Windows.Forms.MessageBoxButtons.OK); return; } // Run the import process var lightmapImporter = new Importer.LightmapImporter(); SetState(LightmapImporterStateEnum.ImporterImporting); lightmapImporter.MessageSent += MessageRedirect; var tagPath = new BlamTagPath(tagsDir.AbsoluteFolder); tagPath.SetPath(absoluteBSPFile); bool result = lightmapImporter.ImportTexcoords(tagsDir.AbsoluteFolder, tagPath.TagPath, absoluteCOLLADAFile); lightmapImporter.MessageSent -= MessageRedirect; SetState(LightmapImporterStateEnum.ImporterReady); if (!result) { mMessageHandler.SendMessage("Lightmap UV import failed"); return; } mMessageHandler.SendMessage("Lightmap UV import completed"); }