Beispiel #1
0
        public void PaintEffect(ITerrainChannel map, bool[,] mask, float rx, float ry, float rz,
                                float size, float strength, int startX, int endX, int startY, int endY)
        {
            int   x, y;
            float distancefactor;
            float dx2;

            size *= size;

            for (x = startX; x <= endX; x++)
            {
                dx2 = (x - rx) * (x - rx);
                for (y = startY; y <= endY; y++)
                {
                    if (!mask[x, y])
                    {
                        continue;
                    }

                    // Calculate a sphere and add it to the heighmap
                    distancefactor = (dx2 + (y - ry) * (y - ry)) / size;
                    if (distancefactor > 1.0f)
                    {
                        continue;
                    }

                    distancefactor = strength * (1.0f - distancefactor);
                    float noise = (float)TerrainUtil.PerlinNoise2D(x / (double)map.Width, y / (double)map.Height, 8, 1.0);
                    map[x, y] += noise * distancefactor;
                }
            }
        }
Beispiel #2
0
        public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
        {
            strength = TerrainUtil.MetersToSphericalStrength(strength);

            int x;

            for (x = 0; x < map.Width; x++)
            {
                int y;
                for (y = 0; y < map.Height; y++)
                {
                    if (!mask[x, y])
                    {
                        continue;
                    }

                    // Calculate a sphere and add it to the heighmap
                    double z = strength;
                    z *= z;
                    z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));

                    double noise = TerrainUtil.PerlinNoise2D(x / (double)Constants.RegionSize, y / (double)Constants.RegionSize, 8, 1.0);

                    if (z > 0.0)
                    {
                        map[x, y] += noise * z * duration;
                    }
                }
            }
        }
Beispiel #3
0
        public override float operate(float[,] map, TerrainModifierData data, int x, int y)
        {
            float factor = this.computeBevel(data, x, y);
            float noise  = (float)TerrainUtil.PerlinNoise2D((double)x / map.GetLength(0), (double)y / map.GetLength(1), 8, 1.0);

            return(map[x, y] + (data.elevation - (data.elevation - data.bevelevation) * factor) * (noise - .5f));
        }
Beispiel #4
0
        public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
                                double strength, double duration, int startX, int endX, int startY, int endY)
        {
            strength = TerrainUtil.MetersToSphericalStrength(strength);

            int x, y;

            for (x = startX; x <= endX; x++)
            {
                for (y = startY; y <= endY; y++)
                {
                    if (!mask[x, y])
                    {
                        continue;
                    }

                    // Calculate a sphere and add it to the heighmap
                    double z = strength;
                    z *= z;
                    z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));

                    double noise = TerrainUtil.PerlinNoise2D(x / (double)map.Width, y / (double)map.Height, 8, 1.0);

                    if (z > 0.0)
                    {
                        map[x, y] += noise * z * duration;
                    }
                }
            }
        }
Beispiel #5
0
        public void RunEffect(ITerrainChannel map)
        {
            int x, y;

            for (x = 0; x < map.Width; x++)
            {
                for (y = 0; y < map.Height; y++)
                {
                    map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10;
                    double spherFac = TerrainUtil.SphericalFactor(x, y, map.Width / 2, map.Height / 2, 50) * 0.01;
                    if (map[x, y] < spherFac)
                    {
                        map[x, y] = spherFac;
                    }
                }
            }
        }
Beispiel #6
0
        public void FloodEffect(ITerrainChannel map, UUID userID, float north,
                                float west, float south, float east, float strength)
        {
            for (int x = (int)west; x < (int)east; x++)
            {
                for (int y = (int)south; y < (int)north; y++)
                {
                    if (!((Scene)map.Scene).Permissions.CanTerraformLand(userID, new Vector3(x, y, 0)))
                    {
                        continue;
                    }
                    float noise = TerrainUtil.PerlinNoise2D(x / map.Scene.RegionInfo.RegionSizeX, y / map.Scene.RegionInfo.RegionSizeY, 8, 1);

                    map[x, y] += noise * strength;
                }
            }
        }
        public void RunEffect(ITerrainChannel map)
        {
            int x, y;

            for (x = 0; x < map.Width; x++)
            {
                for (y = 0; y < map.Height; y++)
                {
                    map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25f) * 10;
                    float spherFac = TerrainUtil.SphericalFactor(x, y, map.Scene.RegionInfo.RegionSizeX / 2, map.Scene.RegionInfo.RegionSizeY / 2, 50) * 0.01f;
                    if (map[x, y] < spherFac)
                    {
                        map[x, y] = spherFac;
                    }
                }
            }
        }
Beispiel #8
0
        public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
                                int startX, int endX, int startY, int endY)
        {
            int x, y;

            for (x = startX; x <= endX; x++)
            {
                for (y = startY; y <= endY; y++)
                {
                    if (fillArea[x, y])
                    {
                        double noise = TerrainUtil.PerlinNoise2D((double)x / map.Width, (double)y / map.Height, 8, 1.0);
                        map[x, y] += noise * strength;
                    }
                }
            }
        }
Beispiel #9
0
        public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
        {
            int x;

            for (x = 0; x < map.Width; x++)
            {
                int y;
                for (y = 0; y < map.Height; y++)
                {
                    if (fillArea[x, y])
                    {
                        double noise = TerrainUtil.PerlinNoise2D((double)x / map.Width, (double)y / map.Height, 8, 1.0);

                        map[x, y] += noise * strength;
                    }
                }
            }
        }
Beispiel #10
0
        public void RunEffect(ITerrainChannel map)
        {
            ITerrainPaintableEffect eroder = new WeatherSphere();

            bool[,] cliffMask   = new bool[map.Width, map.Height];
            bool[,] channelMask = new bool[map.Width, map.Height];
            bool[,] smoothMask  = new bool[map.Width, map.Height];
            bool[,] allowMask   = new bool[map.Width, map.Height];

            m_log.Info("S1");

            // Step one, generate rough mask
            int x, y;

            for (x = 0; x < map.Width; x++)
            {
                for (y = 0; y < map.Height; y++)
                {
                    m_log.Info(".");
                    smoothMask[x, y] = true;
                    allowMask[x, y]  = true;

                    // Start underwater
                    map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 5;
                    // Add a little height. (terrain should now be above water, mostly.)
                    map[x, y] += 20;

                    const int channelsX     = 4;
                    int       channelWidth  = (map.Width / channelsX / 4);
                    const int channelsY     = 4;
                    int       channelHeight = (map.Height / channelsY / 4);

                    SetLowerChannel(map, cliffMask, channelMask, x, y, channelsX, channelWidth, map.Width, x);
                    SetLowerChannel(map, cliffMask, channelMask, x, y, channelsY, channelHeight, map.Height, y);
                }
            }

            m_log.Info("S2");
            //smooth.FloodEffect(map, smoothMask, 4.0);

            m_log.Info("S3");
            for (x = 0; x < map.Width; x++)
            {
                for (y = 0; y < map.Height; y++)
                {
                    if (cliffMask[x, y])
                    {
                        eroder.PaintEffect(map, allowMask, x, y, -1, 4, 0.1);
                    }
                }
            }

            for (x = 0; x < map.Width; x += 2)
            {
                for (y = 0; y < map.Height; y += 2)
                {
                    if (map[x, y] < 0.1)
                    {
                        map[x, y] = 0.1;
                    }
                    if (map[x, y] > 256)
                    {
                        map[x, y] = 256;
                    }
                }
            }
            //smooth.FloodEffect(map, smoothMask, 4.0);
        }