Exemplo n.º 1
0
        /// <summary>
        /// Generates the front mesh vertices as well as the UV coordinates.
        /// Texture tiling is applied.
        /// </summary>
        private void GenerateFrontMeshDataWithTiling()
        {
            Vector3 vertPos = Vector3.zero;
            Vector2 UV      = Vector2.zero;

            prevSurfaceVertsCount = frontMeshVertsCount / 2;
            frontMeshVertsCount   = 0;
            float posX          = transform.position.x;
            float rightHandleX  = handlesPosition[3].x;
            float leftHandleX   = handlesPosition[2].x;
            float bottomHandleY = handlesPosition[1].y;

            for (int y = 0; y < yVerts; y++)
            {
                for (int x = 0; x < xVerts; x++)
                {
                    if (x == xVerts - 1)
                    {
                        vertPos = new Vector3(rightHandleX, bottomHandleY + y * height, 0.0f);
                    }
                    else
                    {
                        vertPos = new Vector3(x * xVertDistance + leftHandleX, bottomHandleY + y * height, 0.0f);
                    }

                    UV = GetFrontMeshUVWithTiling(vertPos, y, posX);
                    ParentDMesh.AddVertex(vertPos, UV, true);
                    frontMeshVertsCount++;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Generates the front mesh vertices as well as the UV coordinates.
        /// No texture tiling is applied.
        /// </summary>
        private void GenerateFrontMeshDataNoTiling()
        {
            Vector3 vertPos = Vector3.zero;
            Vector2 UV;

            prevSurfaceVertsCount = frontMeshVertsCount / 2;
            frontMeshVertsCount   = 0;
            float X, Y;

            for (int y = 0; y < yVerts; y++)
            {
                for (int x = 0; x < xVerts; x++)
                {
                    if (x < xVerts - 1)
                    {
                        X = x * xVertDistance + handlesPosition[2].x;
                    }
                    else
                    {
                        X = handlesPosition[2].x + renderTextureWidth * rtPixelSize;
                    }

                    Y         = handlesPosition[1].y + y * height;
                    vertPos.x = X;
                    vertPos.y = Y;
                    GetFrontMeshUVNoTiling(x, y, out UV);

                    ParentDMesh.AddVertex(vertPos, UV, true);

                    frontMeshVertsCount++;
                }
            }

            if (water2DRippleScript)
            {
                frontMeshRend.sharedMaterial.SetFloat("_WaterHeight", height);
                frontMeshRend.sharedMaterial.SetFloat("_WaterWidth", width);
            }
        }