예제 #1
0
    public void GenerateMap()
    {
        float[,] noiseMap = Noise.GenerateNoiseMap(_mapWidth, _mapHeight, _seed, _noiseScale, _octaves, _persistance, _lacunarity, _offset);

        Color[] colormap = SetColorMap(noiseMap);

        // Display
        if (_drawMode == DrawMode.NoiseMap)
        {
            _mapDisplay.DrawTexture(TextureGenerator.TextureFromHeightMap(noiseMap));
        }
        else if (_drawMode == DrawMode.RegionColorMap)
        {
            _mapDisplay.DrawTexture(TextureGenerator.TextureFromColormap(colormap, _mapWidth, _mapHeight));
        }
        else if (_drawMode == DrawMode.Mesh)
        {
            var meshData = MeshGenerator.GenerateTerrainMesh(noiseMap, _regions[0].height);
            _mapDisplay.DrawMesh(meshData, TextureGenerator.TextureFromColormap(colormap, _mapWidth, _mapHeight));
            if (_generateObstacles)
            {
                ObstacleGenerator.GenerateObstacleMesh(meshData);
            }
        }
        else if (_drawMode == DrawMode.Mesh3D)
        {
            _mapDisplay.DrawMesh3D(MeshGenerator3D.GenerateTerrainMesh(noiseMap), TextureGenerator.TextureFromColormap(colormap, _mapWidth, _mapHeight));
        }
    }
예제 #2
0
    public void GenerateMap()
    {
        float[,] noiseMap = Noise.GenerateNoiseMap(_mapWidth, _mapHeight, _seed, _noiseScale, _octaves, _persistance, _lacunarity, _offset);

        Color[] colormap = SetColorMap(noiseMap);

        if (_waterDepth > DefaultHeight)
        {
            DefaultHeight += _waterDepth;
        }

        // Display
        var meshData = MeshGenerator.GenerateTerrainMesh(noiseMap, _regions[0].height, _yPosition, _waterDepth, DefaultHeight);

        _mapDisplay.DrawMesh(meshData, TextureGenerator.TextureFromColormap(colormap, _mapWidth, _mapHeight));
        if (_generateObstacles)
        {
            ObstacleGenerator.GenerateObstacleMesh(meshData);
        }

        if (_grid != null)
        {
            _grid.StartPathfindGrid();
        }
    }