Beispiel #1
0
        public static bool SubdivideFace(this pb_Object pb, pb_Face[] faces, out pb_Face[] splitFaces)
        {
            List <pb_EdgeConnection> split = new List <pb_EdgeConnection>();

            foreach (pb_Face face in faces)
            {
                split.Add(new pb_EdgeConnection(face, new List <pb_Edge>(face.edges)));
            }

            return(pb.ConnectEdges(split, out splitFaces));
        }
        private static bool ConnectEdges(pb_Object pb, pb_Edge[] edgesToConnect)
        {
            int len = edgesToConnect.Length;
            List <EdgeConnection> splits = new List <EdgeConnection>();

            for (int i = 0; i < len; i++)
            {
                foreach (pb_Face face in pbMeshUtils.GetConnectedFaces(pb, edgesToConnect[i]))
                {
                    if (!splits.Contains((EdgeConnection)face))
                    {
                        List <pb_Edge> faceEdges = new List <pb_Edge>();
                        foreach (pb_Edge e in edgesToConnect)
                        {
                            int localEdgeIndex = face.edges.IndexOf(e, pb.sharedIndices);
                            if (localEdgeIndex > -1)
                            {
                                faceEdges.Add(face.edges[localEdgeIndex]);
                            }
                        }

                        if (faceEdges.Count > 1)
                        {
                            splits.Add(new EdgeConnection(face, faceEdges));
                        }
                    }
                }
            }

            pb_Face[] faces;
            if (pb.ConnectEdges(splits, out faces))
            {
                pb.SetSelectedFaces(faces);
                pb.GenerateUV2(true);
                pb.Refresh();
                return(true);
            }
            return(false);
        }
Beispiel #3
0
		private static bool ConnectEdges(pb_Object pb, pb_Edge[] edgesToConnect)
		{	
			int len = edgesToConnect.Length;
			List<EdgeConnection> splits = new List<EdgeConnection>();

			for(int i = 0; i < len; i++)
			{
				foreach(pb_Face face in pbMeshUtils.GetConnectedFaces(pb, edgesToConnect[i]))
				{
					if(!splits.Contains((EdgeConnection)face))
					{
						List<pb_Edge> faceEdges = new List<pb_Edge>();
						foreach(pb_Edge e in edgesToConnect)
						{
							int localEdgeIndex = face.edges.IndexOf(e, pb.sharedIndices);
							if(localEdgeIndex > -1)
								faceEdges.Add(face.edges[localEdgeIndex]);
						}
	
						if(faceEdges.Count > 1)	
							splits.Add(new EdgeConnection(face, faceEdges));
					}
				}
			}

			pb_Face[] faces;
			if(pb.ConnectEdges(splits, out faces))
			{
				pb.SetSelectedFaces(faces);
				pb.GenerateUV2(true);
				pb.Refresh();
				return true;
			}
			return false;
		}