示例#1
0
        public override void CreateMesh()
        {
            Debug.Log("Creating Quad");

            // initial hardcoded sizes for a quad
            Vector3[] verts = new Vector3[4];
            Vector2[] uvs   = new Vector2[4];
            int[]     tris  = new int[6];

            // set vert positions
            //	1		2
            //
            //	0		3
            verts[0] = new Vector3(0, 0, 0);
            verts[1] = new Vector3(0, 1, 0);
            verts[2] = new Vector3(1, 1, 0);
            verts[3] = new Vector3(1, 0, 0);

            // set uv positions
            //	1		2
            //
            //	0		3
            uvs[0] = new Vector2(0, 0);
            uvs[1] = new Vector2(0, 1);
            uvs[2] = new Vector2(1, 1);
            uvs[3] = new Vector2(1, 0);

            // set triangle array
            tris[0] = 0;
            tris[1] = 1;
            tris[2] = 2;
            tris[3] = 0;
            tris[4] = 2;
            tris[5] = 3;

            // assing data to the mesh
            meshFilter.sharedMesh           = new Mesh();
            meshFilter.sharedMesh.vertices  = verts;
            meshFilter.sharedMesh.uv        = uvs;
            meshFilter.sharedMesh.triangles = tris;
            meshFilter.sharedMesh.RecalculateNormals();
            meshFilter.sharedMesh.RecalculateBounds();
            meshFilter.sharedMesh.name = "LBM_Quad_" + transform.GetInstanceID();
#if UNITY_EDITOR
            SecondaryUV(meshFilter.sharedMesh);
            TangentSolver.Solve(meshFilter.sharedMesh);
#endif
            origUVs = meshFilter.sharedMesh.uv;
            GetComponent <MeshCollider>().sharedMesh = meshFilter.sharedMesh;
        }
示例#2
0
        public override void CreateMesh()
        {
            Debug.Log("Creating CornerFill");

            // initial hardcoded sizes for a wedge
            Vector3[] verts = new Vector3[12];
            Vector2[] uvs   = new Vector2[12];
            int[]     tris  = new int[12];

            // set vert positions per face
            //		1
            //
            //	0		2
            //
            // slope
            verts[0] = new Vector3(0, 0, 0);
            verts[1] = new Vector3(0, 1, 1);
            verts[2] = new Vector3(1, 0, 1);
            // back
            verts[3] = new Vector3(1, 0, 1);
            verts[4] = new Vector3(0, 1, 1);
            verts[5] = new Vector3(0, 0, 1);
            // right
            verts[6] = new Vector3(0, 0, 1);
            verts[7] = new Vector3(0, 1, 1);
            verts[8] = new Vector3(0, 0, 0);
            // bottom
            verts[9]  = new Vector3(0, 0, 1);
            verts[10] = new Vector3(0, 0, 0);
            verts[11] = new Vector3(1, 0, 1);

            // set uv positions per face
            //		1
            //
            //	0		2
            //
            // slope
            uvs[0] = new Vector2(0, 0);
            uvs[1] = new Vector2(0.5f, 1);
            uvs[2] = new Vector2(1, 0);
            //back
            uvs[3] = new Vector2(-1, 0);
            uvs[4] = new Vector2(0, 1);
            uvs[5] = new Vector2(0, 0);
            //right
            uvs[6] = new Vector2(0, 0);
            uvs[7] = new Vector2(0, 1);
            uvs[8] = new Vector2(1, 0);
            //bottom
            uvs[9]  = new Vector2(0, 0);
            uvs[10] = new Vector2(0, 1);
            uvs[11] = new Vector2(1, 0);


            // set triangle array per face
            int anchorIndex = 0;

            for (int i = 0; i < 12; i += 3)
            {
                tris[i]      = anchorIndex;
                tris[i + 1]  = anchorIndex + 1;
                tris[i + 2]  = anchorIndex + 2;
                anchorIndex += 3;
            }

            // assing data to the mesh
            Mesh m = new Mesh();

            m.vertices  = verts;
            m.uv        = uvs;
            m.triangles = tris;
            m.RecalculateNormals();
            m.RecalculateBounds();
            m.name = "LBM_Wedge";
#if UNITY_EDITOR
            UnityEditor.Unwrapping.GenerateSecondaryUVSet(m);
            TangentSolver.Solve(m);
#endif
            GetComponent <MeshFilter>().sharedMesh = m;
            origUVs = m.uv;
            ((MeshCollider)GetComponent <Collider>()).sharedMesh = meshFilter.sharedMesh;
        }
