コード例 #1
0
ファイル: Heightmap.cs プロジェクト: BestDevel/Example_Scene
 public Heightmap(Heightmap parentHeightmap, Vector2Int offset, Vector2Int size, float remap, float baseLevel)
 {
     // Initialise our dimensions and allocate the necessary memory...
     Size  = size;
     Remap = remap;
     Base  = baseLevel;
     m_NormalisedHeights = GenerateBlendedHeightDataFromParent(parentHeightmap, offset, size);
 }
コード例 #2
0
ファイル: Heightmap.cs プロジェクト: BestDevel/Example_Scene
        private float[,] GenerateExactHeightDataFromParent(Heightmap parentHeightmap, Vector2Int offset, Vector2Int size)
        {
            float[,] parentHeightData  = parentHeightmap.m_NormalisedHeights;
            float[,] normalisedHeights = new float[size.y, size.x];

            // Copy the height data from our parent height-map...
            for (int y = 0; y < size.y; y++)
            {
                for (int x = 0; x < size.x; x++)
                {
                    int   parentX      = offset.x + x;
                    int   parentY      = offset.y + y;
                    float parentHeight = parentHeightData[parentY, parentX];

                    m_NormalisedHeights[y, x] = parentHeight;
                }
            }

            return(normalisedHeights);
        }
コード例 #3
0
ファイル: Heightmap.cs プロジェクト: BestDevel/Example_Scene
        private float[,] GenerateBlendedHeightDataFromParent(Heightmap parentHeightmap, Vector2Int offset, Vector2Int size)
        {
            float[,] normalisedHeights = new float[size.y + 1, size.x + 1];
            Vector2 parentOffset = new Vector2(0.0f, offset.y);                 // - 0.5f);
            int     width        = size.x;
            int     height       = size.y;

            // Copy the height data from our parent height-map...
            for (int y = 0; y <= height; y++, parentOffset.y++)
            {
                parentOffset.x = offset.x;                      // - 0.5f;

                for (int x = 0; x <= width; x++, parentOffset.x++)
                {
                    float parentHeight = parentHeightmap.GetNormalisedHeightAt(parentOffset);

                    normalisedHeights[y, x] = parentHeight * Remap + Base;
                }
            }

            return(normalisedHeights);
        }