• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ITerrainChannel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ITerrainChannel的典型用法代码示例。如果您正苦于以下问题:C# ITerrainChannel类的具体用法?C# ITerrainChannel怎么用?C# ITerrainChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ITerrainChannel类属于命名空间,在下文中一共展示了ITerrainChannel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FloodEffect

        public void FloodEffect (ITerrainChannel map, UUID userID, float north,
                                float west, float south, float east, float strength)
        {
            float sum = 0;
            float steps = 0;

            int x, y;
            for (x = (int)west; x < (int)east; x++) {
                for (y = (int)south; y < (int)north; y++) {
                    if (!map.Scene.Permissions.CanTerraformLand (userID, new Vector3 (x, y, 0)))
                        continue;
                    sum += map [x, y];
                    steps += 1;
                }
            }

            float avg = sum / steps;

            float str = 0.1f * strength; // == 0.2 in the default client

            for (x = (int)west; x < (int)east; x++) {
                for (y = (int)south; y < (int)north; y++) {
                    if (!map.Scene.Permissions.CanTerraformLand (userID, new Vector3 (x, y, 0)))
                        continue;
                    map [x, y] = (map [x, y] * (1 - str)) + (avg * str);
                }
            }
        }
开发者ID:Virtual-Universe,项目名称:Virtual-Universe,代码行数:28,代码来源:FlattenArea.cs


示例2: FloodEffect

        public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
            int startX, int endX, int startY, int endY)
        {
            double sum = 0.0;
            double steps = 0.0;

            int x, y;
            for (x = startX; x <= endX; x++)
            {
                for (y = startY; y <= endY; y++)
                {
                    if (fillArea[x, y])
                    {
                        sum += map[x, y];
                        steps += 1.0;
                    }
                }
            }

            double avg = sum / steps;

            double str = 0.1 * strength; // == 0.2 in the default client

            for (x = startX; x <= endX; x++)
            {
                for (y = startY; y <= endY; y++)
                {
                    if (fillArea[x, y])
                        map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str);
                }
            }
        }
开发者ID:CassieEllen,项目名称:opensim,代码行数:32,代码来源:FlattenArea.cs


示例3: GetBilinearInterpolate

        public static double GetBilinearInterpolate(double x, double y, ITerrainChannel map)
        {
            int w = map.Width;
            int h = map.Height;

            if (x > w - 2.0)
                x = w - 2.0;
            if (y > h - 2.0)
                y = h - 2.0;
            if (x < 0.0)
                x = 0.0;
            if (y < 0.0)
                y = 0.0;

            const int stepSize = 1;
            double h00 = map[(int) x, (int) y];
            double h10 = map[(int) x + stepSize, (int) y];
            double h01 = map[(int) x, (int) y + stepSize];
            double h11 = map[(int) x + stepSize, (int) y + stepSize];
            double h1 = h00;
            double h2 = h10;
            double h3 = h01;
            double h4 = h11;
            double a00 = h1;
            double a10 = h2 - h1;
            double a01 = h3 - h1;
            double a11 = h1 - h2 - h3 + h4;
            double partialx = x - (int) x;
            double partialz = y - (int) y;
            double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz);
            return hi;
        }
开发者ID:CassieEllen,项目名称:opensim,代码行数:32,代码来源:TerrainUtil.cs


示例4: FloodEffect

        public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
        {
            double sum = 0.0;
            double steps = 0.0;

            int x, y;
            for (x = 0; x < map.Width; x++)
            {
                for (y = 0; y < map.Height; y++)
                {
                    if (fillArea[x, y])
                    {
                        sum += map[x, y];
                        steps += 1.0;
                    }
                }
            }

            double avg = sum / steps;

            double str = 0.1 * strength; // == 0.2 in the default client

            for (x = 0; x < map.Width; x++)
            {
                for (y = 0; y < map.Height; y++)
                {
                    if (fillArea[x, y])
                        map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str);
                }
            }
        }
开发者ID:RadaSangOn,项目名称:workCore2,代码行数:31,代码来源:FlattenArea.cs


