Donate Donating to nape helps push me to keep on making it better!
Index | Donators | Forums | Project Page
Loading
nape.shape.Polygon class
Top | Properties | Constructor | Methods | Statics

Package nape.shape
Class Polygon
Inheritance Polygon -> Shape -> Interactor

Convex, simple polygon. Winding is not important.

You will be given errors should you try to simulate an invalid polygon (through a call to space.step() when space contains a rigid body with an invalid polygon).



Public Properties
Property Defined By
localVerts : Vec2List
[read-only] Mutable vertex list
Polygon
worldVerts : Vec2List
[read-only] Immutable vertex list
Polygon
edges : EdgeList
[read-only] Immutable edge list
Polygon

Constructor
Constructor
new(localVerts:CompatiblePolygon, ?material:Material, ?material:Material, ?filter:InteractionFilter)
Construct a new Polygon

Public Methods
Method Defined By
const validity() : ValidationResult
Whether polygon is valid for simulation
Polygon

Public Static Methods
Method Defined By
static copy(polygon:const Polygon) : Polygon
Deep* copy of polygon
Polygon

 
static rect(x:Float, y:Float, width:Float, height:Float, ?weak:Bool=false) : Array<Vec2>
Vertex list for rectangle
Polygon
static box(width:Float, height:Float, ?weak:Bool=false) : Array<Vec2>
Vertex list for aligned box
Polygon
static regular(width:Float, height:Float, edgeCount:Int, ?angleOffset:Float=0.0, ?weak:Bool=false) : Array<Vec2>
Vertex list for regular aligned polygon
Polygon

Property Detail
localVerts property
readonly property localVerts : Vec2List

Vertex list for polygon in local coordinates


worldVerts property
readonly property worldVerts : Vec2List

Immutable vertex list for polygon in world coordinates. Will give errors when Polygon is not within a rigid Body.


edges property
readonly property edges : EdgeList

Immutable list of edge data. Edge at index 'n' corresponding to vertices 'n' and 'n+1' with wrap-around.


Constructor Detail
function new(localVerts:CompatiblePolygon, ?material:Material, ?material:Material, ?filter:InteractionFilter)

Construct Polygon with given local vertices, the Vec2 values will be copied on instantiation so that the same list of Vec2s can be used without explicit copying.

● material defaults to new Material()
● filter defaults to new InteractionFilter()

Error if:
X   localVerts contains null entries


Method Detail
validity method
const function validity() : ValidationResult

If you're unsure of the validity of a polygon which would give errors on an attempt to simulate, this method can be used to check for validity and what is wrong if it is not valid.


Static Method Detail
copy static method
static function copy(polygon:const Polygon) : Polygon



Error if:
X    polygon==null

See Also


rect static method
static function rect(x:Float, y:Float, width:Float, height:Float, ?weak:Bool=false) : Array<Vec2>

Vertex list for rectangle. If weak=true, then the Vec2's will be weak


box static method
static function box(width:Float, height:Float, ?weak:Bool=false) : Array<Vec2>

Vertex list for a box aligned at the origin. If weak=true, then the Vec2's will be weak


regular static method
static function regular(width:Float, height:Float, edgeCount:Int, ?angleOffset:Float=0.0, ?weak:Bool=false) : Array<Vec2>

Vertex list for a regular polygon aligned at the origin with vertices starting from an angle of angleOffset. If weak=true, then the Vec2's will be weak