本文整理汇总了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;
}
示例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;
}