public Forest(Game game, ICameraProvider cameraProvider, TerrainMesh terrain, SunlightParameters sky) : base(game) { if (game == null || cameraProvider == null || terrain == null) throw new ArgumentNullException(); _game = game; _cameraProvider = cameraProvider; _terrain = terrain; _sky = sky; _treePositions = new List<Vector3>(); }
public void BuildTerrain(int width, float minHeight, float maxHeight) { _width = width; _minHeight = minHeight; _maxHeight = maxHeight; // When running test scenarios over and over we need to generate the exact same terrains const int myRandomTerrainSeed = 1337; Heightmap = new Heightmap(myRandomTerrainSeed); Heightmap.GenerateFaultHeightmap(_width, _width, _minHeight, _maxHeight, new HeightmapFaultSettings(16, 256, 1024, 128, 0.5f)); // TODO Adding world transformation confuses the sunlight/terrain shader.. not sure why // const float scale = 10; Matrix world = Matrix.Identity; // Matrix.CreateScale(scale) * Matrix.CreateTranslation(scale * Position); Mesh = new TerrainMesh(Game, _cameraProvider, Heightmap, world); Mesh.Initialize(); // TerrainMeshes.Add(first); return; }