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


C# pb_Face类代码示例

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


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

示例1: HiddenFace

    public static bool HiddenFace(pb_Object pb, pb_Face q, float dist)
    {
        // Grab the face normal
        Vector3 dir = pb_Math.Normal(pb.VerticesInWorldSpace(q.indices));

        // If casting from the center of the plane hits, chekc the rest of the points for collisions
        Vector3 orig = pb.transform.TransformPoint(pb_Math.Average(pb.GetVertices(q)));

        bool hidden = true;
        Transform hitObj = RaycastFaceCheck(orig, dir, dist, null);
        if(hitObj != null)
        {
            Vector3[] v = pb.VerticesInWorldSpace(q.indices);
            for(int i = 0; i < v.Length; i++)
            {
                if(null == RaycastFaceCheck(v[i], dir, dist, hitObj))
                {
                    hidden = false;
                    break;
                }
            }
        }
        else
            hidden = false;

        return hidden;
    }
开发者ID:BaptisteBillet,项目名称:Prochain_Arret,代码行数:27,代码来源:AutoNodraw.cs

示例2: HiddenFace

    public static bool HiddenFace(pb_Object pb, pb_Face q, float dist)
    {
        // Grab the face normal
        Vector3 dir = pbUtil.PlaneNormal(pb.VerticesInWorldSpace(q));

        // And also the center of the face
        Vector3 orig = pb.QuadCenter(q);

        // Case a ray from the center of the face out in the normal direction.
        // If an object is hit, return true (that this face is hidden), otherwise
        // return false.  This is pretty simplistic and doesn't account for a lot
        // of "gotchas", but it ought to serve as a fairly decent jumping off point
        // for NoDrawing a dense level.
        RaycastHit hit;
        if(Physics.Raycast(orig, dir, out hit, dist)) {
            // We've hit something.  Now check to see if it is a ProBuilder object,
            // and if so, make sure it's a visblocking brush.
            pb_Entity ent = hit.transform.GetComponent<pb_Entity>();
            if(ent != null)
            {
                if(ent.entityType == ProBuilder.EntityType.Brush || ent.entityType == ProBuilder.EntityType.Occluder)
                    return true;		// it's a brush, blocks vision, return true
                else
                    return false;		// not a vis blocking brush
            }
        }

        // It ain't a ProBuilder object of the entity type Brush or Occluder (world brush)
        return false;
    }
开发者ID:rickypickle,项目名称:Melody-1978,代码行数:30,代码来源:AutoNodraw.cs

示例3: GetConnectedFaces

		/**
		 * \brief Returns all connected faces.
		 */
		public static List<pb_Face> GetConnectedFaces(pb_Object pb, pb_Face[] selFaces)
		{
			int len = selFaces.Length;

			List<pb_Face> faces = new List<pb_Face>();

			pb_IntArray[] sharedIndices = pb.sharedIndices;
				
			pb_Edge[][] sharedEdges = new pb_Edge[len][];
			for(int i = 0; i < len; i++)
				sharedEdges[i] = pb_Edge.GetUniversalEdges(selFaces[i].edges, sharedIndices);

			for(int i = 0; i < pb.faces.Length; i++)
			{
				pb_Edge[] faceEdges = pb_Edge.GetUniversalEdges(pb.faces[i].edges, sharedIndices);
				
				for(int j = 0; j < len; j++)
				{
					int ind = faceEdges.ContainsMatch(sharedEdges[j]);
					if(ind > -1)
						faces.Add(pb.faces[i]);
				}
			}

			return faces;
		}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:29,代码来源:pbMeshUtils.cs

示例4: AppendFace

/**
	 *	\brief
	 *	param sharedIndex An optional array that sets the new pb_Face indices to use the _sharedIndices array.
	 *	\returns The newly appended pb_Face.
	 */
	public static pb_Face AppendFace(this pb_Object pb, Vector3[] v, pb_Face face)
	{
		int[] shared = new int[v.Length];
		for(int i = 0; i < v.Length; i++)
			shared[i] = -1;
		return pb.AppendFace(v, face, shared);
	}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:12,代码来源:pbAppendDelete.cs

