示例#1
0
文件: MapWorld.cs 项目: RomaMig/World
        public void Generate(ProgressBar progress, int type)
        {
            progress.Value = 40;

            MapHeights heights = MapHeights.creates[type](Width, Height);

            progress.Value = 70;

            int[,] distribution = Utilites.DFS <double>(heights.Map,
                                                        (double a) =>
            {
                return(a < Water.seaLevel);
            });
            progress.Value = 80;

            MapNormals normals = new MapNormals(heights);

            progress.Value = 90;

            initLight();
            progress.Value = 92;

            initCells(new Size(Form1.CELL_SIZE, Form1.CELL_SIZE), heights, normals, Light, distribution);
            Light.FirstPass();
            progress.Value = 95;
        }
示例#2
0
        public static MapHeights createLandscape(int w, int h)
        {
            MapHeights landscape;
            MapHeights mountains = createMountains(w, h);
            MapHeights hills     = createHills(w, h);

            int[,] heights = Utilites.DFS <double>(mountains.Map, (double a) =>
            {
                return(a < .3);
            });
            mountains = createUnion(
                false,
                (int i, int j, MapHeights[] maps) =>
            {
                if (heights[i, j] > 0)
                {
                    return((maps[0][i, j] * (.3 - maps[1][i, j]) + maps[1][i, j] * (.5 + maps[1][i, j])) * 10f / 8f);
                }
                else
                {
                    return(maps[1][i, j]);
                }
            }, hills, mountains);
            Bitmap     layoutM = new Bitmap(Bitmap.FromFile(@"C:\Users\Роман\source\repos\World\World\images\layout_mountains.bmp"), mountains.Width, mountains.Height);
            MapHeights plains  = createPlains(w, h);

            landscape = createUnion(
                false,
                (int i, int j, MapHeights[] maps) =>
            {
                double intensive = (layoutM.GetPixel(i, j).R / 255f);
                return(maps[0][i, j] * intensive + maps[1][i, j] * (1 - intensive));
            },
                plains, mountains);
            MapHeights seabed  = createSeabed(w, h);
            Bitmap     layoutS = new Bitmap(Bitmap.FromFile(@"C:\Users\Роман\source\repos\World\World\images\layout_sea.bmp"), seabed.Width, seabed.Height);

            landscape = createUnion(
                false,
                (int i, int j, MapHeights[] maps) =>
            {
                double intensive = 1 - (layoutS.GetPixel(i, j).R / 255f);
                return(maps[0][i, j] * intensive + maps[1][i, j] * (1 - intensive));
            },
                seabed, landscape);
            landscape.max = 1;
            landscape.min = -1;

            //landscape.postprocessing();
            return(landscape);
        }