예제 #1
0
        public void CreateMoistureMap()
        {
            NoiseGenerator noise = new NoiseGenerator();

            MoistureMap.LockBits();
            for (int x = 0; x < MoistureMap.Width; x++)
            {
                for (int y = 0; y < MoistureMap.Height; y++)
                {
                    float orig = (float)noise.Noise(x / DivNoise / 4, y / DivNoise / 4);
                    orig *= orig;
                    float ydel = y / (float)MoistureMap.Height;
                    if (ydel > 0.5f)
                    {
                        ydel -= 0.5f;
                        ydel *= 2.0f;
                    }
                    else
                    {
                        ydel = (0.5f - ydel) * 2.0f;
                    }

                    orig = (orig + orig + ydel) / 3.0f;

                    MoistureMap.SetPixel(x, y, Color.FromArgb(255, (int)(255 * orig), (int)(255 * orig), (int)(255 * orig)));
                }
            }

            MoistureMap.UnlockBits();
            MoistureMap.ResizeImage(Map.Source.Width / 32, Map.Source.Height / 32);
            MoistureMap.ResizeImage(Width, Height);
        }
예제 #2
0
        public void AdjustMoistureMap()
        {
            MoistureMap.LockBits();
            Map.LockBits();
            for (int x = 0; x < MoistureMap.Width; x++)
            {
                for (int y = 0; y < MoistureMap.Height; y++)
                {
                    float orig = (float)MoistureMap.GetPixel(x, y).R / 255.0f;

                    float height = Map.GetHeight(x * 4, y * 4) / 255.0f;
                    if (height * 255.0f < 102)
                    {
                        orig = 1.0f;
                    }
                    if (orig > 1.0f)
                    {
                        orig = 1.0f;
                    }

                    height = 1.0f - height;
                    if (height > 0.54f)
                    {
                        orig = (orig + orig + 1) / 3.0f;
                    }

                    MoistureMap.SetPixel(x, y, Color.FromArgb(255, (int)(255 * orig), (int)(255 * orig), (int)(255 * orig)));
                }
            }

            Map.UnlockBits();
            MoistureMap.UnlockBits();
            MoistureMap.ResizeImage(MoistureMap.Source.Width / 16, MoistureMap.Source.Height / 16);
            MoistureMap.ResizeImage(Width, Height);

            //    MoistureMap.Save24(Globals.MapOutputTotalDir + "moisture.bmp");
        }