////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>	Loads a structure bsp. </summary>
        ///
        /// <param name="path">	Tags relative pathname of the bsp tag. </param>
        ///
        /// <returns>	The loaded structure bsp. </returns>
        structure_bsp_group LoadStructureBSP(string tagsDirectory, string path)
        {
            // Load the structure bsp
            var tagsPath = new BlamPath(tagsDirectory);

            mTagHandler = new TagIndexHandler <BlamLib.Managers.TagIndex>(BlamLib.BlamVersion.Halo1_CE, tagsPath.Root);

            mBSPDatumIndex = mTagHandler.IndexInterface.Open(path, BlamLib.Blam.Halo1.TagGroups.sbsp);
            if (!BlamLib.Managers.TagIndex.IsValid(mBSPDatumIndex))
            {
                SendMessage("Failed to load the target BSP");
                return(null);
            }

            var tagManager   = mTagHandler.IndexInterface[mBSPDatumIndex];
            var structureBSP = tagManager.TagDefinition as structure_bsp_group;

            if (structureBSP == null)
            {
                SendMessage("Failed to load the target BSP");
                return(null);
            }

            return(structureBSP);
        }
        /// <summary>	Unload the current structure bsp. </summary>
        void UnloadStructureBSP()
        {
            mTagHandler.IndexInterface.UnloadAll();
            mTagHandler = null;

            mBSPDatumIndex = DatumIndex.Null;
        }
Esempio n. 3
0
		public void Halo1TestTagIndex()
		{
			using (var handler = new TagIndexHandler<Managers.TagIndex>(BlamVersion.Halo1_CE, kTestInstallationRootPath, kTestTagsDir))
			{
				var tagindex = handler.IndexInterface;
				Blam.DatumIndex datum_scnr_index, datum_matg_index;

				StartStopwatch();
				{
					StartSubStopwatch();
					datum_scnr_index = tagindex.Open(@"levels\test\tutorial\tutorial", Blam.Halo1.TagGroups.scnr, IO.ITagStreamFlags.LoadDependents);
					Console.WriteLine("SCENARIO LOAD: Time taken: {0}", StopSubStopwatch());
				}
				{
					StartSubStopwatch();
					datum_matg_index = tagindex.Open(@"globals\globals", Blam.Halo1.TagGroups.matg, IO.ITagStreamFlags.LoadDependents);
					Console.WriteLine("GLOBALS LOAD: Time taken: {0}", StopSubStopwatch());
				}
				Console.WriteLine("TAG INDEX: Time taken: {0}", StopStopwatch());

				var tag_manager_scnr = tagindex[datum_scnr_index];
				var tag_scenario = tag_manager_scnr.TagDefinition as Blam.Halo1.Tags.scenario_group;
				tag_scenario = null;
				tag_manager_scnr = null;
// 				using (var sw = new StreamWriter(Path.Combine(kTestResultsTagsPath, @"dump_tag_index.txt")))
// 				{ tagindex.Dump(sw); }
				Assert.IsTrue(tagindex.Unload(datum_scnr_index));
				Assert.IsTrue(tagindex.Unload(datum_matg_index));
			}
		}
