Esempio n. 1
0
 private float _Lerp4Height(uint x, uint y, float px, float py)
 {
     return(RMGUtility.LerpSquare(
                _raster.SquareCorners[x, y], _cornerElevations[x, y],
                _raster.SquareCorners[x + 1, y], _cornerElevations[x + 1, y],
                _raster.SquareCorners[x + 1, y + 1], _cornerElevations[x + 1, y + 1],
                _raster.SquareCorners[x, y + 1], _cornerElevations[x, y + 1],
                px, py) - 1);
 }
Esempio n. 2
0
        private void Test( )
        {
            Vector2 A = new Vector2(4, 3);
            Vector2 B = new Vector2(22, 3);
            Vector2 C = new Vector2(25, 30);
            Vector2 D = new Vector2(5, 28);
            Vector2 E = new Vector2(55, 2);
            Vector2 F = new Vector2(50, 32);
            float   a = Random.value;
            float   b = Random.value;
            float   c = Random.value;
            float   d = Random.value;
            float   e = Random.value;
            float   f = Random.value;

            print(a + " " + b + " " + c + " " + d);
            print(RMGUtility.LerpSquare(A, a, B, b, C, c, D, d, B.x, B.y));
            print(b + " " + e + " " + f + " " + c);
            float[,] heights = new float[65, 65];

            for (int i = 0; i < 65; i++)
            {
                for (int j = 0; j < 65; j++)
                {
                    if (RMGUtility.PointInSquare(A, B, C, D, j, i))
                    {
                        heights[i, j] = RMGUtility.LerpSquare(A, a, B, b, C, c, D, d, j, i);
                    }
                    if (RMGUtility.PointInSquare(B, E, F, C, j, i))
                    {
                        heights[i, j] = RMGUtility.LerpSquare(B, b, E, e, F, f, C, c, j, i);
                    }
                }
            }
            TerrainData trdata = new TerrainData();

            trdata.heightmapResolution = 65;
            trdata.size = new Vector3(100, 20, 100);
            trdata.SetHeights(0, 0, heights);
            GameObject tr = Terrain.CreateTerrainGameObject(trdata);
        }