Пример #1
0
        public override int[] GenLayer(int xCoord, int zCoord, int sizeX, int sizeZ)
        {
            int[] result = new int[sizeX * sizeZ];

            for (int x = 0; x < sizeX; x++)
            {
                for (int z = 0; z < sizeZ; z++)
                {
                    int offsetX = (int)(wobbleIntensity * noisegenX.Noise(xCoord + x, zCoord + z));
                    int offsetY = (int)(wobbleIntensity * noisegenY.Noise(xCoord + x, zCoord + z));

                    int finalX = (xCoord + x + offsetX);
                    int finalZ = (zCoord + z + offsetY);

                    int climate = climateNoise.GetLerpedClimateAt(finalX / TerraGenConfig.climateMapScale, finalZ / TerraGenConfig.climateMapScale);
                    int rain    = (climate >> 8) & 0xff;
                    int temp    = TerraGenConfig.GetScaledAdjustedTemperature((climate >> 16) & 0xff, 0);

                    result[z * sizeX + x] = noiseLandforms.GetLandformIndexAt(
                        finalX,
                        finalZ,
                        temp,
                        rain
                        );

                    /*float baseX = (float)finalX / TerraGenConfig.landformMapScale;
                     * float baseY = (float)finalZ / TerraGenConfig.landformMapScale;
                     *
                     * result[z * sizeX + x] = noiseLandforms.GetParentLandformIndexAt(
                     *  (int)baseX,
                     *  (int)baseY,
                     *  climateNoise.GetLerpedClimateAt(finalX / TerraGenConfig.climateMapScale, finalZ / TerraGenConfig.climateMapScale),
                     *  baseX - (int)baseX,
                     *  baseY - (int)baseY
                     * );*/
                }
            }

            return(result);
        }
        public override int[] GenLayer(int xCoord, int zCoord, int sizeX, int sizeZ)
        {
            int[] result = new int[sizeX * sizeZ];

            int cacheSizeX = (int)Math.Ceiling((float)sizeX / TerraGenConfig.climateMapSubScale) + 1;
            int cacheSizeZ = (int)Math.Ceiling((float)sizeZ / TerraGenConfig.climateMapSubScale) + 1;

            int[] climateCache = getClimateCache(xCoord / TerraGenConfig.climateMapSubScale, zCoord / TerraGenConfig.climateMapSubScale, cacheSizeX, cacheSizeZ);

            for (int x = 0; x < sizeX; x++)
            {
                for (int z = 0; z < sizeZ; z++)
                {
                    result[z * sizeX + x] = map.GetLerpedClimateAt(
                        x / (double)TerraGenConfig.climateMapSubScale,
                        z / (double)TerraGenConfig.climateMapSubScale,
                        climateCache,
                        cacheSizeX
                        );
                }
            }

            return(result);
        }