C# 클래스 Nez.PhysicsShapes.Polygon

상속: Shape
파일 보기 프로젝트 열기: prime31/Nez 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
_edgeNormals Vector2[]
isUnrotated bool
points Vector2[]

보호된 프로퍼티들

프로퍼티 타입 설명
_originalPoints Vector2[]

공개 메소드들

메소드 설명
Polygon ( Vector2 points ) : System

constructs a Polygon from points. points should be specified in clockwise fashion without duplicating the first/last point and they should be centered around 0,0.

Polygon ( int vertCount, float radius ) : System

creates a symmetrical polygon based on the radius and vertCount passed in

buildEdgeNormals ( ) : void

builds the Polygon edge normals. These are lazily created and updated only by the edgeNormals getter

buildSymmetricalPolygon ( int vertCount, float radius ) : Vector2[]

builds a symmetrical polygon (hexagon, octogon, n-gon) and returns the points

collidesWithLine ( Vector2 start, Vector2 end, RaycastHit &hit ) : bool
collidesWithShape ( Shape other, CollisionResult &result ) : bool
containsPoint ( Vector2 point ) : bool

essentially what the algorithm is doing is shooting a ray from point out. If it intersects an odd number of polygon sides we know it is inside the polygon.

findPolygonCenter ( Vector2 points ) : Vector2

finds the center of the Polygon. Note that this will be accurate for regular polygons. Irregular polygons have no center.

getClosestPointOnPolygonToPoint ( Vector2 points, Vector2 point, float &distanceSquared, Vector2 &edgeNormal ) : Vector2

iterates all the edges of the polygon and gets the closest point on any edge to point. Returns via out the squared distance to the closest point and the normal of the edge it is on. point should be in the space of the Polygon (point - poly.position)

getFarthestPointInDirection ( Vector2 points, Vector2 direction ) : Vector2
overlaps ( Shape other ) : bool
pointCollidesWithShape ( Vector2 point, CollisionResult &result ) : bool
recalculateCenterAndEdgeNormals ( ) : void

recalculates the Polygon centers. This must be called if the points are changed!

recenterPolygonVerts ( Vector2 points ) : void

recenters the points of the polygon

비공개 메소드들

메소드 설명
Polygon ( Vector2 points, bool isBox ) : System
recalculateBounds ( Collider collider ) : void

메소드 상세

Polygon() 공개 메소드

constructs a Polygon from points. points should be specified in clockwise fashion without duplicating the first/last point and they should be centered around 0,0.
public Polygon ( Vector2 points ) : System
points Vector2 Points.
리턴 System

Polygon() 공개 메소드

creates a symmetrical polygon based on the radius and vertCount passed in
public Polygon ( int vertCount, float radius ) : System
vertCount int Vert count.
radius float Radius.
리턴 System

buildEdgeNormals() 공개 메소드

builds the Polygon edge normals. These are lazily created and updated only by the edgeNormals getter
public buildEdgeNormals ( ) : void
리턴 void

buildSymmetricalPolygon() 공개 정적인 메소드

builds a symmetrical polygon (hexagon, octogon, n-gon) and returns the points
public static buildSymmetricalPolygon ( int vertCount, float radius ) : Vector2[]
vertCount int Vert count.
radius float Radius.
리턴 Vector2[]

collidesWithLine() 공개 메소드

public collidesWithLine ( Vector2 start, Vector2 end, RaycastHit &hit ) : bool
start Vector2
end Vector2
hit RaycastHit
리턴 bool

collidesWithShape() 공개 메소드

public collidesWithShape ( Shape other, CollisionResult &result ) : bool
other Shape
result CollisionResult
리턴 bool

containsPoint() 공개 메소드

essentially what the algorithm is doing is shooting a ray from point out. If it intersects an odd number of polygon sides we know it is inside the polygon.
public containsPoint ( Vector2 point ) : bool
point Vector2 Point.
리턴 bool

findPolygonCenter() 공개 정적인 메소드

finds the center of the Polygon. Note that this will be accurate for regular polygons. Irregular polygons have no center.
public static findPolygonCenter ( Vector2 points ) : Vector2
points Vector2 Points.
리턴 Vector2

getClosestPointOnPolygonToPoint() 공개 정적인 메소드

iterates all the edges of the polygon and gets the closest point on any edge to point. Returns via out the squared distance to the closest point and the normal of the edge it is on. point should be in the space of the Polygon (point - poly.position)
public static getClosestPointOnPolygonToPoint ( Vector2 points, Vector2 point, float &distanceSquared, Vector2 &edgeNormal ) : Vector2
points Vector2
point Vector2 Point.
distanceSquared float Distance squared.
edgeNormal Vector2 Edge normal.
리턴 Vector2

getFarthestPointInDirection() 공개 정적인 메소드

public static getFarthestPointInDirection ( Vector2 points, Vector2 direction ) : Vector2
points Vector2
direction Vector2
리턴 Vector2

overlaps() 공개 메소드

public overlaps ( Shape other ) : bool
other Shape
리턴 bool

pointCollidesWithShape() 공개 메소드

public pointCollidesWithShape ( Vector2 point, CollisionResult &result ) : bool
point Vector2
result CollisionResult
리턴 bool

recalculateCenterAndEdgeNormals() 공개 메소드

recalculates the Polygon centers. This must be called if the points are changed!
public recalculateCenterAndEdgeNormals ( ) : void
리턴 void

recenterPolygonVerts() 공개 정적인 메소드

recenters the points of the polygon
public static recenterPolygonVerts ( Vector2 points ) : void
points Vector2 Points.
리턴 void

프로퍼티 상세

_edgeNormals 공개적으로 프로퍼티

public Vector2[] _edgeNormals
리턴 Vector2[]

_originalPoints 보호되어 있는 프로퍼티

protected Vector2[] _originalPoints
리턴 Vector2[]

isUnrotated 공개적으로 프로퍼티

public bool isUnrotated
리턴 bool

points 공개적으로 프로퍼티

the points that make up the Polygon. They should be CCW and convex.
public Vector2[] points
리턴 Vector2[]