Ejemplo n.º 1
0
        public TezHexMesh createBorderMesh(List <Vector3> centerList, float borderScale = 0.8f)
        {
            TezHexMesh mesh = new TezHexMesh();

            mesh.vertices.Capacity = centerList.Count * 12;
            mesh.indices.Capacity  = centerList.Count * BorderTriangleIndices.Length;

            for (int center_index = 0; center_index < centerList.Count; center_index++)
            {
                var center = centerList[center_index];
                for (int i = 0; i < 6; i++)
                {
                    mesh.vertices.Add(this.createCorner(i, Vector3.zero) + center);
                }

                for (int i = 0; i < 6; i++)
                {
                    ///将所有点移动到0点进行计算
                    ///可以方便进行Vector3的Scale运算
                    ///然后再把计算好的点移动到指定的center上
                    ///否则很难在指定的center上进行Vector3的Scale计算
                    mesh.vertices.Add(this.createCorner(i, Vector3.zero, borderScale) + center);
                }

                var offset = 12 * center_index;
                for (int i = 0; i < BorderTriangleIndices.Length; i++)
                {
                    mesh.indices.Add(BorderTriangleIndices[i] + offset);
                }
            }

            return(mesh);
        }
Ejemplo n.º 2
0
        public TezHexMesh createMesh(List <Vector3> centerList)
        {
            TezHexMesh mesh = new TezHexMesh();

            mesh.vertices.Capacity = 7 * centerList.Count;
            mesh.indices.Capacity  = centerList.Count * HexTriangleIndices.Length;

            for (int i = 0; i < centerList.Count; i++)
            {
                var center = centerList[i];
                mesh.vertices.Add(center);
                mesh.vertices.Add(this.createCorner(0, center));
                mesh.vertices.Add(this.createCorner(1, center));
                mesh.vertices.Add(this.createCorner(2, center));
                mesh.vertices.Add(this.createCorner(3, center));
                mesh.vertices.Add(this.createCorner(4, center));
                mesh.vertices.Add(this.createCorner(5, center));

                var offset = 7 * i;
                for (int j = 0; j < HexTriangleIndices.Length; j++)
                {
                    mesh.indices.Add(HexTriangleIndices[j] + offset);
                }
            }

            return(mesh);
        }
Ejemplo n.º 3
0
        public void combine(TezHexMesh data)
        {
            int rate = vertices.Count > 0 ? vertices.Count / 4 : 0;

            for (int i = 0; i < data.vertices.Count; i++)
            {
                vertices.Add(data.vertices[i]);
            }

            int add = rate * data.vertices.Count;

            for (int i = 0; i < data.indices.Count; i++)
            {
                indices.Add(data.indices[i] + add);
            }

            for (int i = 0; i < data.uv.Count; i++)
            {
                uv.Add(data.uv[i]);
            }
        }
Ejemplo n.º 4
0
        public TezHexMesh createMesh(Vector3 center)
        {
            TezHexMesh mesh = new TezHexMesh();

            mesh.vertices.Capacity = 7;
            mesh.indices.Capacity  = HexTriangleIndices.Length;

            mesh.vertices.Add(center);
            mesh.vertices.Add(this.createCorner(0, center));
            mesh.vertices.Add(this.createCorner(1, center));
            mesh.vertices.Add(this.createCorner(2, center));
            mesh.vertices.Add(this.createCorner(3, center));
            mesh.vertices.Add(this.createCorner(4, center));
            mesh.vertices.Add(this.createCorner(5, center));

            for (int i = 0; i < HexTriangleIndices.Length; i++)
            {
                mesh.indices.Add(HexTriangleIndices[i]);
            }

            return(mesh);
        }
Ejemplo n.º 5
0
        public TezHexMesh createBorderMesh(Vector3 center, float borderScale = 0.8f)
        {
            TezHexMesh mesh = new TezHexMesh();

            mesh.vertices.Capacity = 12;
            mesh.indices.Capacity  = BorderTriangleIndices.Length;

            for (int i = 0; i < 6; i++)
            {
                mesh.vertices.Add(this.createCorner(i, center));
            }

            for (int i = 0; i < 6; i++)
            {
                mesh.vertices.Add(this.createCorner(i, center, borderScale));
            }

            for (int i = 0; i < BorderTriangleIndices.Length; i++)
            {
                mesh.indices.Add(BorderTriangleIndices[i]);
            }

            return(mesh);
        }