示例#3
0
        public override void UpdateMesh()
        {
            vertList.Clear();
            triList.Clear();

            Vector3 centrePos = Vector3.zero;
            float   angle     = 0f;

            for (int i = 0; i <= sections; i++)
            {
                //unit position along the edge of the bend circle:
                centrePos   = Vector3.zero;
                centrePos.x = Mathf.Cos(Mathf.Deg2Rad * angle) * radius;
                centrePos.z = Mathf.Sin(Mathf.Deg2Rad * angle) * radius;

                centrePos += offset;

                vertList.Add(new Vector3(centrePos.x, offset.y, centrePos.z));
                vertList.Add(new Vector3(centrePos.x, 1 + offset.y, centrePos.z));

                angle += (360.0f / sections);
            }

            int vertZero = vertList.Count - 2;
            int vertOne  = vertList.Count - 1;

            // set triangle array per face
            int indexUtil = sections * 2 - 2;

            for (int i = 0; i <= indexUtil; i += 2)
            {
                triList.Add(i);
                triList.Add(i + 1);
                triList.Add(i + 3);
                triList.Add(i);
                triList.Add(i + 3);
                triList.Add(i + 2);
            }

            // Caps
            // top cap
            for (int i = 1; i < sections * 2; i += 2)
            {
                vertList.Add(vertList[i]);
            }

            vertList.Add(new Vector3(offset.x, 1 + offset.y, offset.z));
            int capCenterVert = vertList.Count - 1;

            indexUtil = sections * 2 + 2;
            for (int i = indexUtil; i < indexUtil + sections; i++)
            {
                if (i < indexUtil + sections - 1)
                {
                    triList.Add(i);
                    triList.Add(capCenterVert);
                    triList.Add(i + 1);
                }
                else
                {
                    triList.Add(i);
                    triList.Add(capCenterVert);
                    triList.Add(indexUtil);
                }
            }

            // bottom cap
            for (int i = 0; i < sections * 2; i += 2)
            {
                vertList.Add(vertList[i]);
            }

            vertList.Add(new Vector3(offset.x, offset.y, offset.z));
            capCenterVert = vertList.Count - 1;

            indexUtil = sections * 2 + sections + 3;
            for (int i = indexUtil; i < indexUtil + sections; i++)
            {
                if (i < indexUtil + sections - 1)
                {
                    triList.Add(capCenterVert);
                    triList.Add(i);
                    triList.Add(i + 1);
                }
                else
                {
                    triList.Add(capCenterVert);
                    triList.Add(i);
                    triList.Add(indexUtil);
                }
            }

            // assing data to the mesh
            DestroyImmediate(meshFilter.sharedMesh);
            meshFilter.sharedMesh           = new Mesh();
            meshFilter.sharedMesh.name      = "LBM_Cylinder_" + transform.GetInstanceID();
            meshFilter.sharedMesh.vertices  = vertList.ToArray();
            meshFilter.sharedMesh.triangles = triList.ToArray();
            meshFilter.sharedMesh.uv        = UpdateUVs();

            meshFilter.sharedMesh.RecalculateNormals();
            Vector3[] normals = meshFilter.sharedMesh.normals;
            normals[0] = normals[vertZero] = (normals[0] + normals[vertZero]).normalized;
            normals[1] = normals[vertOne] = (normals[1] + normals[vertOne]).normalized;
            meshFilter.sharedMesh.normals = normals;
            meshFilter.sharedMesh.RecalculateBounds();
#if UNITY_EDITOR
            SecondaryUV(meshFilter.sharedMesh);
            TangentSolver.Solve(meshFilter.sharedMesh);
            lastScale   = transform.localScale;
            lastUVScale = UVScale;
            lastUVPos   = UVPos;
#endif
            GetComponent <MeshCollider>().sharedMesh = meshFilter.sharedMesh;
        }
        public override void CreateMesh()
        {
            Debug.Log("Creating WedgeCorner_In");

            // initial hardcoded sizes for a cube
            Vector3[] verts = new Vector3[24];
            Vector2[] uvs   = new Vector2[24];
            int[]     tris  = new int[30];

            // set vert positions per face
            //	1		2
            //
            //	0		3
            //
            // front
            verts[0] = new Vector3(0, 0, 0);
            verts[1] = new Vector3(0, 1, 0);
            verts[2] = new Vector3(1, 0, 0);
            // top 1
            verts[3] = new Vector3(1, 0, 0);
            verts[4] = new Vector3(0, 1, 0);
            verts[5] = new Vector3(0, 1, 1);
            // top 2
            verts[6] = new Vector3(1, 0, 0);
            verts[7] = new Vector3(0, 1, 1);
            verts[8] = new Vector3(1, 1, 1);
            // right
            verts[9]  = new Vector3(1, 0, 0);
            verts[10] = new Vector3(1, 1, 1);
            verts[11] = new Vector3(1, 0, 1);
            // back
            verts[12] = new Vector3(1, 0, 1);
            verts[13] = new Vector3(1, 1, 1);
            verts[14] = new Vector3(0, 1, 1);
            verts[15] = new Vector3(0, 0, 1);
            // left
            verts[16] = new Vector3(0, 0, 1);
            verts[17] = new Vector3(0, 1, 1);
            verts[18] = new Vector3(0, 1, 0);
            verts[19] = new Vector3(0, 0, 0);
            // bottom
            verts[20] = new Vector3(0, 0, 1);
            verts[21] = new Vector3(0, 0, 0);
            verts[22] = new Vector3(1, 0, 0);
            verts[23] = new Vector3(1, 0, 1);

            // set uv positions per face
            //	1		2
            //
            //	0		3
            // front
            uvs[0] = new Vector2(0, 0);
            uvs[1] = new Vector2(0, 1);
            uvs[2] = new Vector2(1, 0);

            // top 1
            uvs[3] = new Vector2(0.5f, 0);
            uvs[4] = new Vector2(0, 1);
            uvs[5] = new Vector2(0.5f, 1);
            // top 2
            uvs[6] = new Vector2(0.5f, 0);
            uvs[7] = new Vector2(0.5f, 1);
            uvs[8] = new Vector2(1, 1);

            // right
            uvs[9]  = new Vector2(0, 0);
            uvs[10] = new Vector2(1, 1);
            uvs[11] = new Vector2(1, 0);

            //back face
            uvs[12] = new Vector2(-1, 0);
            uvs[13] = new Vector2(-1, 1);
            uvs[14] = new Vector2(0, 1);
            uvs[15] = new Vector2(0, 0);

            //left face
            uvs[16] = new Vector2(-1, 0);
            uvs[17] = new Vector2(-1, 1);
            uvs[18] = new Vector2(0, 1);
            uvs[19] = new Vector2(0, 0);

            // bottom face
            uvs[20] = new Vector2(0, -1);
            uvs[21] = new Vector2(0, 0);
            uvs[22] = new Vector2(1, 0);
            uvs[23] = new Vector2(1, -1);

            // set triangle array per face
            int anchorIndex = 0;

            for (int i = 0; i < 12; i += 3)
            {
                tris[i]      = anchorIndex;
                tris[i + 1]  = anchorIndex + 1;
                tris[i + 2]  = anchorIndex + 2;
                anchorIndex += 3;
            }

            for (int i = 12; i < 30; i += 6)
            {
                tris[i]     = anchorIndex;
                tris[i + 1] = anchorIndex + 1;
                tris[i + 2] = anchorIndex + 2;
                tris[i + 3] = anchorIndex;
                tris[i + 4] = anchorIndex + 2;
                tris[i + 5] = anchorIndex + 3;

                anchorIndex += 4;
            }

            // assing data to the mesh
            meshFilter.sharedMesh           = new Mesh();
            meshFilter.sharedMesh.vertices  = verts;
            meshFilter.sharedMesh.uv        = uvs;
            meshFilter.sharedMesh.triangles = tris;
            meshFilter.sharedMesh.RecalculateNormals();
            meshFilter.sharedMesh.RecalculateBounds();
            meshFilter.sharedMesh.name = "LBM_WedgeCorner_In_" + transform.GetInstanceID();
#if UNITY_EDITOR
            SecondaryUV(meshFilter.sharedMesh);
            TangentSolver.Solve(meshFilter.sharedMesh);
#endif
            origUVs = meshFilter.sharedMesh.uv;
        }
        public override void CreateMesh()
        {
            Debug.Log("Creating Wedge");

            // initial hardcoded sizes for a wedge
            Vector3[] verts = new Vector3[18];
            Vector2[] uvs   = new Vector2[18];
            int[]     tris  = new int[24];

            // set vert positions per face
            //	1		2
            //
            //	0		3
            //
            // slope
            verts[0] = new Vector3(0, 0, 0);
            verts[1] = new Vector3(0, 1, 1);
            verts[2] = new Vector3(1, 1, 1);
            verts[3] = new Vector3(1, 0, 0);
            // back
            verts[4] = new Vector3(1, 0, 1);
            verts[5] = new Vector3(1, 1, 1);
            verts[6] = new Vector3(0, 1, 1);
            verts[7] = new Vector3(0, 0, 1);
            // bottom
            verts[8]  = new Vector3(0, 0, 1);
            verts[9]  = new Vector3(0, 0, 0);
            verts[10] = new Vector3(1, 0, 0);
            verts[11] = new Vector3(1, 0, 1);
            // left
            verts[12] = new Vector3(1, 0, 0);
            verts[13] = new Vector3(1, 1, 1);
            verts[14] = new Vector3(1, 0, 1);
            // right
            verts[15] = new Vector3(0, 0, 1);
            verts[16] = new Vector3(0, 1, 1);
            verts[17] = new Vector3(0, 0, 0);

            // set uv positions per face
            //	1		2
            //
            //	0		3
            //
            // first 12 form 3 quads
            for (int i = 0; i < 12; i += 4)
            {
                uvs[i]     = new Vector2(0, 0);
                uvs[i + 1] = new Vector2(0, 1);
                uvs[i + 2] = new Vector2(1, 1);
                uvs[i + 3] = new Vector2(1, 0);
            }
            // last 6 form 2 tris
            uvs[12] = new Vector2(-1, 0);
            uvs[13] = new Vector2(0, 1);
            uvs[14] = new Vector2(0, 0);
            uvs[15] = new Vector2(0, 0);
            uvs[16] = new Vector2(0, 1);
            uvs[17] = new Vector2(1, 0);


            // set triangle array per face
            // first 18 form 3 quads
            int anchorIndex = 0;

            for (int i = 0; i < 18; i += 6)
            {
                tris[i]     = anchorIndex;
                tris[i + 1] = anchorIndex + 1;
                tris[i + 2] = anchorIndex + 2;
                tris[i + 3] = anchorIndex;
                tris[i + 4] = anchorIndex + 2;
                tris[i + 5] = anchorIndex + 3;

                anchorIndex += 4;
            }
            // last 6 form 2 tris
            tris[18] = 12;
            tris[19] = 13;
            tris[20] = 14;
            tris[21] = 15;
            tris[22] = 16;
            tris[23] = 17;

            // assing data to the mesh
            meshFilter.sharedMesh           = new Mesh();
            meshFilter.sharedMesh.vertices  = verts;
            meshFilter.sharedMesh.uv        = uvs;
            meshFilter.sharedMesh.triangles = tris;
            meshFilter.sharedMesh.RecalculateNormals();
            meshFilter.sharedMesh.RecalculateBounds();
            meshFilter.sharedMesh.name = "LBM_Wedge_" + transform.GetInstanceID();
#if UNITY_EDITOR
            SecondaryUV(meshFilter.sharedMesh);
            TangentSolver.Solve(meshFilter.sharedMesh);
#endif
            origUVs = meshFilter.sharedMesh.uv;
            GetComponent <MeshCollider>().sharedMesh = meshFilter.sharedMesh;
        }
        public override void UpdateMesh()
        {
            squaringPos    = new Vector3[8];
            squaringPos[0] = new Vector3(-radius + offset.x, offset.y, offset.z);
            squaringPos[1] = new Vector3(-radius + offset.x, offset.y, radius + offset.z);
            squaringPos[2] = new Vector3(offset.x, offset.y, radius + offset.z);
            squaringPos[3] = new Vector3(radius + offset.x, offset.y, radius + offset.z);
            squaringPos[4] = new Vector3(radius + offset.x, offset.y, offset.z);
            squaringPos[5] = new Vector3(radius + offset.x, offset.y, -radius + offset.z);
            squaringPos[6] = new Vector3(offset.x, offset.y, -radius + offset.z);
            squaringPos[7] = new Vector3(-radius + offset.x, offset.y, -radius + offset.z);

            vertList.Clear();
            triList.Clear();

            //Debug.Log(sections);
            bool  startCap = false;
            float angle    = 0f;

            angle += startAngle;
            //float sectionSpacing = 1/sections;
            for (int i = 0; i <= sections; i++)
            {
                //unit position along the edge of the bend circle:
                Vector3 centrePos = Vector3.zero;
                centrePos.x = Mathf.Cos(Mathf.Deg2Rad * angle) * radius;
                centrePos.z = Mathf.Sin(Mathf.Deg2Rad * angle) * radius;

                Vector3 inner = -centrePos;
                inner.y = 0;
                inner.Normalize();

                centrePos += offset;

                if (squared)
                {
                    // test squaring ////////////////////////////////////////////////////
                    Vector3 testVec  = new Vector3(centrePos.x, offset.y, centrePos.z);
                    float   testDist = float.PositiveInfinity;
                    int     sqIndex  = 0;
                    for (int j = 0; j < squaringPos.Length; j++)
                    {
                        float thisDist = (testVec - squaringPos[j]).magnitude;
                        if (j == 1 || j == 3 || j == 5 || j == 7)
                        {
                            thisDist -= 0.5f * radius;
                        }

                        if (thisDist < testDist)
                        {
                            testDist = thisDist;
                            sqIndex  = j;
                        }
                    }

                    // start cap
                    if (!startCap)
                    {
                        vertList.Add(new Vector3((centrePos + (inner * width)).x, offset.y, (centrePos + (inner * width)).z));
                        vertList.Add(new Vector3((centrePos + (inner * width)).x, 1 + offset.y, (centrePos + (inner * width)).z));
                        vertList.Add(new Vector3(squaringPos[sqIndex].x, 1 + squaringPos[sqIndex].y, squaringPos[sqIndex].z));
                        vertList.Add(squaringPos[sqIndex]);

                        startCap = true;
                    }

                    vertList.Add(squaringPos[sqIndex]);
                    vertList.Add(new Vector3(squaringPos[sqIndex].x, 1 + squaringPos[sqIndex].y, squaringPos[sqIndex].z));

                    vertList.Add(new Vector3(squaringPos[sqIndex].x, 1 + squaringPos[sqIndex].y, squaringPos[sqIndex].z));
                    vertList.Add(new Vector3((centrePos + (inner * width)).x, 1 + offset.y, (centrePos + (inner * width)).z));

                    vertList.Add(new Vector3((centrePos + (inner * width)).x, 1 + offset.y, (centrePos + (inner * width)).z));
                    vertList.Add(new Vector3((centrePos + (inner * width)).x, offset.y, (centrePos + (inner * width)).z));

                    vertList.Add(new Vector3((centrePos + (inner * width)).x, offset.y, (centrePos + (inner * width)).z));
                    vertList.Add(squaringPos[sqIndex]);

                    // end cap
                    if (i == sections)
                    {
                        vertList.Add(squaringPos[sqIndex]);
                        vertList.Add(new Vector3(squaringPos[sqIndex].x, 1 + squaringPos[sqIndex].y, squaringPos[sqIndex].z));
                        vertList.Add(new Vector3((centrePos + (inner * width)).x, 1 + offset.y, (centrePos + (inner * width)).z));
                        vertList.Add(new Vector3((centrePos + (inner * width)).x, offset.y, (centrePos + (inner * width)).z));
                    }
                }
                else
                {
                    // start cap
                    if (!startCap)
                    {
                        vertList.Add(new Vector3((centrePos + (inner * width)).x, offset.y, (centrePos + (inner * width)).z));
                        vertList.Add(new Vector3((centrePos + (inner * width)).x, 1 + offset.y, (centrePos + (inner * width)).z));
                        vertList.Add(new Vector3(centrePos.x, 1 + offset.y, centrePos.z));
                        vertList.Add(new Vector3(centrePos.x, offset.y, centrePos.z));
                        startCap = true;
                    }

                    vertList.Add(new Vector3(centrePos.x, offset.y, centrePos.z));
                    vertList.Add(new Vector3(centrePos.x, 1 + offset.y, centrePos.z));

                    vertList.Add(new Vector3(centrePos.x, 1 + offset.y, centrePos.z));
                    vertList.Add(new Vector3((centrePos + (inner * width)).x, 1 + offset.y, (centrePos + (inner * width)).z));

                    vertList.Add(new Vector3((centrePos + (inner * width)).x, 1 + offset.y, (centrePos + (inner * width)).z));
                    vertList.Add(new Vector3((centrePos + (inner * width)).x, offset.y, (centrePos + (inner * width)).z));

                    vertList.Add(new Vector3((centrePos + (inner * width)).x, offset.y, (centrePos + (inner * width)).z));
                    vertList.Add(new Vector3(centrePos.x, offset.y, centrePos.z));

                    // end cap
                    if (i == sections)
                    {
                        vertList.Add(new Vector3(centrePos.x, offset.y, centrePos.z));
                        vertList.Add(new Vector3(centrePos.x, 1 + offset.y, centrePos.z));
                        vertList.Add(new Vector3((centrePos + (inner * width)).x, 1 + offset.y, (centrePos + (inner * width)).z));
                        vertList.Add(new Vector3((centrePos + (inner * width)).x, offset.y, (centrePos + (inner * width)).z));
                    }
                }

                angle += (bendAngle / sections);
            }

            // set triangle array per face
            int indexUtil = sections * 8;

            for (int i = 4; i < indexUtil + 4; i += 2)
            {
                triList.Add(i);
                triList.Add(i + 1);
                triList.Add(i + 9);
                triList.Add(i);
                triList.Add(i + 9);
                triList.Add(i + 8);
            }

            // Caps
            triList.Add(0);
            triList.Add(1);
            triList.Add(2);
            triList.Add(0);
            triList.Add(2);
            triList.Add(3);
            indexUtil += 12;
            triList.Add(indexUtil);
            triList.Add(indexUtil + 1);
            triList.Add(indexUtil + 2);
            triList.Add(indexUtil);
            triList.Add(indexUtil + 2);
            triList.Add(indexUtil + 3);

            // assing data to the mesh
            DestroyImmediate(meshFilter.sharedMesh);
            meshFilter.sharedMesh           = new Mesh();
            meshFilter.sharedMesh.name      = "LBM_Arch_" + transform.GetInstanceID();
            meshFilter.sharedMesh.vertices  = vertList.ToArray();
            meshFilter.sharedMesh.triangles = triList.ToArray();
            meshFilter.sharedMesh.uv        = UpdateUVs();
            meshFilter.sharedMesh.RecalculateNormals();
            meshFilter.sharedMesh.RecalculateBounds();
#if UNITY_EDITOR
            SecondaryUV(meshFilter.sharedMesh);
            TangentSolver.Solve(meshFilter.sharedMesh);
            lastScale   = transform.localScale;
            lastUVScale = UVScale;
            lastUVPos   = UVPos;
#endif
            GetComponent <MeshCollider>().sharedMesh = meshFilter.sharedMesh;
        }
