コード例 #1
0
        public float GetTemperature(Index3 blockIndex)
        {
            int   equator                     = (Planet.Size.Y * Chunk.CHUNKSIZE_Y) / 2;
            float equatorTemperature          = 40f;
            float poleTemperature             = -20f;
            float tempFluctuation             = tempFluctuationGenerator.GetTileableNoise2D(blockIndex.X, blockIndex.Y, Planet.Size.X * Chunk.CHUNKSIZE_X, Planet.Size.Y * Chunk.CHUNKSIZE_Y) * 5f;
            float temperatureDifference       = poleTemperature - equatorTemperature;
            float temperatureDecreasePerBlock = 0.1f;
            float distance                    = Math.Abs(blockIndex.Y - equator);
            float temperature                 = tempFluctuation + equatorTemperature + temperatureDifference * (float)Math.Sin((Math.PI / 2) * distance / equator); //equatorTemperature + distance * temperatureDifference / equator;
            float height = (float)(blockIndex.Z - planet.BiomeGenerator.SeaLevel) / (Planet.Size.Z * Chunk.CHUNKSIZE_Z - planet.BiomeGenerator.SeaLevel);

            height = Math.Max(height, 0);
            height = height * height;
            return(temperature - height * temperatureDecreasePerBlock);
        }