예제 #1
0
        private float[] GenerateHeightMap(WorldGenData data, int chunkX, int chunkY, int seedX, int seedY)
        {
            float[] heightMap = new float[data.chunkSize * data.chunkSize];

            float layerFrequency = data.layerFrequency;
            float layerWeight    = data.layerWeight;

            for (int octave = 0; octave < data.octaves; octave++)
            {
                for (int y = 0; y < data.chunkSize; y++)
                {
                    for (int x = 0; x < data.chunkSize; x++)
                    {
                        float inputX = chunkX * data.chunkSize + x + seedX;
                        float inputY = chunkY * data.chunkSize + y + seedY;
                        float noise  = data.layerWeight * SimplexNoise.Noise(inputX * layerFrequency, inputY * layerFrequency);
                        heightMap[x + y * data.chunkSize] += noise;
                    }
                }

                layerFrequency *= 2.0f;
                layerWeight    *= data.roughness;
            }

            return(heightMap);
        }
예제 #2
0
        public void GenerateWorld(WorldGenData data, int seedX, int seedY)
        {
            IdTranslator.Instance.GenerateMissingIds();

            var world = new ServerWorld(255 * data.chunkSize, 255 * data.chunkSize, data.chunkSize)
            {
                SeedX = seedX,
                SeedY = seedY
            };

            ServerApp.World = world;
        }
예제 #3
0
        public void GenerateChunk(WorldChunk chunkToGenerate, WorldGenData data)
        {
            byte chunkX = chunkToGenerate.chunkX;
            byte chunkY = chunkToGenerate.chunkY;

            float[] heightMap = GenerateHeightMap(data, chunkX, chunkY, ServerApp.World.SeedX, ServerApp.World.SeedY);

            for (int y = 0; y < data.chunkSize; y++)
            {
                for (int x = 0; x < data.chunkSize; x++)
                {
                    float height = Mathf.Clamp(heightMap[x + y * data.chunkSize], -1.0f, 1.0f);

                    foreach (var biomeTileData in data.tilesInBiome)
                    {
                    }
                }
            }
        }