Пример #1
0
        public static TS_Mesh Copy(TS_Mesh input)
        {
            TS_Mesh result = new TS_Mesh();

            result.vertices = new Vector3[input.vertices.Length];
            input.vertices.CopyTo(result.vertices, 0);
            result.normals = new Vector3[input.normals.Length];
            input.normals.CopyTo(result.normals, 0);
            result.uv = new Vector2[input.uv.Length];
            input.uv.CopyTo(result.uv, 0);
            result.colors = new Color[input.colors.Length];
            input.colors.CopyTo(result.colors, 0);
            result.tangents = new Vector4[input.tangents.Length];
            input.tangents.CopyTo(result.tangents, 0);
            result.triangles = new int[input.triangles.Length];
            input.triangles.CopyTo(result.triangles, 0);
            result.subMeshes = new List <int[]>();
            for (int i = 0; i < input.subMeshes.Count; i++)
            {
                result.subMeshes.Add(new int[input.subMeshes[i].Length]);
                input.subMeshes[i].CopyTo(result.subMeshes[i], 0);
            }
            result.bounds = new TS_Bounds(input.bounds.center, input.bounds.size);
            return(result);
        }
Пример #2
0
        public static void MakeDoublesidedHalf(TS_Mesh input)
        {
            int vertexHalf = input.vertices.Length / 2;
            int trisHalf   = input.triangles.Length / 2;

            for (int i = 0; i < vertexHalf; i++)
            {
                input.vertices[i + vertexHalf] = input.vertices[i];
                input.normals[i + vertexHalf]  = -input.normals[i];
                input.uv[i + vertexHalf]       = input.uv[i];
                input.colors[i + vertexHalf]   = input.colors[i];
            }

            for (int i = 0; i < trisHalf; i += 3)
            {
                input.triangles[i + trisHalf + 2] = input.triangles[i] + vertexHalf;
                input.triangles[i + trisHalf + 1] = input.triangles[i + 1] + vertexHalf;
                input.triangles[i + trisHalf]     = input.triangles[i + 2] + vertexHalf;
            }

            for (int i = 0; i < input.subMeshes.Count; i++)
            {
                trisHalf = input.subMeshes[i].Length / 2;
                for (int n = 0; n < input.subMeshes[i].Length; n += 3)
                {
                    input.subMeshes[i][n + trisHalf + 2] = input.subMeshes[i][n] + vertexHalf;
                    input.subMeshes[i][n + trisHalf + 1] = input.subMeshes[i][n + 1] + vertexHalf;
                    input.subMeshes[i][n + trisHalf]     = input.subMeshes[i][n + 2] + vertexHalf;
                }
            }
        }
Пример #3
0
        public void Combine(TS_Mesh newMesh)
        {
            Vector3[] newVertices  = new Vector3[vertices.Length + newMesh.vertices.Length];
            Vector3[] newNormals   = new Vector3[normals.Length + newMesh.normals.Length];
            Vector2[] newUvs       = new Vector2[uv.Length + newMesh.uv.Length];
            Color[]   newColors    = new Color[colors.Length + newMesh.colors.Length];
            Vector4[] newTangents  = new Vector4[tangents.Length + newMesh.tangents.Length];
            int[]     newTriangles = new int[triangles.Length + newMesh.triangles.Length];

            vertices.CopyTo(newVertices, 0);
            newMesh.vertices.CopyTo(newVertices, vertices.Length);

            normals.CopyTo(newNormals, 0);
            newMesh.normals.CopyTo(newNormals, normals.Length);

            uv.CopyTo(newUvs, 0);
            newMesh.uv.CopyTo(newUvs, uv.Length);

            colors.CopyTo(newColors, 0);
            newMesh.colors.CopyTo(newColors, colors.Length);

            tangents.CopyTo(newTangents, 0);
            newMesh.tangents.CopyTo(newTangents, tangents.Length);

            for (int i = 0; i < newTriangles.Length; i++)
            {
                if (i < triangles.Length)
                {
                    newTriangles[i] = triangles[i];
                }
                else
                {
                    newTriangles[i] = (newMesh.triangles[i - triangles.Length] + vertices.Length);
                }
            }

            for (int i = 0; i < newMesh.subMeshes.Count; i++)
            {
                if (i >= subMeshes.Count)
                {
                    subMeshes.Add(newMesh.subMeshes[i]);
                }
                else
                {
                    int[] newTris = new int[subMeshes[i].Length + newMesh.subMeshes[i].Length];
                    subMeshes[i].CopyTo(newTris, 0);
                    for (int n = 0; n < newMesh.subMeshes[i].Length; n++)
                    {
                        newTris[subMeshes[i].Length + n] = newMesh.subMeshes[i][n] + vertices.Length;
                    }
                    subMeshes[i] = newTris;
                }
            }
            vertices  = newVertices;
            normals   = newNormals;
            uv        = newUvs;
            colors    = newColors;
            tangents  = newTangents;
            triangles = newTriangles;
        }