示例#7
0
        public override void CreateMesh()
        {
            Debug.Log("Creating Slope");

            slopePos = Vector3.one;

            // initial hardcoded sizes for a cube
            verts = new Vector3[24];
            UpdateVerts();

            Vector2[] uvs = new Vector2[24];
            // set uv positions per face
            //	1		2
            //
            //	0		3
            for (int i = 0; i < 24; i += 4)
            {
                uvs[i]     = new Vector2(0, 0);
                uvs[i + 1] = new Vector2(0, 1);
                uvs[i + 2] = new Vector2(1, 1);
                uvs[i + 3] = new Vector2(1, 0);
            }

            //back face
            uvs[4] = new Vector2(-1, 0);
            uvs[5] = new Vector2(-1, 1);
            uvs[6] = new Vector2(0, 1);
            uvs[7] = new Vector2(0, 0);

            //left face
            uvs[8]  = new Vector2(-1, 0);
            uvs[9]  = new Vector2(-1, 1);
            uvs[10] = new Vector2(0, 1);
            uvs[11] = new Vector2(0, 0);

            // bottom face
            uvs[20] = new Vector2(0, -1);
            uvs[21] = new Vector2(0, 0);
            uvs[22] = new Vector2(1, 0);
            uvs[23] = new Vector2(1, -1);

            // set triangle array per face
            int[] tris        = new int[36];
            int   anchorIndex = 0;

            for (int i = 0; i < 36; i += 6)
            {
                tris[i]     = anchorIndex;
                tris[i + 1] = anchorIndex + 1;
                tris[i + 2] = anchorIndex + 2;
                tris[i + 3] = anchorIndex;
                tris[i + 4] = anchorIndex + 2;
                tris[i + 5] = anchorIndex + 3;

                anchorIndex += 4;
            }

            // assing data to the mesh
            meshFilter.sharedMesh           = new Mesh();
            meshFilter.sharedMesh.vertices  = verts;
            meshFilter.sharedMesh.uv        = uvs;
            meshFilter.sharedMesh.triangles = tris;
            meshFilter.sharedMesh.RecalculateNormals();
            meshFilter.sharedMesh.RecalculateBounds();
            meshFilter.sharedMesh.name = "LBM_Slope_" + transform.GetInstanceID();
#if UNITY_EDITOR
            SecondaryUV(meshFilter.sharedMesh);
            TangentSolver.Solve(meshFilter.sharedMesh);
#endif
            origUVs = meshFilter.sharedMesh.uv;
            GetComponent <MeshCollider>().sharedMesh = meshFilter.sharedMesh;
        }