Ejemplo n.º 1
0
 public void Initialize(int numSteps, int resolution)
 {
     DisposeOfResources();
     terrainGeneratorData = new TerrainGeneratorData(resolution);
     waterErosion         = new WaterErosion(terrainGeneratorData);
     thermalErosion       = new ThermalErosion(terrainGeneratorData);
 }
Ejemplo n.º 2
0
    public WaterErosion(TerrainGeneratorData terrain)
    {
        this.terrain = terrain;
        waterHeight  = new NativeArray <float>(terrain.size * terrain.size, Allocator.Persistent);
#if DEBUG
        waterTerrainHeight = new NativeArray <float>(terrain.size * terrain.size, Allocator.Persistent);
#endif
    }
Ejemplo n.º 3
0
    public void generateAndApply(TerrainGeneratorData tGD)
    {
        if (resolution <= 0)
        {
            Debug.LogError("Resolution too small");
            return;
        }

        int m_resolution = resolution + 1;

        heightArray = createHeightMap(tGD, m_resolution);

        TerrainData terrainData = getTerrainData(m_resolution);

        terrainData.SetHeights(0, 0, heightArray);
    }
Ejemplo n.º 4
0
 public ThermalErosion(TerrainGeneratorData terrain)
 {
     this.terrain = terrain;
 }
Ejemplo n.º 5
0
    private float[,] createHeightMap(TerrainGeneratorData tGD, int m_resolution)
    {
        float[,] ary = new float[m_resolution, m_resolution];
        ary [0, 0] = tGD.startHeight;
        ary [m_resolution - 1, 0] = tGD.startHeight;
        ary [0, m_resolution - 1] = tGD.startHeight;
        ary [m_resolution - 1, m_resolution - 1] = tGD.startHeight;

        HeightMapGenerator.generateHeightMap(ary, tGD.k, tGD.roughness, tGD.minHeight, tGD.maxHeight);
        smooth(ary, tGD.smoothIterations);
        return ary;
    }