示例5: ReverseWindingOrder

	/**
	 * \brief Flips the winding order for the entire mesh. 
	 */
	// public static void ReverseWindingOrder(this pb_Object pb)
	// {
	// 	for(int i = 0; i < pb.faces.Length; i++)
	// 		pb.faces[i].ReverseIndices();
	
	// 	pb.ToMesh();
	// 	pb.Refresh();
	// }	

	/**
	 *	\brief Reverse the winding order for each passed #pb_Face.
	 *	@param faces The faces to apply normal flippin' to.
	 *	\returns Nothing.  No soup for you.
	 *	\sa SelectedFaces pb_Face
	 */
	public static void ReverseWindingOrder(this pb_Object pb, pb_Face[] faces)
	{
		for(int i = 0; i < faces.Length; i++)
			faces[i].ReverseIndices();

		pb.ToMesh();
		pb.Refresh();
	}	
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:26,代码来源:pbTriangleOps.cs

示例6: SubdivideFace

	public static bool SubdivideFace(this pb_Object pb, pb_Face[] faces, out pb_Face[] splitFaces)
	{
		List<EdgeConnection> split = new List<EdgeConnection>();
		foreach(pb_Face face in pb.SelectedFaces)
			split.Add(new EdgeConnection(face, new List<pb_Edge>(face.edges)));

		return pb.ConnectEdges(split, out splitFaces);
	}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:8,代码来源:pbSubdivideSplit.cs

示例7: Triangulate

	static void Triangulate(pb_Object pb)
	{
		Vector3[] 	v = pb.vertices;
		Vector2[] 	u = pb.msh.uv;

		int triangleCount = 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];
		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_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,			// manualUV
											face.color
										);	
				n += 3;
			}

		}

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

		pb.SetSharedIndices( pb_IntArrayUtility.ExtractSharedIndices(tri_vertices) );
		pb.SetSharedIndicesUV( new pb_IntArray[0] );
	}
开发者ID:benlewis,项目名称:unhinged_vr,代码行数:55,代码来源:TriangulatePbObject.cs

示例8: AppendFaces

	/**
	 * Append a group of new faces to the pb_Object.  Significantly faster than calling AppendFace multiple times.
	 */
	public static pb_Face[] AppendFaces(this pb_Object pb, Vector3[][] new_Vertices, Color[][] new_Colors, Vector2[][] new_uvs, pb_Face[] new_Faces, int[][] new_SharedIndices)
	{
		List<Vector3> _verts = new List<Vector3>(pb.vertices);
		List<Color> _colors = new List<Color>(pb.colors);
		List<Vector2> _uv = new List<Vector2>(pb.uv);

		List<pb_Face> _faces = new List<pb_Face>(pb.faces);
		pb_IntArray[] sharedIndices = pb.sharedIndices;

		int vc = pb.vertexCount;

		for(int i = 0; i < new_Faces.Length; i++)
		{
			_verts.AddRange(new_Vertices[i]);
			_colors.AddRange(new_Colors[i]);
			_uv.AddRange(new_uvs[i]);

			new_Faces[i].ShiftIndicesToZero();
			new_Faces[i].ShiftIndices(vc);
			new_Faces[i].RebuildCaches();
			_faces.Add(new_Faces[i]);

			if(new_SharedIndices != null && new_Vertices[i].Length != new_SharedIndices[i].Length)
			{
				Debug.LogError("Append Face failed because sharedIndex array does not match new vertex array.");
				return null;
			}

			if(new_SharedIndices != null)
			{
				for(int j = 0; j < new_SharedIndices[i].Length; j++)
				{
					pb_IntArrayUtility.AddValueAtIndex(ref sharedIndices, new_SharedIndices[i][j], j+vc);
				}
			}
			else
			{
				for(int j = 0; j < new_Vertices[i].Length; j++)
				{
					pb_IntArrayUtility.AddValueAtIndex(ref sharedIndices, -1, j+vc);
				}
			}

			vc = _verts.Count;
		}

		pb.SetSharedIndices(sharedIndices);

		pb.SetVertices(_verts.ToArray());
		pb.SetColors(_colors.ToArray());
		pb.SetUV(_uv.ToArray());
		pb.SetFaces(_faces.ToArray());

		return new_Faces;
	}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:58,代码来源:pbAppendDelete.cs

