public void Initialize(IHeightMapSource heightMap) { // Build the quadtree. var createDescription = new CreateDescription { Settings = settings, HeightMap = heightMap }; quadTree.Build(ref createDescription); // Initialize a height map texture. InitializeHeightMapTexture(heightMap); }
/// <summary> /// Initialize a height map texture. /// The height map texture is created with SurfaceFormat.Single. /// </summary> /// <param name="heightMap"></param> void InitializeHeightMapTexture(IHeightMapSource heightMap) { heightMapTexture = new Texture2D(GraphicsDevice, heightMap.Width, heightMap.Height, false, SurfaceFormat.Single); var heights = new float[heightMap.Width * heightMap.Height]; for (int y = 0; y < heightMap.Height; y++) for (int x = 0; x < heightMap.Width; x++) heights[x + y * heightMap.Width] = heightMap.GetHeight(x, y); heightMapTexture.SetData(heights); }