Esempio n. 4
0
		public void Halo1TestTagIndexRar()
		{
			using (var handler = new TagIndexHandler<Managers.TagIndex>(BlamVersion.Halo1_CE, kTestInstallationRootPath, kTestTagsDir))
			{
				var tagindex = handler.IndexInterface;
				Blam.DatumIndex datum_test_index;

				{
					StartStopwatch();
					datum_test_index = tagindex.Open(
						@"characters\cyborg\cyborg", Blam.Halo1.TagGroups.bipd,
						IO.ITagStreamFlags.LoadDependents);
					Console.WriteLine("TEST LOAD: Time taken: {0}", StopStopwatch());
				}
				tagindex.WinRar(Path.Combine(kTestResultsTagsPath, @"test.rar"), true);
				Assert.IsTrue(tagindex.Unload(datum_test_index));
			}
		}
        public void FieldIndexHandler_TagIndexHandler()
        {
            var fieldValue       = "Tag1,Tag2,Tag3";
            var fieldValueObject = (object)fieldValue;
            var snField          = new IndexableField(fieldValueObject);

            var fieldIndexHandler = new TagIndexHandler();

            fieldIndexHandler.OwnerIndexingInfo = new TestPerfieldIndexingInfoString();

            var indexed = fieldIndexHandler.GetIndexFields(snField, out _);

            Assert.AreEqual(IndexValueType.StringArray, indexed.First().Type);
            var parsed = fieldIndexHandler.Parse(fieldValue.ToString());

            Assert.AreEqual(IndexValueType.String, parsed.Type);
            var termValue = fieldIndexHandler.ConvertToTermValue(fieldValue.ToString());

            Assert.AreEqual(parsed.Type, termValue.Type);

            var retrieved = fieldIndexHandler.GetBack("tag1");

            Assert.AreEqual("tag1", retrieved);
        }
		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Constructor. </summary>
		///
		/// <param name="rootPath">	The users HEK root directory. </param>
		public LightmapImporter()
		{
			mTagHandler = null;
			mBSPDatumIndex = DatumIndex.Null;
		}
