public void Initialize(int numSteps, int resolution) { DisposeOfResources(); terrainGeneratorData = new TerrainGeneratorData(resolution); waterErosion = new WaterErosion(terrainGeneratorData); thermalErosion = new ThermalErosion(terrainGeneratorData); }
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 }
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); }
public ThermalErosion(TerrainGeneratorData terrain) { this.terrain = terrain; }
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; }