示例9: AppendFaces

	/**
	 * Append a group of new faces to the pb_Object.  Significantly faster than calling AppendFace multiple times.
	 */
	public static pb_Face[] AppendFaces(this pb_Object pb, Vector3[][] new_Vertices, pb_Face[] new_Faces, int[][] new_SharedIndices)
	{
		List<Vector3> _verts = new List<Vector3>(pb.vertices);
		List<pb_Face> _faces = new List<pb_Face>(pb.faces);
		pb_IntArray[] sharedIndices = pb.sharedIndices;

		int vc = pb.vertexCount;

		// Dictionary<int, int> grp = new Dictionary<int, int>();	// this allows append face to add new vertices to a new shared index group
		// 														// if the sharedIndex is negative and less than -1, it will create new gorup
		// 														// that other sharedIndex members can then append themselves to.
		for(int i = 0; i < new_Faces.Length; i++)
		{
			_verts.AddRange(new_Vertices[i]);
			new_Faces[i].ShiftIndicesToZero();
			new_Faces[i].ShiftIndices(vc);
			_faces.Add(new_Faces[i]);

			if(new_SharedIndices != null && new_Vertices[i].Length != new_SharedIndices[i].Length)
			{
				Debug.LogError("Append Face failed because sharedIndex array does not match new vertex array.");
				return null;
			}

			if(new_SharedIndices != null)
				for(int j = 0; j < new_SharedIndices[i].Length; j++)
				{
					// TODO - FIX ME
					// if(new_SharedIndices[i][j] < -1)
					// {
					// 	if(grp.ContainsKey(new_SharedIndices[i][j]))
					// 		AddValueAtIndex(grp[new_SharedIndices[i][j]], j+vc);
					// 	else
					// 		grp.Add(new_SharedIndices[i][j], AddValueAtIndex(new_SharedIndices[i][j], j+vc));
					// }
					// else
						pb_IntArrayUtility.AddValueAtIndex(ref sharedIndices, new_SharedIndices[i][j], j+vc);
				}
			else
				for(int j = 0; j < new_Vertices[i].Length; j++)
				{
					pb_IntArrayUtility.AddValueAtIndex(ref sharedIndices, -1, j+vc);
				}
			vc = _verts.Count;
		}

		pb.SetSharedIndices(sharedIndices);
		pb.SetVertices(_verts.ToArray());
		pb.SetFaces(_faces.ToArray());
		pb.ToMesh();

		return new_Faces;
	}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:56,代码来源:pbAppendDelete.cs

示例10: Normal

		public static Vector3 Normal(pb_Object pb, pb_Face face)
		{
			Vector3 p0 = pb.vertices[face.indices[0]];
			Vector3 p1 = pb.vertices[face.indices[1]];
			Vector3 p2 = pb.vertices[face.indices[2]];

			Vector3 cross = Vector3.Cross(p1 - p0, p2 - p0);
			if (cross.magnitude < Mathf.Epsilon)
				return new Vector3(0f, 0f, 0f); // bad triangle
			else
			{
				return cross.normalized;
			}
		}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:14,代码来源:pb_Math.cs

示例11: pb_SerializableFace

 public pb_SerializableFace(pb_Face face)
 {
     this.indices			= face.indices;
     this.distinctIndices	= face.distinctIndices;
     this.edges				= face.edges;
     this.smoothingGroup		= face.smoothingGroup;
     this.uv					= face.uv;
     this.material			= face.material;
     this.manualUV  			= false;
     pb_UpgradeKitUtils.TryGetField(face, "manualUV", ref this.manualUV);
     this.elementGroup		= -1;
     pb_UpgradeKitUtils.TryGetField(face, "elementGroup", ref this.elementGroup);
     this.textureGroup		= -1;
     pb_UpgradeKitUtils.TryGetField(face, "textureGroup", ref this.textureGroup);
 }
开发者ID:HaikunHuang,项目名称:TutorialForTaikeQ,代码行数:15,代码来源:pb_SerializableFace.cs

