SetBounds() public method

Sets the bounds.
public SetBounds ( float min, float max ) : void
min float The minimum value.
max float The maximum value.
return void
Ejemplo n.º 1
0
    public void generate()
    {
        // Get the terrain data of the currently active terrain
        var terrainData = Terrain.activeTerrain.terrainData;

        // A new ridged multifractal generator
        var generator = new RidgedMultifractal(frequency, lacu, octaves, (int)(Random.value * 0xffffff), QualityMode.High);

        // The thresholded output -- choose either 0.0 or 1.0, based on the output
        var clamped = new LibNoise.Operator.Select(new Const(0.0f), new Const(1.0f), generator);

        // Set the threshold and falloff rate
        clamped.SetBounds(0f, threshold);
        clamped.FallOff = falloff;

        // Create a 2D noise generator for the terrain heightmap, using the generator we just created
        var noise = new Noise2D(terrainData.heightmapResolution, clamped);

        // Generate a plane from [0, 1] on x, [0, 1] on y
        noise.GeneratePlanar(0, 1, 0, 1);

        // Get the data in an array so we can use it to set the heights
        // var data = noise.GetData(true, 0, 0, true);
        var data = noise.GetNormalizedData();

        // .. and actually set the heights
        terrainData.SetHeights(0, 0, data);
    }
Ejemplo n.º 2
0
	void Start() 
	{
		// STEP 1
		// Gradient is set directly on the object
		var mountainTerrain = new RidgedMultifractal();
		RenderAndSetImage(mountainTerrain);

		// Stop rendering if we're only getting as far as this tutorial
		// step. It saves me from doing multiple files.
		if (_tutorialStep <= 1) return;

		// STEP 2
		var baseFlatTerrain = new Billow();
		baseFlatTerrain.Frequency = 2.0;
		RenderAndSetImage(baseFlatTerrain);


		if (_tutorialStep <= 2) return;

		// STEP 3
		var flatTerrain = new ScaleBias(0.125, -0.75, baseFlatTerrain);
		RenderAndSetImage(flatTerrain);

		if (_tutorialStep <= 3) return;

		// STEP 4
		var terrainType = new Perlin();
		terrainType.Frequency = 0.5;
		terrainType.Persistence = 0.25;

		var finalTerrain = new Select(flatTerrain, mountainTerrain, terrainType);
		finalTerrain.SetBounds(0, 1000);
		finalTerrain.FallOff = 0.125;
		RenderAndSetImage(finalTerrain);
	}
Ejemplo n.º 3
0
	void Start() 
	{
		var mountainTerrain = new RidgedMultifractal();

		var baseFlatTerrain = new Billow();
		baseFlatTerrain.Frequency = 2.0;

		var flatTerrain = new ScaleBias(0.125, -0.75, baseFlatTerrain);

		var terrainType = new Perlin();
		terrainType.Frequency = 0.5;
		terrainType.Persistence = 0.25;

		// Create the selector for turbulence
		var terrainSelector = new Select(flatTerrain, mountainTerrain, terrainType);
		terrainSelector.SetBounds(0, 1000);
		terrainSelector.FallOff = 0.125f;
		
		var finalTerrain = new Turbulence(terrainSelector);
		finalTerrain.Frequency = _frequency;
		finalTerrain.Power = _power;

		RenderAndSetImage(finalTerrain);
	}
Ejemplo n.º 4
0
	void Start() 
	{
		var mountainTerrain = new RidgedMultifractal();

		var baseFlatTerrain = new Billow();
		baseFlatTerrain.Frequency = 2.0;

		var flatTerrain = new ScaleBias(0.125, -0.75, baseFlatTerrain);

		var terrainType = new Perlin();
		terrainType.Frequency = 0.5;
		terrainType.Persistence = 0.25;

		var terrainSelector = new Select(flatTerrain, mountainTerrain, terrainType);
		terrainSelector.SetBounds(0, 1000);
		terrainSelector.FallOff = 0.125f;

		/*
		 * From the tutorial text:
		 * 
		 * Next, you'll apply a bias of +375 to the output from the terrainSelector 
		 * noise module. This will cause its output to range from (-375 + 375) to 
		 * (+375 + 375), or in other words, 0 to 750. You'll apply this bias so 
		 * that most of the elevations in the resulting terrain height map are 
		 * above sea level. 
		 */
		var terrainScaler = new ScaleBias(terrainSelector);
		terrainScaler.Scale = _scale;
		terrainScaler.Bias = _bias;
		
		var finalTerrain = new Turbulence(terrainScaler);
		finalTerrain.Frequency = _frequency;
		finalTerrain.Power = _power;

		RenderAndSetImage(finalTerrain);
	}