当前位置: 首页>>代码示例>>C#>>正文


C# Part.AddIndices方法代码示例

本文整理汇总了C#中Part.AddIndices方法的典型用法代码示例。如果您正苦于以下问题:C# Part.AddIndices方法的具体用法?C# Part.AddIndices怎么用?C# Part.AddIndices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Part的用法示例。


在下文中一共展示了Part.AddIndices方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreatePortalsGeometry

		/// <summary>
		/// Creates a geometry element for a single cluster portal
		/// </summary>
		/// <param name="portal_index">Index of the portal to create a geometry element for</param>
		/// <returns></returns>
		void CreatePortalsGeometry(int index)
		{
			H2.Tags.scenario_structure_bsp_group definition = tagManager.TagDefinition as H2.Tags.scenario_structure_bsp_group;

			List<Vertex> common_vertices = new List<Vertex>();
			// add the vertex position information to the position source
			foreach(var vertex in definition.ClusterPortals[index].Vertices)
				common_vertices.Add(new Vertex(vertex.Point.ToPoint3D(100)));

			List<Part> common_parts = new List<Part>();

			// only one part is needed since one one material is used
			Part common_part = new Part("portals");
			common_part.AddIndices(BuildFaceIndices(definition.ClusterPortals[index].Vertices.Count));
			common_parts.Add(common_part);

			// create the geometry element
			CreateGeometry("portal-" + index.ToString(), 0, VertexComponent.POSITION,
				common_vertices, common_parts);
		}
开发者ID:CodeAsm,项目名称:open-sauce,代码行数:25,代码来源:ExporterBSP.cs

示例2: CreateFogPlaneGeometry

		/// <summary>
		/// Creates a geometry element for a single fog plane
		/// </summary>
		/// <param name="index">Index of the fog plane to create a geometry element for</param>
		/// <returns></returns>
		void CreateFogPlaneGeometry(int index)
		{
			H1.Tags.structure_bsp_group definition = tagManager.TagDefinition as H1.Tags.structure_bsp_group;

			List<Vertex> common_vertices = new List<Vertex>();

			foreach (var vertex in definition.FogPlanes[index].Vertices)
				common_vertices.Add(new Vertex(vertex.Value.ToPoint3D(100)));

			List<Part> common_parts = new List<Part>();

			// we only have one part since it only has one material
			Part common_part = new Part("fogplanes");
			common_part.AddIndices(BuildFaceIndices(definition.FogPlanes[index].Vertices.Count));
			common_parts.Add(common_part);

			// create the geometry element
			CreateGeometry("fogplane-" + index.ToString(), 0, VertexComponent.POSITION,
				common_vertices, common_parts);
		}
开发者ID:CodeAsm,项目名称:open-sauce,代码行数:25,代码来源:ExporterBSP.cs

