/// <summary> /// Halo2 export interface class constructor /// </summary> /// <param name="tag_index">Tag index containing the tag being exported</param> /// <param name="tag_datum">DatumIndex of the tag being exported</param> public ColladaHalo2(TagIndexBase tag_index, DatumIndex tag_datum) { tagIndex = tag_index; tagManager = tagIndex[tag_datum]; GenerateInfoList(); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Gets the shader data from the tag. </summary> /// /// <param name="tagIndex"> The parent tag index. </param> /// <param name="tagManager"> The tags' manager. </param> /// /// <returns> The shader data. </returns> private StructureBSPShaderData GetShaderData(TagIndexBase tagIndex, BlamLib.Managers.TagManager tagManager) { var data = new StructureBSPShaderData(); data.CollectData(tagIndex, tagManager); return(data); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Gets the model data from the tag. </summary> /// /// <param name="tagIndex"> The parent tag index. </param> /// <param name="tagManager"> The tags' manager. </param> /// /// <returns> The model data. </returns> private ModelData GetModelData(TagIndexBase tagIndex, BlamLib.Managers.TagManager tagManager) { var data = new ModelData(); data.CollectData(tagIndex, tagManager); return(data); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Gets the shader data from the tag. </summary> /// /// <param name="tagIndex"> The parent tag index. </param> /// <param name="tagManager"> The tags' manager. </param> /// /// <returns> The shader data. </returns> private ModelShaderData GetShaderData(TagIndexBase tagIndex, BlamLib.Managers.TagManager tagManager) { var data = new ModelShaderData(); data.CollectData(tagIndex, tagManager); return data; }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Gets the scenario data from the tag. </summary> /// /// <param name="tagIndex"> Zero-based index of the tag. </param> /// <param name="tagManager"> The tag's manager. </param> /// /// <returns> The scenario data. </returns> private ScenarioData GetScenarioData(TagIndexBase tagIndex, BlamLib.Managers.TagManager tagManager) { var data = new ScenarioData(); data.MessageSent += MessageRedirect; data.CollectData(tagIndex, tagManager); data.MessageSent -= MessageRedirect; return data; }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Gets the scenario data from the tag. </summary> /// /// <param name="tagIndex"> Zero-based index of the tag. </param> /// <param name="tagManager"> The tag's manager. </param> /// /// <returns> The scenario data. </returns> private ScenarioData GetScenarioData(TagIndexBase tagIndex, BlamLib.Managers.TagManager tagManager) { var data = new ScenarioData(); data.MessageSent += MessageRedirect; data.CollectData(tagIndex, tagManager); data.MessageSent -= MessageRedirect; return(data); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Gets the BSP data from the tag. </summary> /// /// <param name="tagIndex"> The parent tag index. </param> /// <param name="tagManager"> The tag's manager. </param> /// /// <returns> The bsp data. </returns> private StructureBSPData GetBSPData(TagIndexBase tagIndex, BlamLib.Managers.TagManager tagManager) { var data = new StructureBSPData() { IncludeRenderMesh = mBspData.ExportRenderMesh, IncludePortals = mBspData.ExportPortals, IncludeFogPlanes = mBspData.ExportFogPlanes, IncludeBSPMarkers = mBspData.ExportBSPMarkers }; data.CollectData(tagIndex, tagManager); return data; }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Gets the BSP data from the tag. </summary> /// /// <param name="tagIndex"> The parent tag index. </param> /// <param name="tagManager"> The tag's manager. </param> /// /// <returns> The bsp data. </returns> private StructureBSPData GetBSPData(TagIndexBase tagIndex, BlamLib.Managers.TagManager tagManager) { var data = new StructureBSPData() { IncludeRenderMesh = mBspData.ExportRenderMesh, IncludePortals = mBspData.ExportPortals, IncludeFogPlanes = mBspData.ExportFogPlanes, IncludeBSPMarkers = mBspData.ExportBSPMarkers }; data.CollectData(tagIndex, tagManager); return(data); }
///------------------------------------------------------------------------------------------------- /// <summary> Base class constructor. </summary> /// <param name="arguments"> The collada config variables. </param> /// <param name="tagIndex"> Halo1 tag index. </param> ///------------------------------------------------------------------------------------------------- public ColladaExporterHalo1(IColladaSettings settings, TagIndexBase tagIndex) : base(settings) { mTagIndex = tagIndex; }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Exports the provided bsp's lightmap sizes with a multiplier. </summary> /// /// <param name="tagIndex"> Tag index the bsp belongs to. </param> /// <param name="tagManager"> The bsp tag's manager. </param> /// <param name="sizeMultiplier"> The lightmap size multiplier. </param> /// <param name="outputFile"> The bsp's output file. </param> public void Export(TagIndexBase tagIndex, BlamLib.Managers.TagManager tagManager, int sizeMultiplier, string outputFile) { // Collect the necessary data var structureBSP = tagManager.TagDefinition as BlamLib.Blam.Halo1.Tags.structure_bsp_group; if (!TagIndex.IsValid(structureBSP.LightmapBitmaps.Datum)) { mMessageHandler.SendMessage("Failed to open lightmap bitmap {0}", structureBSP.LightmapBitmaps.ToString()); return; } var bitmapManager = tagIndex[structureBSP.LightmapBitmaps.Datum]; if (bitmapManager == null) { mMessageHandler.SendMessage("Failed to open lightmap bitmap {0}", structureBSP.LightmapBitmaps.ToString()); return; } if (structureBSP.Lightmaps.Count == 0) { mMessageHandler.SendMessage("BSP has no lightmaps {0}", tagManager.Name); return; } var bitmap = bitmapManager.TagDefinition as BlamLib.Blam.Halo1.Tags.bitmap_group; if (bitmap == null) { mMessageHandler.SendMessage("Failed to open lightmap bitmap {0}", structureBSP.LightmapBitmaps.ToString()); return; } // Build the lightmap size list var lightmapSizeList = new List <string>(); var bspName = Path.GetFileNameWithoutExtension(tagManager.Name); foreach (var lightmap in structureBSP.Lightmaps) { if (lightmap.Bitmap.Value == -1) { continue; } if (lightmap.Bitmap.Value >= bitmap.Bitmaps.Count) { mMessageHandler.SendMessage("Failed to export lightmap sizes. A lightmap bitmap and bsp do not have matching lightmap counts {0}", tagManager.Name); return; } var bitmapInfo = bitmap.Bitmaps[lightmap.Bitmap.Value]; lightmapSizeList.Add(String.Format("{0}_{1}\t[{2},{3}]" , bspName , lightmap.Bitmap.Value , bitmapInfo.Width * sizeMultiplier , bitmapInfo.Height * sizeMultiplier)); } // Save the sizes to file var sizeFileName = Path.ChangeExtension(outputFile, "lmsz"); try { using (var outputStream = File.OpenWrite(sizeFileName)) { var writer = new StreamWriter(outputStream); writer.Write(String.Join("\r\n", lightmapSizeList)); writer.Flush(); } mMessageHandler.SendMessage("BSP lightmap sizes saved"); } catch (IOException) { mMessageHandler.SendMessage("Failed to open the lightmap sizes file"); } }