Exemplo n.º 1
0
        private void InitGenerators()
        {
            //prepare noise generators
              perlinLeft = new Perlin() { Frequency = RiverShapeFrequency, NoiseQuality = NoiseQuality.Standard, Seed = Seed + 1, OctaveCount = 6, Lacunarity = RiverShapeLacunarity, Persistence = RiverShapePersistence };
              perlinRight = new Perlin() { Frequency = RiverShapeFrequency, NoiseQuality = NoiseQuality.Standard, Seed = Seed + 2, OctaveCount = 6, Lacunarity = RiverShapeLacunarity, Persistence = RiverShapePersistence };
              perlinLeftWidth = new Perlin() { Frequency = RiverWidthFrequency, NoiseQuality = NoiseQuality.Standard, Seed = Seed + 3, OctaveCount = 6, Lacunarity = RiverWidthLacunarity, Persistence = RiverWidthPersistence };
              perlinRightWidth = new Perlin() { Frequency = RiverWidthFrequency, NoiseQuality = NoiseQuality.Standard, Seed = Seed + 4, OctaveCount = 6, Lacunarity = RiverWidthLacunarity, Persistence = RiverWidthPersistence };

              Perlin terrainPerlin = new Perlin() { Frequency = TerrainPerlinFrequency, NoiseQuality = NoiseQuality.Standard, Seed = Seed, OctaveCount = 6, Lacunarity = TerrainPerlinLacunarity, Persistence = TerrainPerlinPersistence };
              RidgedMultifractal terrainRMF = new RidgedMultifractal() { Frequency = TerrainRMFFrequency, NoiseQuality = NoiseQuality.High, Seed = Seed - 1, OctaveCount = 6, Lacunarity = TerrainRMFLacunarity };
              ScaleOutput scaledRMF = new ScaleOutput(terrainRMF, TerrainRMFScale);
              Add terrainAdd = new Add(terrainPerlin, new BiasOutput(scaledRMF, TerrainRMFBias));
              terrainScaledModule = new ScaleOutput(terrainAdd, HeightScale);

              biomesPerlin = new Perlin() { Frequency = BiomesFrequency, NoiseQuality = NoiseQuality.Low, Seed = Seed - 10, OctaveCount = 6, Lacunarity = BiomesLacunarity, Persistence = BiomesPersistence };
        }
    public LibNoise.IModule GenerateNoise(TerrainArchetype curTerrain, LibNoise.IModule noiseCombine)
    {
        LibNoise.Perlin Temp = new LibNoise.Perlin();
        tempnoise = Temp; noise = Temp; noise1 = Temp; noise2 = Temp; noiseCombine = Temp;
        // Apply Noise Values
        for (int i = 0; i < curTerrain.C_nNoiseList.Length; i++)
        {
            switch (curTerrain.C_nNoiseList[i])
            {
            case SetNoise.Perlin:
                LibNoise.Perlin perlin = new LibNoise.Perlin();
                perlin.Frequency    = curTerrain.C_nFrequency;
                perlin.Lacunarity   = curTerrain.C_nLacunarity;
                perlin.NoiseQuality = curTerrain.C_nQuality;
                perlin.OctaveCount  = curTerrain.C_nOctaves;
                perlin.Persistence  = curTerrain.C_nPersistence;
                perlin.Seed         = curTerrain.C_nSeed;
                tempnoise           = perlin;
                break;

            case SetNoise.Billow:
                LibNoise.Billow billow = new LibNoise.Billow();
                billow.Frequency    = curTerrain.C_nFrequency;
                billow.Lacunarity   = curTerrain.C_nLacunarity;
                billow.NoiseQuality = curTerrain.C_nQuality;
                billow.OctaveCount  = curTerrain.C_nOctaves;
                billow.Persistence  = curTerrain.C_nPersistence;
                billow.Seed         = curTerrain.C_nSeed;
                tempnoise           = billow;
                break;

            case SetNoise.MultiFractal:
                LibNoise.RidgedMultifractal MultiFrac = new LibNoise.RidgedMultifractal();
                MultiFrac.Frequency    = curTerrain.C_nFrequency;
                MultiFrac.Lacunarity   = curTerrain.C_nLacunarity;
                MultiFrac.NoiseQuality = curTerrain.C_nQuality;
                MultiFrac.OctaveCount  = curTerrain.C_nOctaves;
                //MultiFrac.Persistence = Persistence;
                MultiFrac.Seed = curTerrain.C_nSeed;
                tempnoise      = MultiFrac;
                break;
            }
            switch (i)
            {
            case 0:
                noise = tempnoise;
                break;

            case 1:
                noise1 = tempnoise;
                break;

            case 2:
                noise2 = tempnoise;
                break;
            }
        }

        //selector = new LibNoise.Modifiers.Select(noise,noise1,noise2);
        LibNoise.IModule tempNoise1 = new LibNoise.Modifiers.Add(noise, noise1);
        LibNoise.IModule tempNoise2 = new LibNoise.Modifiers.Add(tempNoise1, noise2);
        noiseCombine = tempNoise2;
        return(noiseCombine);
    }