Пример #4
0
        public static void CalculateTangents(TS_Mesh mesh)
        {
            int triangleCount = mesh.triangles.Length / 3;

            if (meshTangents.Length != mesh.vertexCount)
            {
                meshTangents = new Vector4[mesh.vertexCount];
                tan1         = new Vector3[mesh.vertexCount];
                tan2         = new Vector3[mesh.vertexCount];
            }

            int tri = 0;

            for (int i = 0; i < triangleCount; i++)
            {
                int i1 = mesh.triangles[tri];
                int i2 = mesh.triangles[tri + 1];
                int i3 = mesh.triangles[tri + 2];

                float x1 = mesh.vertices[i2].x - mesh.vertices[i1].x;
                float x2 = mesh.vertices[i3].x - mesh.vertices[i1].x;
                float y1 = mesh.vertices[i2].y - mesh.vertices[i1].y;
                float y2 = mesh.vertices[i3].y - mesh.vertices[i1].y;
                float z1 = mesh.vertices[i2].z - mesh.vertices[i1].z;
                float z2 = mesh.vertices[i3].z - mesh.vertices[i1].z;

                float s1 = mesh.uv[i2].x - mesh.uv[i1].x;
                float s2 = mesh.uv[i3].x - mesh.uv[i1].x;
                float t1 = mesh.uv[i2].y - mesh.uv[i1].y;
                float t2 = mesh.uv[i3].y - mesh.uv[i1].y;

                float div = s1 * t2 - s2 * t1;
                float r   = div == 0f ? 0f : 1f / div;

                Vector3 sdir = new Vector3((t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, (t2 * z1 - t1 * z2) * r);
                Vector3 tdir = new Vector3((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * z2 - s2 * z1) * r);

                tan1[i1] += sdir;
                tan1[i2] += sdir;
                tan1[i3] += sdir;

                tan2[i1] += tdir;
                tan2[i2] += tdir;
                tan2[i3] += tdir;

                tri += 3;
            }

            for (int i = 0; i < mesh.vertexCount; i++)
            {
                Vector3 n = mesh.normals[i];
                Vector3 t = tan1[i];
                Vector3.OrthoNormalize(ref n, ref t);
                meshTangents[i].x = t.x;
                meshTangents[i].y = t.y;
                meshTangents[i].z = t.z;
                meshTangents[i].w = (Vector3.Dot(Vector3.Cross(n, t), tan2[i]) < 0.0f) ? -1.0f : 1.0f;
            }
            mesh.tangents = meshTangents;
        }
Пример #5
0
        public static void MakeDoublesidedHalf(TS_Mesh input)
        {
            int num  = input.vertices.Length / 2;
            int num2 = input.triangles.Length / 2;

            for (int i = 0; i < num; i++)
            {
                input.vertices[i + num] = input.vertices[i];
                input.normals[i + num]  = -input.normals[i];
                input.uv[i + num]       = input.uv[i];
                input.colors[i + num]   = input.colors[i];
            }
            for (int j = 0; j < num2; j += 3)
            {
                input.triangles[j + num2 + 2] = input.triangles[j] + num;
                input.triangles[j + num2 + 1] = input.triangles[j + 1] + num;
                input.triangles[j + num2]     = input.triangles[j + 2] + num;
            }
            for (int k = 0; k < input.subMeshes.Count; k++)
            {
                num2 = input.subMeshes[k].Length / 2;
                for (int l = 0; l < input.subMeshes[k].Length; l += 3)
                {
                    input.subMeshes[k][l + num2 + 2] = input.subMeshes[k][l] + num;
                    input.subMeshes[k][l + num2 + 1] = input.subMeshes[k][l + 1] + num;
                    input.subMeshes[k][l + num2]     = input.subMeshes[k][l + 2] + num;
                }
            }
        }
Пример #6
0
        public static TS_Mesh Copy(TS_Mesh input)
        {
            TS_Mesh tS_Mesh = new TS_Mesh();

            tS_Mesh.vertices = new Vector3[input.vertices.Length];
            input.vertices.CopyTo(tS_Mesh.vertices, 0);
            tS_Mesh.normals = new Vector3[input.normals.Length];
            input.normals.CopyTo(tS_Mesh.normals, 0);
            tS_Mesh.uv = new Vector2[input.uv.Length];
            input.uv.CopyTo(tS_Mesh.uv, 0);
            tS_Mesh.uv2 = new Vector2[input.uv2.Length];
            input.uv2.CopyTo(tS_Mesh.uv2, 0);
            tS_Mesh.uv3 = new Vector2[input.uv3.Length];
            input.uv3.CopyTo(tS_Mesh.uv3, 0);
            tS_Mesh.uv4 = new Vector2[input.uv4.Length];
            input.uv4.CopyTo(tS_Mesh.uv4, 0);
            tS_Mesh.colors = new Color[input.colors.Length];
            input.colors.CopyTo(tS_Mesh.colors, 0);
            tS_Mesh.tangents = new Vector4[input.tangents.Length];
            input.tangents.CopyTo(tS_Mesh.tangents, 0);
            tS_Mesh.triangles = new int[input.triangles.Length];
            input.triangles.CopyTo(tS_Mesh.triangles, 0);
            tS_Mesh.subMeshes = new List <int[]>();
            for (int i = 0; i < input.subMeshes.Count; i++)
            {
                tS_Mesh.subMeshes.Add(new int[input.subMeshes[i].Length]);
                input.subMeshes[i].CopyTo(tS_Mesh.subMeshes[i], 0);
            }
            tS_Mesh.bounds = new TS_Bounds(input.bounds.center, input.bounds.size);
            return(tS_Mesh);
        }
Пример #7
0
        public void Absorb(TS_Mesh input)
        {
            if (vertices.Length != input.vertexCount)
            {
                vertices = new Vector3[input.vertexCount];
            }
            if (normals.Length != input.normals.Length)
            {
                normals = new Vector3[input.normals.Length];
            }
            if (colors.Length != input.colors.Length)
            {
                colors = new Color[input.colors.Length];
            }
            if (uv.Length != input.uv.Length)
            {
                uv = new Vector2[input.uv.Length];
            }
            if (tangents.Length != input.tangents.Length)
            {
                tangents = new Vector4[input.tangents.Length];
            }
            if (triangles.Length != input.triangles.Length)
            {
                triangles = new int[input.triangles.Length];
            }

            input.vertices.CopyTo(vertices, 0);
            input.normals.CopyTo(normals, 0);
            input.colors.CopyTo(colors, 0);
            input.uv.CopyTo(uv, 0);
            input.tangents.CopyTo(tangents, 0);
            input.triangles.CopyTo(triangles, 0);

            if (subMeshes.Count == input.subMeshes.Count)
            {
                for (int i = 0; i < subMeshes.Count; i++)
                {
                    if (input.subMeshes[i].Length != subMeshes[i].Length)
                    {
                        subMeshes[i] = new int[input.subMeshes[i].Length];
                    }
                    input.subMeshes[i].CopyTo(subMeshes[i], 0);
                }
            }
            else
            {
                subMeshes = new List <int[]>();
                for (int i = 0; i < input.subMeshes.Count; i++)
                {
                    subMeshes.Add(new int[input.subMeshes[i].Length]);
                    input.subMeshes[i].CopyTo(subMeshes[i], 0);
                }
            }
            bounds = new TS_Bounds(input.bounds.center, input.bounds.size);
        }
Пример #8
0
 public static void TransformMesh(TS_Mesh input, Transform transform)
 {
     if (input.vertices != null && input.normals != null)
     {
         for (int i = 0; i < input.vertices.Length; i++)
         {
             input.vertices[i] = transform.TransformPoint(input.vertices[i]);
             input.normals[i]  = transform.TransformDirection(input.normals[i]);
         }
     }
 }
Пример #9
0
 public static void InverseTransformMesh(TS_Mesh input, Transform transform)
 {
     if (input.vertices == null || input.normals == null)
     {
         return;
     }
     for (int i = 0; i < input.vertices.Length; i++)
     {
         input.vertices[i] = transform.InverseTransformPoint(input.vertices[i]);
         input.normals[i]  = transform.InverseTransformDirection(input.normals[i]);
     }
 }
Пример #10
0
 public static void FlipFaces(TS_Mesh input)
 {
     for (int i = 0; i < input.subMeshes.Count; i++)
     {
         int[] array = input.subMeshes[i];
         FlipTriangles(ref array);
     }
     FlipTriangles(ref input.triangles);
     for (int i = 0; i < input.normals.Length; i++)
     {
         input.normals[i] *= -1f;
     }
 }
Пример #11
0
        public static void CalculateTangents(TS_Mesh mesh)
        {
            int num = mesh.triangles.Length / 3;

            if (meshTangents.Length != mesh.vertexCount)
            {
                meshTangents = new Vector4[mesh.vertexCount];
                tan1         = new Vector3[mesh.vertexCount];
                tan2         = new Vector3[mesh.vertexCount];
            }
            int num2 = 0;

            for (int i = 0; i < num; i++)
            {
                int     num3    = mesh.triangles[num2];
                int     num4    = mesh.triangles[num2 + 1];
                int     num5    = mesh.triangles[num2 + 2];
                float   num6    = mesh.vertices[num4].x - mesh.vertices[num3].x;
                float   num7    = mesh.vertices[num5].x - mesh.vertices[num3].x;
                float   num8    = mesh.vertices[num4].y - mesh.vertices[num3].y;
                float   num9    = mesh.vertices[num5].y - mesh.vertices[num3].y;
                float   num10   = mesh.vertices[num4].z - mesh.vertices[num3].z;
                float   num11   = mesh.vertices[num5].z - mesh.vertices[num3].z;
                float   num12   = mesh.uv[num4].x - mesh.uv[num3].x;
                float   num13   = mesh.uv[num5].x - mesh.uv[num3].x;
                float   num14   = mesh.uv[num4].y - mesh.uv[num3].y;
                float   num15   = mesh.uv[num5].y - mesh.uv[num3].y;
                float   num16   = num12 * num15 - num13 * num14;
                float   num17   = (num16 != 0f) ? (1f / num16) : 0f;
                Vector3 vector  = new Vector3((num15 * num6 - num14 * num7) * num17, (num15 * num8 - num14 * num9) * num17, (num15 * num10 - num14 * num11) * num17);
                Vector3 vector2 = new Vector3((num12 * num7 - num13 * num6) * num17, (num12 * num9 - num13 * num8) * num17, (num12 * num11 - num13 * num10) * num17);
                tan1[num3] += vector;
                tan1[num4] += vector;
                tan1[num5] += vector;
                tan2[num3] += vector2;
                tan2[num4] += vector2;
                tan2[num5] += vector2;
                num2       += 3;
            }
            for (int j = 0; j < mesh.vertexCount; j++)
            {
                Vector3 normal  = mesh.normals[j];
                Vector3 tangent = tan1[j];
                Vector3.OrthoNormalize(ref normal, ref tangent);
                meshTangents[j].x = tangent.x;
                meshTangents[j].y = tangent.y;
                meshTangents[j].z = tangent.z;
                meshTangents[j].w = ((!(Vector3.Dot(Vector3.Cross(normal, tangent), tan2[j]) < 0f)) ? 1f : (-1f));
            }
            mesh.tangents = meshTangents;
        }
Пример #12
0
        public static void MakeDoublesided(TS_Mesh input)
        {
            Vector3[] vertices  = input.vertices;
            Vector3[] normals   = input.normals;
            Vector2[] uvs       = input.uv;
            Color[]   colors    = input.colors;
            int[]     triangles = input.triangles;

            Vector3[] newVertices = new Vector3[vertices.Length * 2];
            Vector3[] newNormals  = new Vector3[normals.Length * 2];
            Vector2[] newUvs      = new Vector2[uvs.Length * 2];
            Color[]   newColors   = new Color[colors.Length * 2];
            int[]     newTris     = new int[triangles.Length * 2];

            for (int i = 0; i < vertices.Length; i++)
            {
                newVertices[i] = vertices[i];
                newNormals[i]  = normals[i];
                newUvs[i]      = uvs[i];
                newColors[i]   = colors[i];

                newVertices[i + vertices.Length] = vertices[i];
                newNormals[i + vertices.Length]  = -normals[i];
                newUvs[i + vertices.Length]      = uvs[i];
                newColors[i + vertices.Length]   = colors[i];
            }

            for (int i = 0; i < triangles.Length; i += 3)
            {
                int index1 = triangles[i];
                int index2 = triangles[i + 1];
                int index3 = triangles[i + 2];
                newTris[i]     = index1;
                newTris[i + 1] = index2;
                newTris[i + 2] = index3;

                newTris[i + triangles.Length]     = index3 + vertices.Length;
                newTris[i + triangles.Length + 1] = index2 + vertices.Length;
                newTris[i + triangles.Length + 2] = index1 + vertices.Length;
            }

            input.vertices  = newVertices;
            input.normals   = newNormals;
            input.uv        = newUvs;
            input.colors    = newColors;
            input.triangles = newTris;
        }
Пример #13
0
        public static void MakeDoublesided(TS_Mesh input)
        {
            Vector3[]    vertices  = input.vertices;
            Vector3[]    normals   = input.normals;
            Vector2[]    uvs       = input.uv;
            Color[]      colors    = input.colors;
            int[]        triangles = input.triangles;
            List <int[]> submeshes = input.subMeshes;

            Vector3[]    newVertices  = new Vector3[vertices.Length * 2];
            Vector3[]    newNormals   = new Vector3[normals.Length * 2];
            Vector2[]    newUvs       = new Vector2[uvs.Length * 2];
            Color[]      newColors    = new Color[colors.Length * 2];
            int[]        newTris      = new int[triangles.Length * 2];
            List <int[]> newSubmeshes = new List <int[]>();

            for (int i = 0; i < submeshes.Count; i++)
            {
                newSubmeshes.Add(new int[submeshes[i].Length * 2]);
                submeshes[i].CopyTo(newSubmeshes[i], 0);
            }

            for (int i = 0; i < vertices.Length; i++)
            {
                newVertices[i] = vertices[i];
                newNormals[i]  = normals[i];
                newUvs[i]      = uvs[i];
                if (colors.Length > i)
                {
                    newColors[i] = colors[i];
                }

                newVertices[i + vertices.Length] = vertices[i];
                newNormals[i + vertices.Length]  = -normals[i];
                newUvs[i + vertices.Length]      = uvs[i];
                if (colors.Length > i)
                {
                    newColors[i + vertices.Length] = colors[i];
                }
            }

            for (int i = 0; i < triangles.Length; i += 3)
            {
                int index1 = triangles[i];
                int index2 = triangles[i + 1];
                int index3 = triangles[i + 2];
                newTris[i]     = index1;
                newTris[i + 1] = index2;
                newTris[i + 2] = index3;

                newTris[i + triangles.Length]     = index3 + vertices.Length;
                newTris[i + triangles.Length + 1] = index2 + vertices.Length;
                newTris[i + triangles.Length + 2] = index1 + vertices.Length;
            }

            for (int i = 0; i < submeshes.Count; i++)
            {
                for (int n = 0; n < submeshes[i].Length; n += 3)
                {
                    int index1 = submeshes[i][n];
                    int index2 = submeshes[i][n + 1];
                    int index3 = submeshes[i][n + 2];
                    newSubmeshes[i][n]     = index1;
                    newSubmeshes[i][n + 1] = index2;
                    newSubmeshes[i][n + 2] = index3;

                    newSubmeshes[i][n + submeshes[i].Length]     = index3 + vertices.Length;
                    newSubmeshes[i][n + submeshes[i].Length + 1] = index2 + vertices.Length;
                    newSubmeshes[i][n + submeshes[i].Length + 2] = index1 + vertices.Length;
                }
            }

            input.vertices  = newVertices;
            input.normals   = newNormals;
            input.uv        = newUvs;
            input.colors    = newColors;
            input.triangles = newTris;
            input.subMeshes = newSubmeshes;
        }
Пример #14
0
 public void Combine(TS_Mesh newMesh)
 {
     Vector3[] array  = new Vector3[vertices.Length + newMesh.vertices.Length];
     Vector3[] array2 = new Vector3[normals.Length + newMesh.normals.Length];
     Vector2[] array3 = new Vector2[uv.Length + newMesh.uv.Length];
     Vector2[] array4 = new Vector2[uv.Length + newMesh.uv2.Length];
     Vector2[] array5 = new Vector2[uv.Length + newMesh.uv3.Length];
     Vector2[] array6 = new Vector2[uv.Length + newMesh.uv4.Length];
     Color[]   array7 = new Color[colors.Length + newMesh.colors.Length];
     Vector4[] array8 = new Vector4[tangents.Length + newMesh.tangents.Length];
     int[]     array9 = new int[triangles.Length + newMesh.triangles.Length];
     vertices.CopyTo(array, 0);
     newMesh.vertices.CopyTo(array, vertices.Length);
     normals.CopyTo(array2, 0);
     newMesh.normals.CopyTo(array2, normals.Length);
     uv.CopyTo(array3, 0);
     newMesh.uv.CopyTo(array3, uv.Length);
     uv2.CopyTo(array4, 0);
     newMesh.uv2.CopyTo(array4, uv2.Length);
     uv3.CopyTo(array5, 0);
     newMesh.uv3.CopyTo(array5, uv3.Length);
     uv4.CopyTo(array6, 0);
     newMesh.uv4.CopyTo(array6, uv4.Length);
     colors.CopyTo(array7, 0);
     newMesh.colors.CopyTo(array7, colors.Length);
     tangents.CopyTo(array8, 0);
     newMesh.tangents.CopyTo(array8, tangents.Length);
     for (int i = 0; i < array9.Length; i++)
     {
         if (i < triangles.Length)
         {
             array9[i] = triangles[i];
         }
         else
         {
             array9[i] = newMesh.triangles[i - triangles.Length] + vertices.Length;
         }
     }
     for (int j = 0; j < newMesh.subMeshes.Count; j++)
     {
         if (j >= subMeshes.Count)
         {
             subMeshes.Add(newMesh.subMeshes[j]);
             continue;
         }
         int[] array10 = new int[subMeshes[j].Length + newMesh.subMeshes[j].Length];
         subMeshes[j].CopyTo(array10, 0);
         for (int k = 0; k < newMesh.subMeshes[j].Length; k++)
         {
             array10[subMeshes[j].Length + k] = newMesh.subMeshes[j][k] + vertices.Length;
         }
         subMeshes[j] = array10;
     }
     vertices  = array;
     normals   = array2;
     uv        = array3;
     uv2       = array4;
     uv3       = array5;
     uv4       = array6;
     colors    = array7;
     tangents  = array8;
     triangles = array9;
 }
Пример #15
0
        public static void MakeDoublesided(TS_Mesh input)
        {
            Vector3[]    vertices  = input.vertices;
            Vector3[]    normals   = input.normals;
            Vector2[]    uv        = input.uv;
            Color[]      colors    = input.colors;
            int[]        triangles = input.triangles;
            List <int[]> subMeshes = input.subMeshes;

            Vector3[]    array  = new Vector3[vertices.Length * 2];
            Vector3[]    array2 = new Vector3[normals.Length * 2];
            Vector2[]    array3 = new Vector2[uv.Length * 2];
            Color[]      array4 = new Color[colors.Length * 2];
            int[]        array5 = new int[triangles.Length * 2];
            List <int[]> list   = new List <int[]>();

            for (int i = 0; i < subMeshes.Count; i++)
            {
                list.Add(new int[subMeshes[i].Length * 2]);
                subMeshes[i].CopyTo(list[i], 0);
            }
            for (int j = 0; j < vertices.Length; j++)
            {
                array[j]  = vertices[j];
                array2[j] = normals[j];
                array3[j] = uv[j];
                array4[j] = colors[j];
                array[j + vertices.Length]  = vertices[j];
                array2[j + vertices.Length] = -normals[j];
                array3[j + vertices.Length] = uv[j];
                array4[j + vertices.Length] = colors[j];
            }
            for (int k = 0; k < triangles.Length; k += 3)
            {
                int num  = triangles[k];
                int num2 = triangles[k + 1];
                int num3 = triangles[k + 2];
                array5[k]     = num;
                array5[k + 1] = num2;
                array5[k + 2] = num3;
                array5[k + triangles.Length]     = num3 + vertices.Length;
                array5[k + triangles.Length + 1] = num2 + vertices.Length;
                array5[k + triangles.Length + 2] = num + vertices.Length;
            }
            for (int l = 0; l < subMeshes.Count; l++)
            {
                for (int m = 0; m < subMeshes[l].Length; m += 3)
                {
                    int num4 = subMeshes[l][m];
                    int num5 = subMeshes[l][m + 1];
                    int num6 = subMeshes[l][m + 2];
                    list[l][m]     = num4;
                    list[l][m + 1] = num5;
                    list[l][m + 2] = num6;
                    list[l][m + subMeshes[l].Length]     = num6 + vertices.Length;
                    list[l][m + subMeshes[l].Length + 1] = num5 + vertices.Length;
                    list[l][m + subMeshes[l].Length + 2] = num4 + vertices.Length;
                }
            }
            input.vertices  = array;
            input.normals   = array2;
            input.uv        = array3;
            input.colors    = array4;
            input.triangles = array5;
            input.subMeshes = list;
        }