Ejemplo n.º 1
0
        public static void ApplySmoothingGroup(PBMesh pbMesh, MeshSelection selection, float angleThreshold)
        {
            selection = selection.ToFaces(false);

            ProBuilderMesh mesh  = pbMesh.ProBuilderMesh;
            IList <Face>   faces = new List <Face>();

            mesh.GetFaces(selection.GetFaces(pbMesh).ToArray(), faces);
            Smoothing.ApplySmoothingGroups(mesh, faces, angleThreshold);
        }
Ejemplo n.º 2
0
        public static void SetGroup(PBMesh pbMesh, MeshSelection selection, int index)
        {
            selection = selection.ToFaces(false);

            ProBuilderMesh mesh  = pbMesh.ProBuilderMesh;
            IList <Face>   faces = new List <Face>();

            mesh.GetFaces(selection.GetFaces(pbMesh).ToArray(), faces);

            foreach (Face face in faces)
            {
                face.smoothingGroup = index;
            }

            mesh.ToMesh();
            mesh.Refresh();
        }
Ejemplo n.º 3
0
        public static MeshSelection ExpandSelection(MeshSelection selection)
        {
            selection = selection.ToFaces(false);

            foreach (PBMesh pbMesh in selection.GetSelectedMeshes().ToArray())
            {
                ProBuilderMesh mesh          = pbMesh.ProBuilderMesh;
                IList <Face>   selectedFaces = new List <Face>();
                mesh.GetFaces(selection.GetFaces(pbMesh).ToArray(), selectedFaces);

                HashSet <int> groupsHs = new HashSet <int>();
                for (int i = 0; i < selectedFaces.Count; ++i)
                {
                    Face face = selectedFaces[i];
                    if (!groupsHs.Contains(face.smoothingGroup))
                    {
                        groupsHs.Add(face.smoothingGroup);
                    }
                }


                IList <int>  selectedIndices = new List <int>();
                IList <Face> faces           = mesh.faces;
                for (int i = 0; i < faces.Count; ++i)
                {
                    Face face = faces[i];
                    if (groupsHs.Contains(face.smoothingGroup))
                    {
                        selectedIndices.Add(i);
                    }
                }

                selection.SelectedFaces[pbMesh.gameObject] = selectedIndices;
            }

            return(selection);
        }