public Terrain(DagonGame game, int width, int length) { _basicEffect = new BasicEffect(game.GraphicsDevice) { TextureEnabled = true}; if (game.Settings.EnableDefaultLighting) { _basicEffect.EnableDefaultLighting(); _basicEffect.PreferPerPixelLighting = true; } _basicEffect.FogEnabled = true; _basicEffect.FogStart = game.Settings.RangeOfVisibility / 3f; _basicEffect.FogEnd = game.Settings.RangeOfVisibility; _basicEffect.FogColor = game.World.SkyColor.ToVector3(); //_basicEffect. _game = game; _hightMap = new float[width + 1][]; var random = new Random(DateTime.Now.Millisecond); for (int i = 0; i < width + 1; i++) { _hightMap[i] = new float[length + 1]; for (int j = 0; j < length + 1; j++) { _hightMap[i][j] = (float)(random.NextDouble() / 4); } } vertexData = new VertexPositionNormalTexture[_hightMap.Length * _hightMap[0].Length * 2 * 3]; var index = 0; //TODO make map width*length size for (int i = 0; i < width-1; i++) { for (int j = 0; j < length-1; j++) { vertexData[index] = CreateVertex(i, j, new Vector2(0, 0)); index++; vertexData[index] = CreateVertex(i + 1, j, new Vector2(1, 0)); index++; vertexData[index] = CreateVertex(i, j + 1, new Vector2(0, 1)); index++; vertexData[index] = CreateVertex(i + 1, j, new Vector2(1, 0)); index++; vertexData[index] = CreateVertex(i + 1, j + 1, new Vector2(1, 1)); index++; vertexData[index] = CreateVertex(i, j + 1, new Vector2(0, 1)); index++; } } }
public Box(DagonGame game) { _basicEffect = new BasicEffect(game.GraphicsDevice) { VertexColorEnabled = true }; _game = game; }