Beispiel #1
0
		void ExportModel(string file_name)
		{
			ModelInfoInternal model_info = new ModelInfoInternal();

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

			// create an info object with all of the registered infos combined
			foreach (int index in registeredInfos)
			{
				ModelInfoInternal info = internalInfoList[index] as ModelInfoInternal;

				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 Halo1.ColladaModelExporter(arguments, model_info, tagIndex, tagManager);

			ExportSave(exporter, RelativeFilePath + file_name + ".dae");
		}
Beispiel #2
0
		/// <summary>
		/// Creates info classes for a gbxmodel
		/// </summary>
		void GenerateInfoListModel()
		{
			int permutation_count = Model.GetPermutationCount(tagManager);

			for (int i = 0; i < permutation_count; i++)
			{
				for (int j = 0; j < 5; j++)
				{
					ModelInfoInternal model_info_internal = new ModelInfoInternal();

					model_info_internal.Permutation = i;
					model_info_internal.IsMultiplePermutations = false;
					Model.AddGeometryInfos(model_info_internal, tagManager, i, j);
					Model.AddShaderDatums(model_info_internal, tagManager);

					internalInfoList.Add(model_info_internal);

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

					Add(model_info);
				}
			}
		}
Beispiel #3
0
			public static int GetTriangleCount(ModelInfoInternal model_info, TagManager manager)
			{
				var definition = manager.TagDefinition as Blam.Halo1.Tags.gbxmodel_group;

				int triangle_count = 0;
				for (int i = 0; i < model_info.GetGeometryCount(); i++)
				{
					foreach (var part in definition.Geometries[model_info.GetGeometryIndex(i)].Parts)
						triangle_count += part.Triangles.Count;
				}
				return triangle_count;
			}
Beispiel #4
0
			public static int GetVertexCount(ModelInfoInternal model_info, TagManager manager)
			{
				var definition = manager.TagDefinition as Blam.Halo1.Tags.gbxmodel_group;

				int vertex_count = 0;
				for (int i = 0; i < model_info.GetGeometryCount(); i++)
				{
					foreach (var part in definition.Geometries[model_info.GetGeometryIndex(i)].Parts)
						vertex_count += part.UncompressedVertices.Count;
				}
				return vertex_count;
			}
Beispiel #5
0
			public static void AddShaderDatums(ModelInfoInternal model_info, TagManager manager)
			{
				var definition = manager.TagDefinition as Blam.Halo1.Tags.gbxmodel_group;

				for (int i = 0; i < model_info.GetGeometryCount(); i++)
				{
					foreach (var part in definition.Geometries[model_info.GetGeometryIndex(i)].Parts)
						model_info.AddShaderDatum(definition.Shaders[part.ShaderIndex.Value].Shader.Datum,
							definition.Shaders[part.ShaderIndex.Value].Shader.ToString());
				}
			}
Beispiel #6
0
			public static void AddGeometryInfos(ModelInfoInternal model_info, TagManager manager, int permutation, int lod)
			{
				var definition = manager.TagDefinition as Blam.Halo1.Tags.gbxmodel_group;

				foreach (var region in definition.Regions)
				{
					int permutation_index = permutation;

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

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

					int index = 0;
					switch (lod)
					{
						case 0: index = region.Permutations[permutation_index].SuperHigh; break;
						case 1: index = region.Permutations[permutation_index].High; break;
						case 2: index = region.Permutations[permutation_index].Medium; break;
						case 3: index = region.Permutations[permutation_index].Low; break;
						case 4: index = region.Permutations[permutation_index].SuperLow; break;
					};

					model_info.AddGeometry(name, index);
				}
			}