示例12: InitWithObject

	/**
	 *	\brief Duplicates and returns the passed pb_Object.
	 *	@param pb The pb_Object to duplicate.
	 *	\returns A unique copy of the passed pb_Object.
	 */
	public static pb_Object InitWithObject(pb_Object pb)
	{
		Vector3[] v = new Vector3[pb.vertexCount];
		System.Array.Copy(pb.vertices, v, pb.vertexCount);

		pb_Face[] f = new pb_Face[pb.faces.Length];
		
		for(int i = 0; i < f.Length; i++)
			f[i] = new pb_Face(pb.faces[i]);

		pb_Object p = CreateInstanceWithVerticesFacesSharedIndices(v, f, pb.GetSharedIndices());

		p.gameObject.name = pb.gameObject.name + "-clone";

		return p;
	}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:21,代码来源:pb_Object.cs

示例13: GetWindingOrder

		/**
		 * Attempt to figure out the winding order the passed face.  Note that 
		 * this may return WindingOrder.Unknown.
		 */
		public static WindingOrder GetWindingOrder(this pb_Object pb, pb_Face face)
		{
			Vector2[] p = pb_Math.PlanarProject(pb.GetVertices( face.edges.AllTriangles() ), pb_Math.Normal(pb, face));

			float sum = 0f;

			// http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order
			for(int i = 0; i < p.Length; i++)
			{
				Vector2 a = p[i];
				Vector2 b = i < p.Length - 1 ? p[i+1] : p[0];

				sum += ( (b.x-a.x) * (b.y+a.y) );
			}

			return sum == 0f ? WindingOrder.Unknown : (sum >= 0f ? WindingOrder.Clockwise : WindingOrder.CounterClockwise);
		}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:21,代码来源:pbTriangleOps.cs

示例14: pb_Face

	/**
	 * Deep copy constructor.
	 */
	public pb_Face(pb_Face face)
	{
		_indices = new int[face.indices.Length];
		System.Array.Copy(face.indices, _indices, face.indices.Length);
		
		_uv = new pb_UV(face.uv);

		_mat = face.material;

		_smoothingGroup = face.smoothingGroup;
		textureGroup = face.textureGroup;
		elementGroup = face.elementGroup;

		_colors = new Color32[face.colors.Length];
		System.Array.Copy(face.colors, _colors, colors.Length);
		
		manualUV = face.manualUV;

		RebuildCaches();
	}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:23,代码来源:pb_Face.cs

示例15: AppendFace

	/**
	 * Append a new face to the pb_Object using sharedIndex array to set the face indices to sharedIndex groups.
	 */
	public static pb_Face AppendFace(this pb_Object pb, Vector3[] v, Color[] c, Vector2[] u, pb_Face face, int[] sharedIndex)
	{
		int vertexCount = pb.vertexCount;

		Vector3[] _verts = new Vector3[vertexCount + v.Length];
		Color[] _colors = new Color[vertexCount + c.Length];
		Vector2[] _uvs = new Vector2[pb.uv.Length + u.Length];

		List<pb_Face> _faces = new List<pb_Face>(pb.faces);
		pb_IntArray[] sharedIndices = pb.sharedIndices;

		// copy new vertices
		System.Array.Copy(pb.vertices, 0, _verts, 0, vertexCount);
		System.Array.Copy(v, 0, _verts, vertexCount, v.Length);

		// copy new colors
		System.Array.Copy(pb.colors, 0, _colors, 0, vertexCount);
		System.Array.Copy(c, 0, _colors, vertexCount, c.Length);

		// copy new uvs
		System.Array.Copy(pb.uv, 0, _uvs, 0, pb.uv.Length);
		System.Array.Copy(u, 0, _uvs, pb.uv.Length, u.Length);

		face.ShiftIndicesToZero();
		face.ShiftIndices(vertexCount);
		face.RebuildCaches();

		_faces.Add(face);

		for(int i = 0; i < sharedIndex.Length; i++)
			pb_IntArrayUtility.AddValueAtIndex(ref sharedIndices, sharedIndex[i], i+vertexCount);

		pb.SetVertices( _verts );
		pb.SetColors( _colors );
		pb.SetUV( _uvs );
		
		pb.SetSharedIndices(sharedIndices);
		pb.SetFaces(_faces.ToArray());

		return face;
	}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:44,代码来源:pbAppendDelete.cs


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