Exemplo n.º 1
0
    public void BuildMap()
    {
        //initialzing settings objects

        hmSettings = new heightMapSettings
        {
            Octaves     = octaves,
            Frequency   = frequency,
            Lacunarity  = lacunarity,
            Quality     = quality,
            Seed        = seed,
            Persistence = persistence
        };
        thisChunk = new worldChunkSettings //need to move this out of this class for tiling world chunks
        {
            mapHeight = _mapHeight,
            mapWidth  = _mapWidth,
            top       = 0,
            bottom    = 1,
            left      = 2,
            right     = 3
        };
        mmSettings = new moistureMapSettings
        {
            Octaves     = MMoctaves,
            Frequency   = MMfrequency,
            Lacunarity  = MMlacunarity,
            Quality     = MMquality,
            Seed        = MMseed,
            Persistence = MMpersistence
        };

        //build maps
        HeightMap   = new heightMap(thisChunk, hmSettings);
        HeatMap     = new heatMap(thisChunk);
        ComboMap    = new combinedHeightHeat(HeightMap, HeatMap, thisChunk);
        MoistureMap = new moistureMap(thisChunk, mmSettings, HeightMap);
        BiomeMap    = new biomeMap(HeightMap, ComboMap, MoistureMap, maskWater);
        //Debug.Log("map seed "+hmSettings.Seed);
        //find game objects and build textures for each map
        HeightDisplay = GameObject.Find("HeightMapObj");
        HeightDisplay.GetComponent <Renderer>().sharedMaterial.mainTexture = textureFromMap.BuildTexture(HeightMap);
        //Debug.Log("Perlin point:" + HeightMap.GetValue(100, 100));

        HeatDisplay = GameObject.Find("HeatMapObj");
        HeatDisplay.GetComponent <Renderer>().sharedMaterial.mainTexture = textureFromMap.BuildTexture(HeatMap);

        //Debug.Log("Gradient Noise value:" + HeatMap.GetValue(0, 10));
        ComboDisplay = GameObject.Find("ComboMapObj");
        ComboDisplay.GetComponent <Renderer>().sharedMaterial.mainTexture = textureFromMap.BuildTexture(ComboMap);

        MoistureDisplay = GameObject.Find("MoistureMapObj");
        MoistureDisplay.GetComponent <Renderer>().sharedMaterial.mainTexture = textureFromMap.BuildTexture(MoistureMap);

        BiomeDisplay = GameObject.Find("BiomeMapObj");
        BiomeDisplay.GetComponent <Renderer>().sharedMaterial.mainTexture = textureFromMap.BuildTexture(BiomeMap);
    }
Exemplo n.º 2
0
    private void fill(worldChunkSettings chunkSettings, heightMapSettings settings)

    {
        RidgedMultifractal baseMap = new RidgedMultifractal();

        baseMap.OctaveCount = settings.Octaves;
        baseMap.Frequency   = settings.Frequency;
        baseMap.Lacunarity  = settings.Lacunarity;
        baseMap.Seed        = settings.Seed;

        Perlin layer2 = new Perlin();

        layer2.OctaveCount = settings.Octaves;
        layer2.Frequency   = settings.Frequency;
        layer2.Lacunarity  = settings.Lacunarity;
        layer2.Seed        = settings.Seed;
        Billow controller = new Billow();

        controller.Frequency = settings.Frequency;
        Blend  blend    = new Blend(baseMap, layer2, controller);
        Invert invert   = new Invert(blend);         //makes heightmap more island like
        Clamp  oceanfix = new Clamp(-.7, 1, invert); //prevent ocean floor from being to low

        //Const black = new Const(-1);
        // holes in surface at top of mountains
        //Select holes = new Select(oceanfix, black, oceanfix);
        //holes.SetBounds(.85, 1, .01); //get highest elevation with little falloff
        this.heightCache = new Cache(oceanfix);

        var final = new Noise2D(chunkSettings.mapHeight, chunkSettings.mapWidth, oceanfix);

        //turbulance = new Turbulence(12, baseMap);
        final.GeneratePlanar(chunkSettings.left, chunkSettings.right, chunkSettings.top, chunkSettings.bottom, isSeamless: true);
        //final.GenerateSpherical(1, 3,1, 3);

        /*
         * for (int x=0; x<mapWidth; x++)
         * {
         *  for (int y=0;y<mapHeight;y++)
         *  {
         *      noiseData[x,y] = (float)(baseMap.GetValue(x,0,y));
         *  }
         * }
         */
        noiseData = final.GetData();
    }
Exemplo n.º 3
0
    public heightMap(worldChunkSettings chunkSettings, heightMapSettings settings)

    {
        fill(chunkSettings, settings);
    }