示例#1
0
		void ExportRenderModel(string file_name)
		{
			RenderModelInfoInternal model_info = new RenderModelInfoInternal();

			List<int> added_permutations = new List<int>();

			foreach (int index in registeredInfos)
			{
				RenderModelInfoInternal info = internalInfoList[index] as RenderModelInfoInternal;

				if (!added_permutations.Contains(info.Permutation))
					added_permutations.Add(info.Permutation);

				for (int i = 0; i < info.GetShaderCount(); i++)
					model_info.AddShaderDatum(info.GetShaderDatum(i), info.GetShaderName(i));
				for (int i = 0; i < info.GetGeometryCount(); i++)
					model_info.AddGeometry(info.GetGeometryName(i), info.GetGeometryIndex(i));
			}

			if (added_permutations.Count == 1)
				model_info.Permutation = added_permutations[0];
			else
				model_info.IsMultiplePermutations = true;

			ColladaExportArgs arguments = new ColladaExportArgs(Overwrite, RelativeFilePath, BitmapFormat);
			var exporter = new Halo2.ColladaRenderModelExporter(arguments, model_info, tagIndex, tagManager);

			ExportSave(exporter, RelativeFilePath + file_name + ".dae");
		}
示例#2
0
		/// <summary>
		/// Creates info classes for a render model
		/// </summary>
		void GenerateInfoListRenderModel()
		{
			string name = Path.GetFileNameWithoutExtension(tagManager.Name);

			int permutation_count = RenderModel.GetPermutationCount(tagManager);

			for (int i = 0; i < permutation_count; i++)
			{
				for (int j = 0; j < 6; j++)
				{
					RenderModelInfoInternal model_info_internal = new RenderModelInfoInternal();
					model_info_internal.Permutation = i;
					model_info_internal.IsMultiplePermutations = false;

					RenderModel.AddGeometryInfos(model_info_internal, tagManager, i, j);
					RenderModel.AddShaderDatums(model_info_internal, tagManager);

					internalInfoList.Add(model_info_internal);

					ColladaHalo2RenderModelInfo model_info = new ColladaHalo2RenderModelInfo(
						internalInfoList.Count - 1,
						Path.GetFileNameWithoutExtension(tagManager.Name),
						RenderModel.GetVertexCount(model_info_internal, tagManager),
						RenderModel.GetTriangleCount(model_info_internal, tagManager),
						i,
						j);

					Add(model_info);
				}
			}
		}
示例#3
0
			public static void AddShaderDatums(RenderModelInfoInternal model_info, TagManager manager)
			{
				var definition = manager.TagDefinition as Blam.Halo2.Tags.render_model_group;

				for(int i = 0; i <  model_info.GetGeometryCount(); i++)
				{
					foreach (var part in definition.Sections[model_info.GetGeometryIndex(i)].SectionData[0].Section.Value.Parts)
						model_info.AddShaderDatum(definition.Materials[part.Material].Shader.Datum,
							definition.Materials[part.Material].Shader.ToString());
				}
			}
示例#4
0
			public static int GetTriangleCount(RenderModelInfoInternal model_info, TagManager manager)
			{
				var definition = manager.TagDefinition as Blam.Halo2.Tags.render_model_group;

				int count = 0;
				for (int i = 0; i < model_info.GetGeometryCount(); i++)
					count += definition.Sections[model_info.GetGeometryIndex(i)].SectionInfo.Value.TotalTriangleCount;
				return count;
			}
示例#5
0
			public static void AddGeometryInfos(RenderModelInfoInternal model_info, TagManager manager, int permutation, int lod)
			{
				var definition = manager.TagDefinition as Blam.Halo2.Tags.render_model_group;

				for (int i = 0; i < definition.Regions.Count; i++ )
				{
					var region = definition.Regions[i];

					int permutation_index = permutation;

					if (permutation >= region.Permutations.Count)
						permutation_index = 0;

					string name = string.Format("{0}-{1}-lod{2}",
						definition.Regions[i].Name.ToString(), region.Permutations[permutation_index].Name.ToString(), lod);

					int index = 0;
					switch (lod)
					{
						case 0: index = region.Permutations[permutation_index].L6; break;
						case 1: index = region.Permutations[permutation_index].L5; break;
						case 2: index = region.Permutations[permutation_index].L4; break;
						case 3: index = region.Permutations[permutation_index].L3; break;
						case 4: index = region.Permutations[permutation_index].L2; break;
						case 5: index = region.Permutations[permutation_index].L1; break;
					};

					model_info.AddGeometry(name, index);
				}
			}