Exemple #1
0
        public bool[,] Generate(int sizeX, int sizeY, int nThreads, int seed)
        {
            bool[,] tiles = new bool[sizeX, sizeY];

            Func <Vector3, float, float> sampler = (pos, scale) =>
                                                   NoiseAlgos3D.LinearNoise(pos * scale);

            float seedF = (float)seed;

            ThreadedRunner.Run(nThreads, sizeY,
                               (startY, endY) =>
            {
                for (int y = startY; y <= endY; ++y)
                {
                    float yF = (float)y;
                    for (int x = 0; x < sizeX; ++x)
                    {
                        float xF = (float)x;

                        float val   = Noise.Sample(new Vector3(xF, yF, seedF), sampler);
                        val         = Mathf.Pow(val, Exponent);
                        tiles[x, y] = (val > Threshold);
                    }
                }
            });

            return(tiles);
        }
Exemple #2
0
        public BiomeTile[,] Generate(int sizeX, int sizeY, int nThreads, int seed)
        {
            BiomeTile[,] tiles = new BiomeTile[sizeX, sizeY];

            Func <Vector3, float, float> sampler = (pos, scale) =>
                                                   NoiseAlgos3D.LinearNoise(pos * scale);

            float seedF = (float)seed;

            ThreadedRunner.Run(nThreads, sizeY,
                               (startY, endY) =>
            {
                for (int y = startY; y <= endY; ++y)
                {
                    float yF = (float)y;
                    for (int x = 0; x < sizeX; ++x)
                    {
                        float xF = (float)x;

                        tiles[x, y] = new BiomeTile();
                        tiles[x, y].CaveSmoothness = Noise.Sample(new Vector3(xF, yF, seedF),
                                                                  sampler);
                    }
                }
            });

            return(tiles);
        }