示例5: Compare

 public bool Compare(ITerrainChannel terrainChannel)
 {
     if (m_terrainChannel != terrainChannel)
         return false;
     else
         return false;
 }
开发者ID:QueenStarfinder,项目名称:WhiteCore-Dev,代码行数:7,代码来源:UndoState.cs


示例6: FloodEffect

        public void FloodEffect(ITerrainChannel map, UUID userID, float north,
            float west, float south, float east, float strength)
        {
            float area = strength;
            float step = strength/4;

            for (int x = (int) west; x < (int) east; x++)
            {
                for (int y = (int) south; y < (int) north; y++)
                {
                    if (!map.Scene.Permissions.CanTerraformLand(userID, new Vector3(x, y, 0)))
                        continue;

                    float average = 0;
                    int avgsteps = 0;

                    float n;
                    for (n = 0 - area; n < area; n += step)
                    {
                        float l;
                        for (l = 0 - area; l < area; l += step)
                        {
                            avgsteps++;
                            average += TerrainUtil.GetBilinearInterpolate(x + n, y + l, map);
                        }
                    }

                    map[x, y] = average/avgsteps;
                }
            }
        }
开发者ID:QueenStarfinder,项目名称:WhiteCore-Dev,代码行数:31,代码来源:SmoothArea.cs


示例7: PaintEffect

        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;
                }
            }
        }
开发者ID:CassieEllen,项目名称:opensim,代码行数:26,代码来源:NoiseSphere.cs


示例8: SaveFile

 public virtual void SaveFile(ITerrainChannel m_channel, string filename,
                      int offsetX, int offsetY,
                      int fileWidth, int fileHeight,
                      int regionSizeX, int regionSizeY)
 {
     throw new System.Exception("Not Implemented");
 }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:7,代码来源:JPEG.cs


示例9: CreateBitmapFromMap

        private static Bitmap CreateBitmapFromMap(ITerrainChannel map)
        {
            Bitmap gradientmapLd = new Bitmap("defaultstripe.png");

            int pallete = gradientmapLd.Height;

            Bitmap bmp = new Bitmap(map.Width, map.Height);
            Color[] colours = new Color[pallete];

            for (int i = 0; i < pallete; i++)
            {
                colours[i] = gradientmapLd.GetPixel(0, i);
            }

            for (int y = 0; y < map.Height; y++)
            {
                for (int x = 0; x < map.Width; x++)
                {
                    // 512 is the largest possible height before colours clamp
                    int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1));
                    bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]);
                }
            }
            return bmp;
        }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:25,代码来源:JPEG.cs


示例10: ModifyTerrain

        public override string ModifyTerrain(ITerrainChannel map, string[] args)
        {
            string result;
            if (args.Length < 3)
            {
                result = "Usage: " + GetUsage();
            }
            else
            {
                TerrainModifierData data;
                result = this.parseParameters(args, out data);

                // Context-specific validation
                if (result == String.Empty)
                {
                    if (data.shape == String.Empty)
                    {
                        data.shape = "rectangle";
                        data.x0 = 0;
                        data.y0 = 0;
                        data.dx = map.Width;
                        data.dy = map.Height;
                    }
                }

                // if it's all good, then do the work
                if (result == String.Empty)
                {
                    this.applyModification(map, data);
                }
            }

            return result;
        }
开发者ID:CassieEllen,项目名称:opensim,代码行数:34,代码来源:FillModifier.cs


示例11: PaintEffect

        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)
        {
            int s = (int) (Math.Pow(2, strength) + 0.5);

            int x, y;

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

                    // Calculate a cos-sphere and add it to the heighmap
                    double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry)));
                    double z = Math.Cos(r * Math.PI / (s * 2));
                    if (z > 0.0)
                    {
                        double newz = map[x, y] - z * duration;
                        if (newz < 0.0)
                            map[x, y] = 0.0;
                        else
                            map[x, y] = newz;
                    } 
                }
            }

        }
开发者ID:CassieEllen,项目名称:opensim,代码行数:29,代码来源:LowerSphere.cs


