示例#1
0
        public override int[] GenLayer(int xCoord, int yCoord, int sizeX, int sizeY)
        {
            sizeX += zoomLevel;
            sizeY += zoomLevel;

            int[] outCache = new int[sizeX * sizeY];

            int parentXCoord = xCoord / zoomLevel - 1;
            int parentZCoord = yCoord / zoomLevel - 1;

            int smallXSize = sizeX / zoomLevel;
            int smallZSize = sizeY / zoomLevel;

            int[] inInts = parent.GenLayer(parentXCoord, parentZCoord, smallXSize, smallZSize);

            int index, inValue;

            for (int i = 0; i < inInts.Length; i++)
            {
                int xpos = i % smallXSize;
                int zpos = i / smallXSize;

                inValue = inInts[i];

                index = zoomLevel * xpos + zoomLevel * zpos * sizeX;

                for (int j = 0; j < zoomLevel * zoomLevel; j++)
                {
                    outCache[index + sizeX * (j / zoomLevel) + j % zoomLevel] = inValue;
                }
            }

            return(CutRightAndBottom(outCache, sizeX, sizeY, zoomLevel));
        }
        public override int[] GenLayer(int xCoord, int zCoord, int sizeX, int sizeZ)
        {
            int[] map = parent.GenLayer(xCoord, zCoord, sizeX, sizeZ);

            BoxBlurHorizontal(map, range, 0, 0, sizeX, sizeZ);
            BoxBlurVertical(map, range, 0, 0, sizeX, sizeZ);

            return(map);
        }
        public override int[] GenLayer(int xPos, int zPos, int xSize, int zSize)
        {
            int xCoord = xPos >> 1;
            int zCoord = zPos >> 1;

            int newXSize = (xSize >> 1) + 2;
            int newZSize = (zSize >> 1) + 2;

            int[] parentInts = parent.GenLayer(xCoord, zCoord, newXSize, newZSize);

            int outXsize = newXSize - 1 << 1;
            int outZSize = newZSize - 1 << 1;

            int[] fuzzyZoom = new int[outXsize * outZSize];
            int   index;

            for (int z = 0; z < newZSize - 1; ++z)
            {
                index = (z << 1) * outXsize;

                for (int x = 0; x < newXSize - 1; ++x)
                {
                    InitPositionSeed(xCoord + x, zCoord + z);

                    int valTopLeft     = parentInts[x + (z + 0) * newXSize];
                    int valTopRight    = parentInts[x + 1 + (z + 0) * newXSize];
                    int valBottomLeft  = parentInts[x + (z + 1) * newXSize];
                    int valBottomRight = parentInts[x + 1 + (z + 1) * newXSize];

                    fuzzyZoom[index]                = valTopLeft;
                    fuzzyZoom[index + outXsize]     = selectRandom(valTopLeft, valBottomLeft);
                    fuzzyZoom[index + 1]            = selectRandom(valTopLeft, valTopRight);
                    fuzzyZoom[index + 1 + outXsize] = selectRandom(valTopLeft, valTopRight, valBottomLeft, valBottomRight);

                    index += 2;
                }
            }

            int[] outCache = new int[xSize * zSize];

            for (int z = 0; z < zSize; ++z)
            {
                int srcPos = (z + (zPos & 1)) * outXsize + (xPos & 1);

                Array.Copy(fuzzyZoom, srcPos, outCache, z * xSize, xSize);
            }

            return(outCache);
        }
示例#4
0
        private void OnMapRegionGen(IMapRegion mapRegion, int regionX, int regionZ)
        {
            int pad = TerraGenConfig.geoProvMapPadding;

            mapRegion.GeologicProvinceMap.Data = geologicprovinceGen.GenLayer(
                regionX * noiseSizeGeoProv - pad,
                regionZ * noiseSizeGeoProv - pad,
                noiseSizeGeoProv + 2 * pad,
                noiseSizeGeoProv + 2 * pad
                );
            mapRegion.GeologicProvinceMap.Size           = noiseSizeGeoProv + 2 * pad;
            mapRegion.GeologicProvinceMap.TopLeftPadding = mapRegion.GeologicProvinceMap.BottomRightPadding = pad;

            pad = 2;
            // dominionsmod we get the climate data through the GenClimateLayer method of WorldMap, which reads the climate.png
            if (worldMap.climateMap != null)
            {
                mapRegion.ClimateMap.Data = worldMap.GenClimateLayer(
                    regionX,
                    regionZ,
                    noiseSizeClimate + 2 * pad,
                    noiseSizeClimate + 2 * pad
                    );
            }
            else
            {
                mapRegion.ClimateMap.Data = climateGen.GenLayer(
                    regionX * noiseSizeClimate - pad,
                    regionZ * noiseSizeClimate - pad,
                    noiseSizeClimate + 2 * pad,
                    noiseSizeClimate + 2 * pad
                    );
            }
            mapRegion.ClimateMap.Size           = noiseSizeClimate + 2 * pad;
            mapRegion.ClimateMap.TopLeftPadding = mapRegion.ClimateMap.BottomRightPadding = pad;


            mapRegion.ForestMap.Size = noiseSizeForest + 1;
            mapRegion.ForestMap.BottomRightPadding = 1;
            forestGen.SetInputMap(mapRegion.ClimateMap, mapRegion.ForestMap);
            mapRegion.ForestMap.Data = forestGen.GenLayer(regionX * noiseSizeForest, regionZ * noiseSizeForest, noiseSizeForest + 1, noiseSizeForest + 1);


            mapRegion.BeachMap.Size = noiseSizeBeach + 1;
            mapRegion.BeachMap.BottomRightPadding = 1;
            mapRegion.BeachMap.Data = beachGen.GenLayer(regionX * noiseSizeBeach, regionZ * noiseSizeBeach, noiseSizeBeach + 1, noiseSizeBeach + 1);

            mapRegion.ShrubMap.Size = noiseSizeShrubs + 1;
            mapRegion.ShrubMap.BottomRightPadding = 1;
            bushGen.SetInputMap(mapRegion.ClimateMap, mapRegion.ShrubMap);
            mapRegion.ShrubMap.Data = bushGen.GenLayer(regionX * noiseSizeShrubs, regionZ * noiseSizeShrubs, noiseSizeShrubs + 1, noiseSizeShrubs + 1);


            mapRegion.FlowerMap.Size = noiseSizeForest + 1;
            mapRegion.FlowerMap.BottomRightPadding = 1;
            flowerGen.SetInputMap(mapRegion.ClimateMap, mapRegion.FlowerMap);
            mapRegion.FlowerMap.Data = flowerGen.GenLayer(regionX * noiseSizeForest, regionZ * noiseSizeForest, noiseSizeForest + 1, noiseSizeForest + 1);



            pad = TerraGenConfig.landformMapPadding;
            // dominionsmod
            if (worldMap.landformMap != null)
            {
                mapRegion.LandformMap.Data = worldMap.GenLandformLayer(regionX, regionZ, noiseSizeLandform + 2 * pad, noiseSizeLandform + 2 * pad);
            }
            else
            {
                mapRegion.LandformMap.Data = landformsGen.GenLayer(regionX * noiseSizeLandform - pad, regionZ * noiseSizeLandform - pad, noiseSizeLandform + 2 * pad, noiseSizeLandform + 2 * pad);
            }
            mapRegion.LandformMap.Size           = noiseSizeLandform + 2 * pad;
            mapRegion.LandformMap.TopLeftPadding = mapRegion.LandformMap.BottomRightPadding = pad;


            mapRegion.DirtyForSaving = true;
        }