本文整理匯總了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;
}
}
}