示例12: PaintEffect

        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;
                }
            }
        }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:25,代码来源:NoiseSphere.cs


示例13: FloodEffect

        public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
        {
            double area = strength;
            double step = strength / 4.0;

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

                    double average = 0.0;
                    int avgsteps = 0;

                    double n;
                    for (n = 0.0 - area; n < area; n += step)
                    {
                        double l;
                        for (l = 0.0 - area; l < area; l += step)
                        {
                            avgsteps++;
                            average += GetBilinearInterpolate(x + n, y + l, map);
                        }
                    }

                    map[x, y] = average / avgsteps;
                }
            }
        }
开发者ID:mugginsm,项目名称:Aurora-Sim,代码行数:31,代码来源:SmoothArea.cs


示例14: PaintEffect

        public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration, float BrushSize)
        {
            strength = TerrainUtil.MetersToSphericalStrength(BrushSize);
            duration = 0.03; //MCP Should be read from ini file
 
            if (duration > 1.0)
                duration = 1.0;
            if (duration < 0)
                return;

            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 = 0;
                    if (duration < 4.0)
                        z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * duration * 0.25;

                    if (z > 0.0)
                    {
                        map[x, y] = (map[x, y] * (1.0 - z)) + (m_revertmap[x, y] * z);
                    }
                }
            }
        }
开发者ID:shangcheng,项目名称:Aurora,代码行数:31,代码来源:RevertSphere.cs


示例15: PaintEffect

        public void PaintEffect (ITerrainChannel map, UUID userID, float rx, float ry, float rz, float strength,
                                float duration, float BrushSize)
        {
            int x;
            int xFrom = (int)(rx - BrushSize + 0.5);
            int xTo = (int)(rx + BrushSize + 0.5) + 1;
            int yFrom = (int)(ry - BrushSize + 0.5);
            int yTo = (int)(ry + BrushSize + 0.5) + 1;

            if (xFrom < 0)
                xFrom = 0;

            if (yFrom < 0)
                yFrom = 0;

            if (xTo > map.Width)
                xTo = map.Width;

            if (yTo > map.Height)
                yTo = map.Height;

            for (x = xFrom; x < xTo; x++) {
                int y;
                for (y = yFrom; y < yTo; y++) {
                    if (!map.Scene.Permissions.CanTerraformLand (userID, new Vector3 (x, y, 0)))
                        continue;

                    // Calculate a cos-sphere and add it to the heightmap
                    double r = Math.Sqrt ((x - rx) * (x - rx) + ((y - ry) * (y - ry)));
                    double z = Math.Cos (r * Math.PI / (BrushSize * 2));
                    if (z > 0.0)
                        map [x, y] += (float)(z * duration);
                }
            }
        }
开发者ID:Virtual-Universe,项目名称:Virtual-Universe,代码行数:35,代码来源:RaiseSphere.cs


示例16: BuildTiles

        private void BuildTiles(ITerrainChannel map, double height)
        {
            int channelWidth = (int) Math.Floor((map.Width / num_w) * 0.8);
            int channelHeight = (int) Math.Floor((map.Height / num_h) * 0.8);
            int channelXOffset = (map.Width / num_w) - channelWidth;
            int channelYOffset = (map.Height / num_h) - channelHeight;

            for (int x = 0; x < num_w; x++)
            {
                for (int y = 0; y < num_h; y++)
                {
                    int xoff = ((channelXOffset + channelWidth) * x) + (channelXOffset / 2);
                    int yoff = ((channelYOffset + channelHeight) * y) + (channelYOffset / 2);

                    Boolean[,] bitmap = new bool[map.Width,map.Height];

                    for (int dx = 0; dx < channelWidth; dx++)
                    {
                        for (int dy = 0; dy < channelHeight; dy++)
                        {
                            bitmap[dx + xoff, dy + yoff] = true;
                        }
                    }

                    raiseFunction.FloodEffect(map, bitmap, height);
                }
            }
        }
开发者ID:RadaSangOn,项目名称:workCore2,代码行数:28,代码来源:ChannelDigger.cs


