当前位置: 首页>>代码示例>>C#>>正文


C# Octree.Add方法代码示例

本文整理汇总了C#中Octree.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Octree.Add方法的具体用法?C# Octree.Add怎么用?C# Octree.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Octree的用法示例。


在下文中一共展示了Octree.Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Generate

        public static Octree<Volume> Generate( int width, int depth )
        {
            Octree<Volume> octree = new Octree<Volume>(new Volume(new Vector3(0,0,0), new Vector3(width, 64, depth), new Color()), Volume.AddHandler, Volume.RemoveHandler, Volume.SearchHandler, Volume.SetRootHandler, Volume.RemoveAllHandler);

            List<Vector3> coords = new List<Vector3>();
            int hills = rand.Next(10);
            int height = 0;
            for (int i = 0; i < hills; i++)
            {
                coords.Add( new Vector3( rand.Next(width), 0, rand.Next(depth)));
            }
            System.Drawing.Color c = System.Drawing.Color.LawnGreen;
            int r, g, b;
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < depth; j++)
                {
                    octree.Add(
                                new Volume(
                                new Vector3(i, 0, j),
                                new Vector3(1, 1, 1),
                                new Color(c.R, c.G, c.B))
                                );
                }
            }
            foreach (Vector3 coord in coords)
            {
                for (int x = -10; x < 10; x++)
                {
                    for (int z = -10; z < 10; z++)
                    {
                        c = System.Drawing.Color.LawnGreen;
                        r = (int)(0.1f * (float)height * (int)c.R);
                        g = (int)c.G;
                        b = (int)(0.1f * (float)height * (int)c.B);

                        if (r > 255) r = 255; if (g > 255) g = 255; if (b > 255) b = 255;
                        height = Math.Min(20 - Math.Abs(z), 20 - Math.Abs(x));
                        c = System.Drawing.Color.FromArgb(r, g, b);
                        octree.Add(
                            new Volume(
                            new Vector3(coord.X + x, height, coord.Z + z),
                            new Vector3(1, 1, 1),
                            new Color(c.R, c.G, c.B))
                            );
                    }
                }
            }

            return octree;
        }
开发者ID:asarudick,项目名称:Soapvox,代码行数:51,代码来源:TerrainGenerator.cs


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