Пример #1
0
        public bool AppendMesh(IMesh appendMesh, IndexMap mergeMapV, out int[] mapV, int appendGID = -1)
        {
            mapV = new int[appendMesh.MaxVertexID];
            foreach (int vid in appendMesh.VertexIndices())
            {
                if (mergeMapV.Contains(vid))
                {
                    mapV[vid] = mergeMapV[vid];
                }
                else
                {
                    NewVertexInfo vinfo  = appendMesh.GetVertexAll(vid);
                    int           newvid = Mesh.AppendVertex(vinfo);
                    mapV[vid] = newvid;
                }
            }

            foreach (int tid in appendMesh.TriangleIndices())
            {
                Index3i t = appendMesh.GetTriangle(tid);
                t.a = mapV[t.a];
                t.b = mapV[t.b];
                t.c = mapV[t.c];
                int gid = appendMesh.GetTriangleGroup(tid);
                if (appendGID >= 0)
                {
                    gid = appendGID;
                }
                Mesh.AppendTriangle(t, gid);
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Make a copy of provided triangles, with new vertices. You provide MapV because
        /// you know if you are doing a small subset or a full-mesh-copy.
        /// </summary>
        public List <int> DuplicateTriangles(IEnumerable <int> triangles, ref IndexMap MapV, int group_id = -1)
        {
            List <int> new_triangles = new List <int>();

            foreach (int tid in triangles)
            {
                Index3i tri = Mesh.GetTriangle(tid);
                for (int j = 0; j < 3; ++j)
                {
                    int vid = tri[j];
                    if (MapV.Contains(vid) == false)
                    {
                        int new_vid = Mesh.AppendVertex(Mesh, vid);
                        MapV[vid] = new_vid;
                        tri[j]    = new_vid;
                    }
                    else
                    {
                        tri[j] = MapV[vid];
                    }
                }
                int new_tid = Mesh.AppendTriangle(tri, group_id);
                new_triangles.Add(new_tid);
            }
            return(new_triangles);
        }