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


C# pb_Object.TriangleCount方法代码示例

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


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

示例1: Triangulate

		/**
		 * Triangulate an entire pb_Object.
		 */
		public static void Triangulate(pb_Object pb)
		{
			Vector3[] 	v = pb.vertices;
			Color[] 	c = pb.colors;
			Vector2[] 	u = pb.uv;

			int triangleCount = pb.TriangleCount();
			// int triangleCount = pb_Face.AllTriangles(pb.faces).Length; // pb.msh.triangles.Length;

			if(triangleCount == v.Length)
			{
				Debug.LogWarning("We can't pull over any further!\npb_Object: " + pb.name + " is already triangulated.");
			}

			int vertexCount = triangleCount;
			int faceCount = vertexCount / 3;

			Vector3[]	tri_vertices = new Vector3[vertexCount];
			Color[] 	tri_colors = new Color[vertexCount];
			Vector2[]	tri_uvs = new Vector2[vertexCount];
			pb_Face[]	tri_faces = new pb_Face[faceCount];

			int n = 0, f = 0;
			foreach(pb_Face face in pb.faces)
			{
				int[] indices = face.indices;

				for(int i = 0; i < indices.Length; i+=3)
				{
					tri_vertices[n+0] = v[indices[i+0]];
					tri_vertices[n+1] = v[indices[i+1]];
					tri_vertices[n+2] = v[indices[i+2]];

					tri_colors[n+0] = c[indices[i+0]];
					tri_colors[n+1] = c[indices[i+1]];
					tri_colors[n+2] = c[indices[i+2]];

					tri_uvs[n+0] = u[indices[i+0]];
					tri_uvs[n+1] = u[indices[i+1]];
					tri_uvs[n+2] = u[indices[i+2]];
		
					tri_faces[f++] = new pb_Face( new int[] { n+0, n+1, n+2 },
												face.material,
												face.uv,
												face.smoothingGroup,
												face.textureGroup,		// textureGroup -> force to manual uv mode
												face.elementGroup,
												face.manualUV
											);	
					n += 3;
				}

			}

			pb.SetVertices(tri_vertices);
			pb.SetColors(tri_colors);
			pb.SetUV(tri_uvs);
			pb.SetFaces(tri_faces);

			pb.SetSharedIndices( pb_IntArrayUtility.ExtractSharedIndices(tri_vertices) );
			pb.SetSharedIndicesUV( new pb_IntArray[0] );
		}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:65,代码来源:pbTriangleOps.cs


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