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


C# DTSweepContext.PrepareTriangulation方法代码示例

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


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

示例1: ConvexPartition

        public static List<Vertices> ConvexPartition(Vertices vertices)
        {
            Polygon poly = new Polygon();

            foreach (Vector2 vertex in vertices)
            {
                poly.Points.Add(new TriangulationPoint(vertex.X, vertex.Y));
            }

            DTSweepContext tcx = new DTSweepContext();
            tcx.PrepareTriangulation(poly);
            DTSweep.Triangulate(tcx);

            List<Vertices> results = new List<Vertices>();

            foreach (DelaunayTriangle triangle in poly.Triangles)
            {
                Vertices v = new Vertices();
                foreach (TriangulationPoint p in triangle.Points)
                {
                    v.Add(new Vector2((float)p.X, (float)p.Y));
                }
                results.Add(v);
            }

            return results;
        }
开发者ID:boris2,项目名称:mmogameproject2,代码行数:27,代码来源:CDTDecomposer.cs

示例2: ConvexPartition

        /// <summary>
        /// Decompose the polygon into several smaller non-concave polygon.
        /// </summary>
        public static List<Vertices> ConvexPartition(Vertices vertices)
        {
            if (vertices.Count <= 3)
                return new List<Vertices> { vertices };

            Polygon poly = new Polygon();

            foreach (Vector2 vertex in vertices)
                poly.Points.Add(new TriangulationPoint(vertex.X, vertex.Y));

            if (vertices.Holes != null)
            {
                foreach (Vertices holeVertices in vertices.Holes)
                {
                    Polygon hole = new Polygon();

                    foreach (Vector2 vertex in holeVertices)
                        hole.Points.Add(new TriangulationPoint(vertex.X, vertex.Y));

                    poly.AddHole(hole);
                }
            }

            DTSweepContext tcx = new DTSweepContext();
            tcx.PrepareTriangulation(poly);
            DTSweep.Triangulate(tcx);

            List<Vertices> results = new List<Vertices>();

            foreach (DelaunayTriangle triangle in poly.Triangles)
            {
                Vertices v = new Vertices();
                foreach (TriangulationPoint p in triangle.Points)
                {
                    v.Add(new Vector2((float)p.X, (float)p.Y));
                }
                results.Add(v);
            }

            return results;
        }
开发者ID:shadowmint,项目名称:pongstar,代码行数:44,代码来源:CDTDecomposer.cs


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