private void CreateGround()
        {
            var heightmap = new Graphics.Software.Texel.R32F[100, 100];

            Random r       = new Random();
            int    xSize   = 4;
            int    ySize   = 4;
            int    xPieces = (int)(heightmap.GetLength(0) / (float)xSize);
            int    yPieces = (int)(heightmap.GetLength(1) / (float)ySize);

            float lastHeight = 0f;

            for (int y = 0; y < yPieces; y++)
            {
                for (int x = 0; x < xPieces; x++)
                {
                    float height = 2f * (float)r.NextDouble() - 1f;
                    for (int yp = 0; yp < ySize; yp++)
                    {
                        for (int xp = 0; xp < xSize; xp++)
                        {
                            if (x > 0 && y > 0)
                            {
                                heightmap[x * xSize + xp, y *ySize + yp].R = lastHeight + (height - lastHeight) * ((float)xp / (xSize - 1)) * ((float)yp / (ySize - 1));
                            }
                        }
                    }
                    lastHeight = height;
                }
            }


            var ground = new TestGround
            {
                Size      = new SizeF(size.Width, size.Height),
                Heightmap = heightmap,
                NPieces   = new Size(10, 10),
                Height    = 1,
            };

            scene.Add(ground);
            ground.ConstructPieces();
        }
        private void CreateGround()
        {
            var heightmap = new Graphics.Software.Texel.R32F[100, 100];

            Random r = new Random();
            int xSize = 4;
            int ySize = 4;
            int xPieces = (int)(heightmap.GetLength(0) / (float)xSize);
            int yPieces = (int)(heightmap.GetLength(1) / (float)ySize);

            float lastHeight = 0f;
            for (int y = 0; y < yPieces; y++)
            {
                for (int x = 0; x < xPieces; x++)
                {
                    float height = 2f * (float)r.NextDouble() - 1f;
                    for (int yp = 0; yp < ySize; yp++)
                        for (int xp = 0; xp < xSize; xp++)
                        {
                            if (x > 0 && y > 0)
                                heightmap[x*xSize + xp, y*ySize + yp].R = lastHeight + (height - lastHeight) * ((float)xp / (xSize - 1)) * ((float)yp / (ySize - 1));
                        }
                    lastHeight = height;
                }
            }

            var ground = new TestGround
            {
                Size = new SizeF(size.Width, size.Height),
                Heightmap = heightmap,
                NPieces = new Size(10, 10),
                Height = 1,
            };

            scene.Add(ground);
            ground.ConstructPieces();
        }