示例17: PaintEffect

        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);
            duration = 0.03; //MCP Should be read from ini file
 
            if (duration > 1.0)
                duration = 1.0;
            if (duration < 0)
                return;

            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));

                    if (z > 0.0)
                    {
                        z *= duration;
                        map[x, y] = (map[x, y] * (1.0 - z)) + (m_revertmap[x, y] * z);
                    }
                }
            }
        }
开发者ID:CassieEllen,项目名称:opensim,代码行数:32,代码来源:RevertSphere.cs


示例18: RunEffect

        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];

            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;

                    // 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, UUID.Zero, x, y, -1, 4, 0.1f, 4, null);
                }
            }

            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);
        }
开发者ID:kf6kjg,项目名称:halcyon,代码行数:59,代码来源:CookieCutter.cs


示例19: PaintEffect

        public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
        {
            strength = TerrainUtil.MetersToSphericalStrength(strength);

            int x, y;
            double[,] tweak = new double[map.Width,map.Height];

            double area = strength;
            double step = strength / 4.0;
            duration = 0.03; //MCP Should be read from ini file

            // compute delta map
            for (x = 0; x < map.Width; x++)
            {
                for (y = 0; y < map.Height; y++)
                {
                    double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);

                    if (z > 0) // add in non-zero amount
                    {
                        double average = 0.0;
                        int avgsteps = 0;

                        double n;
                        for (n = 0.0 - area; n < area; n += step)
                        {
                            double l;
                            for (l = 0.0 - area; l < area; l += step)
                            {
                                avgsteps++;
                                average += TerrainUtil.GetBilinearInterpolate(x + n, y + l, map);
                            }
                        }
                        tweak[x, y] = average / avgsteps;
                    }
                }
            }
            // blend in map
            for (x = 0; x < map.Width; x++)
            {
                for (y = 0; y < map.Height; y++)
                {
                    if (!mask[x,y])
                        continue;

                    double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);

                    if (z > 0) // add in non-zero amount
                    {
                        double da = z;
                        double a = (map[x, y] - tweak[x, y]) * da;
                        double newz = map[x, y] - (a * duration);

                        if (newz > 0.0)
                            map[x, y] = newz;
                    }
                }
            }
        }
开发者ID:RadaSangOn,项目名称:workCore2,代码行数:59,代码来源:SmoothSphere.cs


示例20: PaintEffect

        public void PaintEffect(ITerrainChannel map, UUID userID, float rx, float ry, float rz, float strength,
                                float duration, float BrushSize)
        {
            strength = TerrainUtil.MetersToSphericalStrength(strength);

            int x;

            for (x = 0; x < map.Width; x++)
            {
                int y;
                for (y = 0; y < map.Height; y++)
                {
                    if (!map.Scene.Permissions.CanTerraformLand(userID, new Vector3(x, y, 0)))
                        continue;

                    float z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);

                    if (z > 0) // add in non-zero amount
                    {
                        const int NEIGHBOUR_ME = 4;
                        const int NEIGHBOUR_MAX = 9;

                        for (int j = 0; j < NEIGHBOUR_MAX; j++)
                        {
                            if (j != NEIGHBOUR_ME)
                            {
                                int[] coords = Neighbours(type, j);

                                coords[0] += x;
                                coords[1] += y;

                                if (coords[0] > map.Width - 1)
                                    continue;
                                if (coords[1] > map.Height - 1)
                                    continue;
                                if (coords[0] < 0)
                                    continue;
                                if (coords[1] < 0)
                                    continue;

                                float heightF = map[x, y];
                                float target = map[coords[0], coords[1]];

                                if (target > heightF + talus)
                                {
                                    float calc = duration*((target - heightF) - talus)*z;
                                    heightF += calc;
                                    target -= calc;
                                }

                                map[x, y] = heightF;
                                map[coords[0], coords[1]] = target;
                            }
                        }
                    }
                }
            }
        }
开发者ID:VirtualReality,项目名称:Universe,代码行数:58,代码来源:WeatherSphere.cs



注:本文中的ITerrainChannel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ITest类代码示例发布时间:2022-05-24
下一篇:
C# ITerminal类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap