C# Class Danmaku_no_Kyojin.Triangulator.Triangulator

A static class exposing methods for triangulating 2D polygons. This is the sole public class in the entire library; all other classes/structures are intended as internal-only objects used only to assist in triangulation. This class makes use of the DEBUG conditional and produces quite verbose output when built in Debug mode. This is quite useful for debugging purposes, but can slow the process down quite a bit. For optimal performance, build the library in Release mode. The triangulation is also not optimized for garbage sensitive processing. The point of the library is a robust, yet simple, system for triangulating 2D shapes. It is intended to be used as part of your content pipeline or at load-time. It is not something you want to be using each and every frame unless you really don't care about garbage.
显示文件 Open project: Noxalus/Danmaku-no-Kyojin

Public Methods

Method Description
CutHoleInShape ( Vector2 shapeVerts, Vector2 holeVerts ) : Microsoft.Xna.Framework.Vector2[]

Cuts a hole into a shape.

DetermineWindingOrder ( Vector2 vertices ) : WindingOrder

Determines the winding order of a polygon given a set of vertices.

EnsureWindingOrder ( Vector2 vertices, WindingOrder windingOrder ) : Microsoft.Xna.Framework.Vector2[]

Ensures that a set of vertices are wound in a particular order, reversing them if necessary.

ReverseWindingOrder ( Vector2 vertices ) : Microsoft.Xna.Framework.Vector2[]

Reverses the winding order for a set of vertices.

Triangulate ( Vector2 inputVertices, WindingOrder desiredWindingOrder, Vector2 &outputVertices, int &indices ) : void

Triangulates a 2D polygon produced the indexes required to render the points as a triangle list.

Private Methods

Method Description
ClipNextEar ( ICollection triangles ) : void
FindConvexAndReflexVertices ( ) : void
FindEarVertices ( ) : void
IsConvex ( Vertex c ) : bool
IsEar ( Vertex c ) : bool
IsReflex ( Vertex c ) : bool
ValidateAdjacentVertex ( Vertex vertex ) : void

Method Details

CutHoleInShape() public static method

Cuts a hole into a shape.
public static CutHoleInShape ( Vector2 shapeVerts, Vector2 holeVerts ) : Microsoft.Xna.Framework.Vector2[]
shapeVerts Microsoft.Xna.Framework.Vector2 An array of vertices for the primary shape.
holeVerts Microsoft.Xna.Framework.Vector2 An array of vertices for the hole to be cut. It is assumed that these vertices lie completely within the shape verts.
return Microsoft.Xna.Framework.Vector2[]

DetermineWindingOrder() public static method

Determines the winding order of a polygon given a set of vertices.
public static DetermineWindingOrder ( Vector2 vertices ) : WindingOrder
vertices Microsoft.Xna.Framework.Vector2 The vertices of the polygon.
return WindingOrder

EnsureWindingOrder() public static method

Ensures that a set of vertices are wound in a particular order, reversing them if necessary.
public static EnsureWindingOrder ( Vector2 vertices, WindingOrder windingOrder ) : Microsoft.Xna.Framework.Vector2[]
vertices Microsoft.Xna.Framework.Vector2 The vertices of the polygon.
windingOrder WindingOrder The desired winding order.
return Microsoft.Xna.Framework.Vector2[]

ReverseWindingOrder() public static method

Reverses the winding order for a set of vertices.
public static ReverseWindingOrder ( Vector2 vertices ) : Microsoft.Xna.Framework.Vector2[]
vertices Microsoft.Xna.Framework.Vector2 The vertices of the polygon.
return Microsoft.Xna.Framework.Vector2[]

Triangulate() public static method

Triangulates a 2D polygon produced the indexes required to render the points as a triangle list.
public static Triangulate ( Vector2 inputVertices, WindingOrder desiredWindingOrder, Vector2 &outputVertices, int &indices ) : void
inputVertices Microsoft.Xna.Framework.Vector2 The polygon vertices in counter-clockwise winding order.
desiredWindingOrder WindingOrder The desired output winding order.
outputVertices Microsoft.Xna.Framework.Vector2 The resulting vertices that include any reversals of winding order and holes.
indices int The resulting indices for rendering the shape as a triangle list.
return void