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


C# pb_Face.isValid方法代码示例

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


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

示例1: AppendVerticesToFace

	/**
	 *	Given a face and a point, this will add a vertex to the pb_Object and retriangulate the face.
	 */
	public static bool AppendVerticesToFace(this pb_Object pb, pb_Face face, List<Vector3> points, out pb_Face newFace)
	{
		if(!face.isValid())
		{
			newFace = face;
			return false;
		}

		// First order of business - project face to 2d
		int[] distinctIndices = face.distinctIndices;
		Vector3[] verts = pb.GetVertices(distinctIndices);

		// Get the face normal before modifying the vertex array
		Vector3 nrm = pb_Math.Normal(pb.GetVertices(face.indices));
		Vector3 projAxis = pb_Math.GetProjectionAxis(nrm).ToVector3();
		
		// Add the new point
		Vector3[] t_verts = new Vector3[verts.Length + points.Count];
		System.Array.Copy(verts, 0, t_verts, 0, verts.Length);
		System.Array.Copy(points.ToArray(), 0, t_verts, verts.Length, points.Count);

		verts = t_verts;

		// Project
		List<Vector2> plane = new List<Vector2>(pb_Math.VerticesTo2DPoints(verts, projAxis));

		// Save the sharedIndices index for each distinct vertex
		pb_IntArray[] sharedIndices = pb.sharedIndices;
		int[] sharedIndex = new int[distinctIndices.Length+points.Count];
		for(int i = 0; i < distinctIndices.Length; i++)
			sharedIndex[i] = sharedIndices.IndexOf(distinctIndices[i]);
		
		for(int i = distinctIndices.Length; i < distinctIndices.Length+points.Count; i++)
			sharedIndex[i] = -1;	// add the new vertex to it's own sharedIndex

		// Triangulate the face with the new point appended
		int[] tris = Delauney.Triangulate(plane).ToIntArray();

		// Check to make sure the triangulated face is facing the same direction, and flip if not
		Vector3 del = Vector3.Cross( verts[tris[2]] - verts[tris[0]], verts[tris[1]]-verts[tris[0]]).normalized;
		if(Vector3.Dot(nrm, del) > 0) System.Array.Reverse(tris);

		// Compose new face
		newFace = pb.AppendFace(verts, new pb_Face(tris, face.material, new pb_UV(face.uv), face.smoothingGroup, face.textureGroup, -1, face.color), sharedIndex);

		// And delete the old
		pb.DeleteFace(face);	

		return true;
	}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:53,代码来源:pbVertexOps.cs


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