示例#1
0
        private void ShowRefinement(int vertexid1, int vertexid2)
        {
            if (activeControllers.Count == 2)
            {
                //splitManifold = Extrudable._manifold.Copy();

                //int edge = adjacentVertices[activeControllers[1].AssociatedVertexID];

                /*
                 * Debug.Log("vertexid2: " + vertexid2);
                 *
                 * string text = "";
                 *
                 * foreach (KeyValuePair<int, int> kvp in adjacentVertices)
                 * {
                 *  //textBox3.Text += ("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
                 *  text += string.Format("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
                 * }
                 * Debug.Log(text);
                 */
                int edge = adjacentVertices[vertexid2];

                splitManifold = Extrudable._manifold.Copy();

                int edge2 = splitManifold.GetNextHalfEdge(edge);

                edge2 = splitManifold.GetNextHalfEdge(edge2);

                splitManifold.RefineFaceloop(edge, edge2);

                //Extrudable._manifold.RefineFaceloop(edge, edge2);
                splitManifold.StitchMesh(1e-10);
                var newMesh = new Mesh();
                newMesh.vertices     = mesh.vertices;
                newMesh.normals      = mesh.normals;
                newMesh.subMeshCount = 2;
                newMesh.SetIndices(mesh.triangles, MeshTopology.Triangles, 0);
                //newMesh.SetIndices(new int[0], MeshTopology.Lines, 1);
                mesh = newMesh;
                mesh.UploadMeshData(false);
                GameObject refinePreview = GameObject.FindGameObjectWithTag("RefinePreview");
                refinePreview.GetComponent <MeshFilter>().mesh      = CreatePreviewMesh();
                refinePreview.GetComponent <MeshRenderer>().enabled = true;
            }
        }