private void LoadHeightData(Texture2D heightMap)
        {
            terrainWidth  = heightMap.Width;
            terrainHeight = heightMap.Height;

            Color[] heightMapColors = new Color[terrainWidth * terrainHeight];
            heightMap.GetData(heightMapColors);

            heightData = new float[terrainWidth, terrainHeight];
            var bepuHehighData = new float[terrainWidth, terrainHeight];

            for (int x = 0; x < terrainWidth; x++)
            {
                for (int y = 0; y < terrainHeight; y++)
                {
                    heightData[x, y] = heightMapColors[x + y * terrainWidth].R / 5.0f;
                }
            }

            int yy = 0;

            for (int x = 0; x < terrainWidth; x++)
            {
                for (int y = terrainHeight - 1; y >= 0; y--)
                {
                    bepuHehighData[x, y] = heightMapColors[x + yy * terrainWidth].R / 5.0f;
                    yy++;
                }
                yy = 0;
            }
            bepuTerrain = new BEPUphysics.Collidables.Terrain(bepuHehighData, new AffineTransform(
                                                                  new Vector3(1, 1, 1)
                                                                  , Quaternion.Identity
                                                                  , new Vector3(0, 0, -terrainHeight)
                                                                  ));

            Game1.Instance.Space.Add(bepuTerrain);
        }
        private void LoadHeightData(Texture2D heightMap)
        {
            terrainWidth = heightMap.Width;
            terrainHeight = heightMap.Height;

            Color[] heightMapColors = new Color[terrainWidth * terrainHeight];
            heightMap.GetData(heightMapColors);

            heightData = new float[terrainWidth, terrainHeight];
            var bepuHehighData = new float[terrainWidth, terrainHeight];
            for (int x = 0; x < terrainWidth; x++)
            {
                for (int y = 0; y < terrainHeight; y++)
                {
                    heightData[x, y] = heightMapColors[x + y * terrainWidth].R / 5.0f;
                }
            }

            int yy = 0;
            for (int x = 0; x < terrainWidth; x++)
            {
                for (int y = terrainHeight - 1; y >= 0 ; y--)
                {
                    bepuHehighData[x, y] = heightMapColors[x + yy * terrainWidth].R / 5.0f;
                    yy++;
                }
                yy = 0;
            }
            bepuTerrain = new BEPUphysics.Collidables.Terrain(bepuHehighData, new AffineTransform(
                    new Vector3(1, 1, 1)
                    , Quaternion.Identity
                    ,new Vector3(0, 0, -terrainHeight)
                    ));

             Game1.Instance.Space.Add(bepuTerrain);
        }