Ejemplo n.º 1
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);
                }
            }
        }
Ejemplo n.º 2
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);
				}
			}
		}