示例3: CreateGeometryHalo2

		/// <summary>
		/// Creates a geometry element for a Halo geometry section
		/// </summary>
		/// <param name="name">The name for the geometry</param>
		/// <param name="is_skinned">Controls whether the strip indices should be treated as a triangle strip or a triangle list</param>
		/// <param name="section">The geometry section to create an element for</param>
		/// <param name="shader_names">A string list containing all of the shader names</param>
		protected void CreateGeometryHalo2(string name, bool is_skinned, 
			H2.Tags.global_geometry_section_info_struct section_info, H2.Tags.global_geometry_section_struct section, 
			List<string> shader_names)
		{
			List<Vertex> common_vertices = new List<Vertex>();
			// create a generic list of vertices
			foreach (var vertex in section.RawVertices)
			{
				Vertex common_vertex = new Vertex(
					vertex.Point.Position.ToPoint3D(100),
					vertex.Normal.ToVector3D(),
					vertex.Binormal.ToVector3D(),
					vertex.Tangent.ToVector3D());

				common_vertex.AddTexcoord(new LowLevel.Math.real_point2d(
					vertex.Texcoord.X,
					(vertex.Texcoord.Y * -1) + 1));
				common_vertex.AddTexcoord(new LowLevel.Math.real_point2d(
					vertex.SecondaryTexcoord.X,
					(vertex.SecondaryTexcoord.Y * -1) + 1));
				common_vertex.AddTexcoord(new LowLevel.Math.real_point2d(
					vertex.PrimaryLightmapTexcoord.X,
					(vertex.PrimaryLightmapTexcoord.Y * -1) + 1));

				common_vertices.Add(common_vertex);
			}

			List<Part> commom_parts = new List<Part>();
			// create the generic part definition list
			for (int part_index = 0; part_index < section.Parts.Count; part_index++)
			{
				string shader_name;
				if (shader_names.Count == 0)
					shader_name = "";
				else
					shader_name = shader_names[section.Parts[part_index].Material];

				Part common_part = new Part(shader_name);

				if(is_skinned)
					common_part.AddIndices(CreateIndicesSkinned(section, part_index));
				else
					common_part.AddIndices(CreateIndicesWorldSpace(section, part_index));

				commom_parts.Add(common_part);
			}

			// create the geometry element
			CreateGeometry(name, 3,
				VertexComponent.POSITION | VertexComponent.NORMAL | VertexComponent.BINORMAL | VertexComponent.TANGENT | VertexComponent.TEXCOORD,
				common_vertices, commom_parts);
		}
开发者ID:CodeAsm,项目名称:open-sauce,代码行数:59,代码来源:Base.cs

示例4: CreateRenderGeometry

		/// <summary>
		/// Creates a geometry element for a BSP lightmap
		/// </summary>
		/// <param name="index">The lightmap index to create a geometry from</param>
		/// <returns></returns>
		void CreateRenderGeometry(int index)
		{
			H1.Tags.structure_bsp_group definition = tagManager.TagDefinition as H1.Tags.structure_bsp_group;

			List<Vertex> common_vertices = new List<Vertex>();

			// add all of the vertices used in the render geometry
			foreach (var material in definition.Lightmaps[index].Materials)
			{
				// read vertex information from the uncompressed vertex data
				System.IO.BinaryReader uncompressed_reader = new System.IO.BinaryReader(
					new System.IO.MemoryStream(material.UncompressedVertices.Value));

				int vertex_count = material.VertexBuffersCount1;

				for (int vertex_index = 0; vertex_index < vertex_count; vertex_index++)
				{
					Vertex common_vertex = new Vertex(
						//RealPoint3D position
						new LowLevel.Math.real_point3d(
							uncompressed_reader.ReadSingle() * 100,
							uncompressed_reader.ReadSingle() * 100,
							uncompressed_reader.ReadSingle() * 100),
						//RealVector3D  normal
						new LowLevel.Math.real_vector3d(
							uncompressed_reader.ReadSingle(),
							uncompressed_reader.ReadSingle(),
							uncompressed_reader.ReadSingle()),
						//RealVector3D  binormal
						new LowLevel.Math.real_vector3d(
							uncompressed_reader.ReadSingle(),
							uncompressed_reader.ReadSingle(),
							uncompressed_reader.ReadSingle()),
						//RealVector3D  tangent
						new LowLevel.Math.real_vector3d(
							uncompressed_reader.ReadSingle(),
							uncompressed_reader.ReadSingle(),
							uncompressed_reader.ReadSingle()));

					//RealPoint2D   texcoord0
					common_vertex.AddTexcoord(new LowLevel.Math.real_point2d(
						uncompressed_reader.ReadSingle(),
						(uncompressed_reader.ReadSingle() * -1) + 1));

					//RealPoint2D   texcoord1
					if (material.VertexBuffersCount2 != 0)
					{
						int position = (int)uncompressed_reader.BaseStream.Position;
						uncompressed_reader.BaseStream.Position = (material.VertexBuffersCount1 * 56) + (vertex_index * 20) + 12;

						common_vertex.AddTexcoord(new LowLevel.Math.real_point2d(
							uncompressed_reader.ReadSingle(),
							(uncompressed_reader.ReadSingle() * -1) + 1));

						uncompressed_reader.BaseStream.Position = position;
					}
					else
						common_vertex.AddTexcoord(new LowLevel.Math.real_point2d(0, 1));

					common_vertices.Add(common_vertex);
				};
			}

			List<Part> common_parts = new List<Part>();

			// add part definitions for the lightmap materials
			// an index offset is necessary since the vertex list is global for this geometry, rather than local to each material
			int index_offset = 0;
			foreach (var material in definition.Lightmaps[index].Materials)
			{
				Part common_part = new Part(Path.GetFileNameWithoutExtension(material.Shader.ToString()));
				common_part.AddIndices(CreateIndicesBSP(definition, material.Surfaces, material.SurfaceCount, index_offset));

				index_offset += material.VertexBuffersCount1;

				common_parts.Add(common_part);
			}

			// create the geometry element
			CreateGeometry(ColladaUtilities.FormatName(tagName, " ", "_") + "-" + definition.Lightmaps[index].Bitmap.ToString(), 2,
				VertexComponent.POSITION | VertexComponent.NORMAL | VertexComponent.BINORMAL | VertexComponent.TANGENT | VertexComponent.TEXCOORD,
				common_vertices, common_parts);
		}
