// Update is called once per frame void Update() { float[] norm = Normalise.Normaliser(new float[3] { CameraControle.Actuel.cam.orthographicSize, CameraControle.Actuel.minZoom, CameraControle.Actuel.maxZoom - 4 }); sourceForet.volume = 1 - norm[0]; sourceNuage.volume = norm[0]; }
public static Stack <float> Normaliser(Stack <float> stack) { float hauteurMinim = MiniMax.TrouverMinimum(stack); float hauteurMax = MiniMax.TrouverMaximum(stack); float[] tabloMediateur = new float[stack.Count]; for (int x = 0; x < stack.Count; x++) { tabloMediateur[x] = stack.Pop(); } Normalise.Normaliser(tabloMediateur); for (int x = 0; x < stack.Count; x++) { stack.Push(tabloMediateur[x]); } return(stack); }
public static Queue <float> Normaliser(Queue <float> queue) { float hauteurMinim = MiniMax.TrouverMinimum(queue); float hauteurMax = MiniMax.TrouverMaximum(queue); float[] tabloMediateur = new float[queue.Count]; for (int x = 0; x < queue.Count; x++) { tabloMediateur[x] = queue.Dequeue(); } Normalise.Normaliser(tabloMediateur); for (int x = 0; x < queue.Count; x++) { queue.Enqueue(tabloMediateur[x]); } return(queue); }
private const float RoughnessForTempAndRainfall = 0.5f; //Roughness to use for temp and rainfall maps public void Generate() { DeleteOldTerrain(); manager = GetComponent <HeightmapGenerationManager> (); layers = GetComponent <TerrainLayers> (); int dimension = (int)Mathf.Sqrt(numberOfChunks); chunks = new ChunkData[dimension, dimension]; for (int y = 0; y < dimension; y++) { for (int x = 0; x < dimension; x++) { int chunkDimension = 1025; chunks [x, y] = new ChunkData(chunkDimension, manager.terrainHeight, layers); float xOffset = (float)x * chunkDimension; float yOffset = (float)y * chunkDimension; chunks [x, y].terrain.transform.SetParent(terrainHolder); float[,] terrainMap = Normalise.NormaliseHeightmap(ApplyHeightCurve(manager.GenerateHeightMap(xOffset, yOffset))); float[,] temperatureMap = Normalise.NormaliseHeightmap(manager.GenerateHeatMap(xOffset, yOffset, genMethodForTempAndRainfall, RoughnessForTempAndRainfall)); float[,] precipitationMap = Normalise.NormaliseHeightmap(manager.GenerateRainMap(xOffset, yOffset, genMethodForTempAndRainfall, RoughnessForTempAndRainfall)); //chunks [x, y].SetHeightMap (Copy2DArray (terrainMap)); chunks [x, y].initialHeightMap = Copy2DArray(terrainMap); chunks [x, y].temperatureMap = temperatureMap; chunks [x, y].precipitationMap = precipitationMap; chunks [x, y].SetHeightMap(GetComponent <Convrt> ().Convert()); chunks[x, y].OffsetChunk(x, y); GetComponent <TextureManager> ().TextureChunk(chunks[x, y]); } } }