Esempio n. 7
0
		public void Halo1TestCOLLADAModelExport()
		{
			using (var handler = new TagIndexHandler<Managers.TagIndex>(BlamVersion.Halo1_CE, kTestTagIndexTagsPath))
			{
				var tagindex = handler.IndexInterface;
				foreach (var model_def in ModelTestDefinitions)
				{
					// load the tag with dependents
					StartStopwatch();
					{
						model_def.Open(tagindex);
						Console.WriteLine("{0} LOAD: Time taken: {1}", model_def.TypeString, m_testStopwatch.Elapsed);
					}
					Console.WriteLine("TAG INDEX: Time taken: {0}", StopStopwatch());

					// create a halo1 collada interface with the gbxmodel datum
					var object_tag = tagindex[model_def.TagIndex].TagDefinition as Blam.Halo1.Tags.object_group;

					var halo1 = new BlamLib.Render.COLLADA.Halo1.ColladaHalo1(tagindex, object_tag.Model.Datum);

					// set the interfaces settings (want to look into a better way of doing this)
					halo1.Overwrite = true;
					halo1.RelativeFilePath = Path.Combine(kTestTagIndexTagsPath, @"data\");

					// export each permutation and lod separately
					foreach (var info in halo1)
					{
						// clear the export register
						halo1.ClearRegister();
						// add the info object to export
						halo1.RegisterForExport(info);
						
						var model_info = info as Render.COLLADA.Halo1.ColladaHalo1ModelInfo;

						string name = string.Format("{0}-perm{1}-lod{2}", model_info.Name, model_info.Permutation, model_info.LevelOfDetail);

						StartStopwatch();
						halo1.Export(name);
						Console.WriteLine("EXPORT {0} TIME: Time taken: {1}", name, StopStopwatch());

						// print any errors
						foreach (string report in halo1.Reports())
							Console.WriteLine(report);
					}

					// export all the models into a single collada file
					halo1.ClearRegister();
					foreach (var info in halo1)
						halo1.RegisterForExport(info);

					string name_all = Path.GetFileNameWithoutExtension(model_def.Name) + "_all";

					StartStopwatch();
					halo1.Export(name_all);
					Console.WriteLine("EXPORT {0} TIME: Time taken: {1}", name_all, StopStopwatch());

					foreach (string report in halo1.Reports())
						Console.WriteLine(report);

					model_def.Close(tagindex);
				}
			}
		}
		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Loads a structure bsp. </summary>
		///
		/// <param name="path">	Tags relative pathname of the bsp tag. </param>
		///
		/// <returns>	The loaded structure bsp. </returns>
		structure_bsp_group LoadStructureBSP(string tagsDirectory, string path)
		{
			// Load the structure bsp
			var tagsPath = new BlamPath(tagsDirectory);
			mTagHandler = new TagIndexHandler<BlamLib.Managers.TagIndex>(BlamLib.BlamVersion.Halo1_CE, tagsPath.Root);

			mBSPDatumIndex = mTagHandler.IndexInterface.Open(path, BlamLib.Blam.Halo1.TagGroups.sbsp);
			if (!BlamLib.Managers.TagIndex.IsValid(mBSPDatumIndex))
			{
				SendMessage("Failed to load the target BSP");
				return null;
			}

			var tagManager = mTagHandler.IndexInterface[mBSPDatumIndex];
			var structureBSP = tagManager.TagDefinition as structure_bsp_group;
			if (structureBSP == null)
			{
				SendMessage("Failed to load the target BSP");
				return null;
			}

			return structureBSP;
		}
		/// <summary>	Unload the current structure bsp. </summary>
		void UnloadStructureBSP()
		{
			mTagHandler.IndexInterface.UnloadAll();
			mTagHandler = null;

			mBSPDatumIndex = DatumIndex.Null;
		}
Esempio n. 10
0
		public void Halo2TestCOLLADARenderModelExport()
		{
			using (var handler = new TagIndexHandler<Managers.TagIndex>(BlamVersion.Halo2_PC, kTestTagIndexTagsPath))
			{
				var tagindex = handler.IndexInterface;
				foreach (var model_def in RenderModelTestDefinitions)
				{
					StartStopwatch();
					{
						model_def.Open(tagindex);
						Console.WriteLine("{0} LOAD: Time taken: {1}", model_def.TypeString, m_testStopwatch.Elapsed);
					}
					Console.WriteLine("TAG INDEX: Time taken: {0}", StopStopwatch());

					var halo2 = new BlamLib.Render.COLLADA.Halo2.ColladaHalo2(tagindex, model_def.TagIndex);

					halo2.Overwrite = true;
					halo2.RelativeFilePath = Path.Combine(kTestTagIndexTagsPath, @"data\");

					foreach (Render.COLLADA.Halo2.ColladaHalo2RenderModelInfo info in halo2)
					{
						halo2.ClearRegister();
						halo2.RegisterForExport(info);

						string name = string.Format("{0}-perm{1}-lod{2}", info.Name, info.Permutation, info.LevelOfDetail);

						StartStopwatch();
						halo2.Export(name);
						Console.WriteLine("EXPORT {0} TIME: Time taken: {1}", name, StopStopwatch());

						foreach (string report in halo2.Reports())
							Console.WriteLine(report);
					}

					halo2.ClearRegister();
					
					foreach (var info in halo2)
						halo2.RegisterForExport(info);

					var model_info = halo2[0] as Render.COLLADA.Halo2.ColladaHalo2RenderModelInfo;

					string name_all = model_info.Name + "_all";

					StartStopwatch();
					halo2.Export(name_all);
					Console.WriteLine("EXPORT {0} TIME: Time taken: {1}", name_all, StopStopwatch());

					foreach (string report in halo2.Reports())
						Console.WriteLine(report);

					model_def.Close(tagindex);
				}
			}
		}
Esempio n. 11
0
		public void Halo1TestTagIndexThreaded()
		{
			var bd = BlamLib.Program.Halo1.Manager;
			
			var thread_matg = new System.Threading.Thread(delegate (/*object param*/)
			{
				StartStopwatch();
				using (var handler = new TagIndexHandler<Managers.TagIndex>(BlamVersion.Halo1_CE, kTestInstallationRootPath, kTestTagsDir))
				{
					var tagindex_matg = handler.IndexInterface;

					var datum_test_index = tagindex_matg.Open(
						@"globals\globals", Blam.Halo1.TagGroups.matg,
						IO.ITagStreamFlags.LoadDependents);
					Console.WriteLine("GLOBALS LOAD: Time taken: {0}", StopStopwatch());

				}
			});
			var thread_scnr = new System.Threading.Thread(delegate(/*object param*/)
			{
				StartStopwatch();
				using (var handler = new TagIndexHandler<Managers.TagIndex>(BlamVersion.Halo1_CE, kTestInstallationRootPath, kTestTagsDir))
				{
					var tagindex_scnr = handler.IndexInterface;

					var datum_test_index2 = tagindex_scnr.Open(
						@"levels\test\tutorial\tutorial", Blam.Halo1.TagGroups.scnr,
						IO.ITagStreamFlags.LoadDependents);
					Console.WriteLine("SCENARIO LOAD: Time taken: {0}", StopStopwatch());
				}
			});

			thread_matg.Start(/*TestContext*/);
			thread_scnr.Start(/*TestContext*/);
			thread_matg.Join();
			thread_scnr.Join();
		}
Esempio n. 12
0
		public void Halo1TestCOLLADAModelExport()
		{
			var settings = new TestColladaSettings(
				true,
				Path.Combine(kTestInstallationRootPath, kTestDataDir),
				AssetFormat.bmp);

			using (var handler = new TagIndexHandler<Managers.TagIndex>(BlamVersion.Halo1_CE, kTestInstallationRootPath, kTestTagsDir))
			{
				var tagindex = handler.IndexInterface;
				foreach (var model_def in ModelTestDefinitions)
				{
					// load the tag with dependents
					StartStopwatch();
					{
						model_def.Open(tagindex);
						Console.WriteLine("{0} LOAD: Time taken: {1}", model_def.TypeString, m_testStopwatch.Elapsed);
					}
					Console.WriteLine("TAG INDEX: Time taken: {0}", StopStopwatch());
					
					// create a halo1 collada interface with the gbxmodel datum
					var object_tag = tagindex[model_def.TagIndex].TagDefinition as Blam.Halo1.Tags.object_group;
					var tagManager = tagindex[object_tag.Model.Datum];
					string name = Path.GetFileNameWithoutExtension(model_def.Name);

					var modelData = new BlamLib.Render.COLLADA.Halo1.ModelData();
					var modelShaderData = new BlamLib.Render.COLLADA.Halo1.ModelShaderData();
					
					modelData.CollectData(tagindex, tagManager);
					modelShaderData.CollectData(tagindex, tagManager);

					var exporter = new BlamLib.Render.COLLADA.Halo1.ColladaModelExporter(settings,
						tagindex,
						tagManager);

					exporter.MessageSent +=
						(object sender, BlamLib.Messaging.MessageArgs args) =>
						{
							Console.WriteLine("COLLADA_ERROR: {0}", args.Message);
						};

					exporter.AddDataProvider(modelData);
					exporter.AddDataProvider(modelShaderData);

					StartStopwatch();

					Assert.IsTrue(exporter.BuildColladaInstance(), "Failed to build collada instance for {0}", model_def.Name);
					exporter.SaveDAE(Path.Combine(kTestResultsDataPath, modelData.GetRelativeURL()) + ".dae");

					Console.WriteLine("EXPORT {0} TIME: Time taken: {1}", name, StopStopwatch());

					model_def.Close(tagindex);
				}
			}
		}
Esempio n. 13
0
		public void Halo1TestCOLLADAScenarioExport()
		{
			var settings = new TestColladaSettings(
				true,
				Path.Combine(kTestInstallationRootPath, kTestDataDir),
				AssetFormat.bmp);

			using (var handler = new TagIndexHandler<Managers.TagIndex>(BlamVersion.Halo1_CE, kTestInstallationRootPath, kTestDataDir))
			{
				var tagindex = handler.IndexInterface;
				foreach (var scenario_def in ScenarioTestDefinitions)
				{
					StartStopwatch();
					{
						scenario_def.Open(tagindex);
						Console.WriteLine(scenario_def.TypeString + " LOAD: Time taken: {0}", m_testStopwatch.Elapsed);
					}
					Console.WriteLine("TAG INDEX: Time taken: {0}", StopStopwatch());

					var tagManager = tagindex[scenario_def.TagIndex];

					var scenarioData = new BlamLib.Render.COLLADA.Halo1.ScenarioData();

					scenarioData.CollectData(tagindex, tagManager);

					var exporter = new BlamLib.Render.COLLADA.Halo1.ColladaScenarioExporter(settings,
						tagindex,
						tagManager);

					exporter.MessageSent +=
						(object sender, BlamLib.Messaging.MessageArgs args) =>
						{
							Console.WriteLine("COLLADA_ERROR: {0}", args.Message);
						};

					exporter.AddDataProvider(scenarioData);

					StartStopwatch();

					Assert.IsTrue(exporter.BuildColladaInstance(), "Failed to build collada instance for {0}", scenario_def.Name);
					exporter.SaveDAE(Path.Combine(kTestResultsDataPath, tagManager.Name) + "-objects.dae");

					Console.WriteLine("EXPORT {0} TIME: Time taken: {1}", scenario_def.Name, StopStopwatch());

					scenario_def.Close(tagindex);
				}
			}
		}
Esempio n. 14
0
		public void Halo2TestCOLLADABSPExport()
		{
			using (var handler = new TagIndexHandler<Managers.TagIndex>(BlamVersion.Halo2_PC, kTestTagIndexTagsPath))
			{
				var tagindex = handler.IndexInterface;
				foreach (var model_def in BSPTestDefinitions)
				{
					StartStopwatch();
					{
						model_def.Open(tagindex);
						Console.WriteLine("{0} LOAD: Time taken: {1}", model_def.TypeString, m_testStopwatch.Elapsed);
					}
					Console.WriteLine("TAG INDEX: Time taken: {0}", StopStopwatch());

					var halo2 = new BlamLib.Render.COLLADA.Halo2.ColladaHalo2(tagindex, model_def.TagIndex);

					halo2.Overwrite = true;
					halo2.RelativeFilePath = Path.Combine(kTestTagIndexTagsPath, @"data\");

					halo2.ClearRegister();

					foreach (var info in halo2)
						halo2.RegisterForExport(info);

					var bsp_info = halo2[0] as Render.COLLADA.Halo2.ColladaHalo2BSPInfo;

					StartStopwatch();
					halo2.Export(bsp_info.Name);
					Console.WriteLine("EXPORT {0} TIME: Time taken: {1}", bsp_info.Name, StopStopwatch());

					foreach (string report in halo2.Reports())
						Console.WriteLine(report);

					model_def.Close(tagindex);
				}
			}
		}
Esempio n. 15
0
		public void Halo1TestTagIndexNonTags()
		{
			using (var handler = new TagIndexHandler<Managers.TagIndex>(BlamVersion.Halo1_CE, kTestInstallationRootPath, kTestTagsDir))
			{
				var tagindex = handler.IndexInterface;

				using (var sw = new StreamWriter(Path.Combine(kTestResultsTagsPath, @"non_tag_files.txt")))
				{ tagindex.DumpNonTagFiles(sw); }
			}
		}
Esempio n. 16
0
		public void Halo1TestTagIndexSharingThreaded()
		{
			StartStopwatch();

			var bd = BlamLib.Program.Halo1.Manager;

			TagIndexHandler<Managers.TagIndex> handler_matg = null;
			var thread_matg = new System.Threading.Thread(delegate (/*object param*/)
			{
				StartSubStopwatch();
				handler_matg = new TagIndexHandler<Managers.TagIndex>(BlamVersion.Halo1_CE, kTestInstallationRootPath, kTestTagsDir);
				{
					var tagindex_matg = handler_matg.IndexInterface;

					var datum_test_index = tagindex_matg.Open(
						@"globals\globals", Blam.Halo1.TagGroups.matg,
						IO.ITagStreamFlags.LoadDependents);

					tagindex_matg.Open(@"ui\ui_tags_loaded_all_scenario_types", Blam.Halo1.TagGroups.tagc,
						IO.ITagStreamFlags.LoadDependents);

					Console.WriteLine("GLOBALS LOAD: Time taken: {0}", StopSubStopwatch());
				}
			});

			TagIndexHandler<Managers.TagIndex> handler_scnr = null;
			var thread_scnr = new System.Threading.Thread(delegate(/*object param*/)
			{
				StartSubStopwatch();
				handler_scnr = new TagIndexHandler<Managers.TagIndex>(BlamVersion.Halo1_CE, kTestInstallationRootPath, kTestTagsDir);
				{
					var tagindex_scnr = handler_scnr.IndexInterface;

					var datum_test_index2 = tagindex_scnr.Open(
						@"levels\test\tutorial\tutorial", Blam.Halo1.TagGroups.scnr,
						IO.ITagStreamFlags.LoadDependents);

					tagindex_scnr.Open(@"ui\ui_tags_loaded_multiplayer_scenario_type", Blam.Halo1.TagGroups.tagc,
						IO.ITagStreamFlags.LoadDependents);

					Console.WriteLine("SCENARIO LOAD: Time taken: {0}", StopSubStopwatch());
				}
			});

			thread_matg.Start(/*TestContext*/);
			thread_scnr.Start(/*TestContext*/);
			thread_matg.Join();
			thread_scnr.Join();

			using (var sw = new StreamWriter(Path.Combine(kTestResultsTagsPath, @"dump_tag_index_matg.txt")))
			{ handler_matg.IndexInterface.Dump(sw); }
			using (var sw = new StreamWriter(Path.Combine(kTestResultsTagsPath, @"dump_tag_index_sncr.txt")))
			{ handler_scnr.IndexInterface.Dump(sw); }
			using (var sw = new StreamWriter(Path.Combine(kTestResultsTagsPath, @"dump_shared_tag_index.txt")))
			{ handler_scnr.IndexInterface.DumpSharedReferences(sw, handler_matg.IndexInterface); }

			handler_matg.Dispose();
			handler_scnr.Dispose();

			Console.WriteLine("TOTAL: Time taken: {0}", StopStopwatch());
		}
Esempio n. 17
0
		public void Halo1TestTagIndexSharing()
		{
			using (var handler_matg = new TagIndexHandler<Managers.TagIndex>(BlamVersion.Halo1_CE, kTestInstallationRootPath, kTestTagsDir))
			using (var handler_scnr = new TagIndexHandler<Managers.TagIndex>(BlamVersion.Halo1_CE, kTestInstallationRootPath, kTestTagsDir))
			{
				var tagindex_matg = handler_matg.IndexInterface;
				var tagindex_scnr = handler_scnr.IndexInterface;

				Blam.DatumIndex datum_test_index, datum_test_index2;

				{
					StartStopwatch();
					datum_test_index = tagindex_matg.Open(
						@"globals\globals", Blam.Halo1.TagGroups.matg,
						IO.ITagStreamFlags.LoadDependents);
					Console.WriteLine("TEST LOAD: Time taken: {0}", StopStopwatch());
				}
				{
					StartStopwatch();
					datum_test_index2 = tagindex_scnr.Open(
						@"levels\test\tutorial\tutorial", Blam.Halo1.TagGroups.scnr,
						IO.ITagStreamFlags.LoadDependents);
					Console.WriteLine("TEST LOAD 2: Time taken: {0}", StopStopwatch());
				}

				//using (var sw = new StreamWriter(Path.Combine(kTestResultsTagsPath, @"dump_shared_tag_index.txt")))
				//{ tagindex_scnr.DumpSharedReferences(sw, tagindex_matg); }

				tagindex_matg.ToDatabase(Path.Combine(kTestResultsTagsPath, @"_matg.tag_database"));
				tagindex_scnr.ToDatabase(Path.Combine(kTestResultsTagsPath, @"_scnr.tag_database"));

				Assert.IsTrue(tagindex_scnr.Unload(datum_test_index2));
				Assert.IsTrue(tagindex_matg.Unload(datum_test_index));
			}
		}
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>	Constructor. </summary>
 ///
 /// <param name="rootPath">	The users HEK root directory. </param>
 public LightmapImporter()
 {
     mTagHandler    = null;
     mBSPDatumIndex = DatumIndex.Null;
 }