开发者ID:CodeAsm,项目名称:open-sauce,代码行数:88,代码来源:ExporterBSP.cs

示例5: CreateGeometryList

		/// <summary>
		/// Creates geometry elements for all of the included geometry blocks
		/// </summary>
		void CreateGeometryList()
		{
			H1.Tags.gbxmodel_group definition = tagManager.TagDefinition as H1.Tags.gbxmodel_group;

			// create a list contining the names of all the shaders being used
			List<string> shader_names = new List<string>();
			foreach (var shader in definition.Shaders)
				shader_names.Add(Path.GetFileNameWithoutExtension(shader.Shader.ToString()));

			for (int i = 0; i < modelInfo.GetGeometryCount(); i++)
			{
				string name = ColladaUtilities.FormatName(modelInfo.GetGeometryName(i), " ", "_");
				
				List<Vertex> common_vertices = new List<Vertex>();

				H1.Tags.gbxmodel_group.model_geometry_block geometry = definition.Geometries[modelInfo.GetGeometryIndex(i)];

				// collect the vertices for all of the geometries parts
				foreach(var part in geometry.Parts)
				{
					foreach(var vertex in part.UncompressedVertices)
					{
						Vertex common_vertex = new Vertex(vertex.Position.ToPoint3D(100),
							vertex.Normal.ToVector3D(),
							vertex.Binormal.ToVector3D(),
							vertex.Tangent.ToVector3D());

						// if the texture coordinate scale is 0.0, default to 1.0
						float u_scale = (definition.BaseMapUScale.Value == 0.0f ? 1.0f : definition.BaseMapUScale.Value);
						float v_scale = (definition.BaseMapVScale.Value == 0.0f ? 1.0f : definition.BaseMapVScale.Value);

						// add the texture coordinate data
						common_vertex.AddTexcoord(new LowLevel.Math.real_point2d(
							vertex.TextureCoords.X * u_scale,
							((vertex.TextureCoords.Y * v_scale) * -1) + 1));

						common_vertices.Add(common_vertex);
					}
				}
				
				List<Part> common_parts = new List<Part>();
				// create a new Part for each geometry part
				int index_offset = 0;
				foreach(var part in geometry.Parts)
				{
					Part common_part = new Part(shader_names[part.ShaderIndex]);
					common_part.AddIndices(CreateIndicesModel(part, index_offset));

					index_offset += part.UncompressedVertices.Count;

					common_parts.Add(common_part);
				}

				// create the geometry element
				CreateGeometry(name, 1,
					VertexComponent.POSITION | VertexComponent.NORMAL | VertexComponent.BINORMAL | VertexComponent.TANGENT | VertexComponent.TEXCOORD,
					common_vertices, common_parts);
			}
		}
开发者ID:CodeAsm,项目名称:open-sauce,代码行数:62,代码来源:ExporterModel.cs


注:本文中的Part.AddIndices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。