本文整理汇总了C#中Microsoft.Xna.Framework.Vector2.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.Clone方法的具体用法?C# Vector2.Clone怎么用?C# Vector2.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Vector2
的用法示例。
在下文中一共展示了Vector2.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Triangulate
/// <summary>
/// Triangulates a 2D polygon produced the indexes required to render the points as a triangle list.
/// </summary>
/// <param name="inputVertices">The polygon vertices in counter-clockwise winding order.</param>
/// <param name="desiredWindingOrder">The desired output winding order.</param>
/// <param name="outputVertices">The resulting vertices that include any reversals of winding order and holes.</param>
/// <param name="indices">The resulting indices for rendering the shape as a triangle list.</param>
public static void Triangulate(
Vector2[] inputVertices,
WindingOrder desiredWindingOrder,
out Vector2[] outputVertices,
out int[] indices)
{
List<Triangle> triangles = new List<Triangle>();
//make sure we have our vertices wound properly
if (DetermineWindingOrder(inputVertices) == WindingOrder.Clockwise)
outputVertices = ReverseWindingOrder(inputVertices);
else
outputVertices = (Vector2[])inputVertices.Clone();
//clear all of the lists
polygonVertices.Clear();
earVertices.Clear();
convexVertices.Clear();
reflexVertices.Clear();
//generate the cyclical list of vertices in the polygon
for (int i = 0; i < outputVertices.Length; i++)
polygonVertices.AddLast(new Vertex(outputVertices[i], i));
//categorize all of the vertices as convex, reflex, and ear
FindConvexAndReflexVertices();
FindEarVertices();
//clip all the ear vertices
while (polygonVertices.Count > 3 && earVertices.Count > 0)
ClipNextEar(triangles);
//if there are still three points, use that for the last triangle
if (polygonVertices.Count == 3)
triangles.Add(new Triangle(
polygonVertices[0].Value,
polygonVertices[1].Value,
polygonVertices[2].Value));
//add all of the triangle indices to the output array
indices = new int[triangles.Count * 3];
//move the if statement out of the loop to prevent all the
//redundant comparisons
if (desiredWindingOrder == WindingOrder.CounterClockwise)
{
for (int i = 0; i < triangles.Count; i++)
{
indices[(i * 3)] = triangles[i].A.Index;
indices[(i * 3) + 1] = triangles[i].B.Index;
indices[(i * 3) + 2] = triangles[i].C.Index;
}
}
else
{
for (int i = 0; i < triangles.Count; i++)
{
indices[(i * 3)] = triangles[i].C.Index;
indices[(i * 3) + 1] = triangles[i].B.Index;
indices[(i * 3) + 2] = triangles[i].A.Index;
}
}
}