-
-
Field Summary
Fields Modifier and Type Field Description private Array<Vec2>verticesprivate Array<Vec2>normalsprivate CollisionBodyInterfacebodyprivate Mat2orientation
-
Constructor Summary
Constructors Constructor Description Polygon(Array<Vec2> vertList)Constructor takes a supplied list of vertices and generates a convex hull around them. Polygon(Double width, Double height)Constructor to generate a rectangle. Polygon(Integer radius, Integer noOfSides)Generate a regular polygon with a specified number of sides and size.
-
Method Summary
Modifier and Type Method Description final Array<Vec2>getVertices()final UnitsetVertices(Array<Vec2> vertices)final Array<Vec2>getNormals()final UnitsetNormals(Array<Vec2> normals)final CollisionBodyInterfacegetBody()final UnitsetBody(CollisionBodyInterface body)final Mat2getOrientation()final UnitsetOrientation(Mat2 orientation)UnitcalcMass(Double density)Implementation of calculating the mass of a polygon. UnitcreateAABB()Generates an AABB encompassing the polygon and binds it to the body. BooleanisPointInside(Vec2 startPoint)Method to check if point is inside a body in world space. Shape.IntersectionReturnElementrayIntersect(Vec2 startPoint, Vec2 endPoint, Double maxDistance, Double rayLength)Checks if a ray intersects with the shape. -
-
Constructor Detail
-
Polygon
Polygon(Array<Vec2> vertList)
Constructor takes a supplied list of vertices and generates a convex hull around them.- Parameters:
vertList- Vertices of polygon to create.
-
Polygon
Polygon(Double width, Double height)
Constructor to generate a rectangle.- Parameters:
width- Desired width of rectangleheight- Desired height of rectangle
-
-
Method Detail
-
getVertices
final Array<Vec2> getVertices()
-
setVertices
final Unit setVertices(Array<Vec2> vertices)
-
getNormals
final Array<Vec2> getNormals()
-
setNormals
final Unit setNormals(Array<Vec2> normals)
-
getBody
final CollisionBodyInterface getBody()
-
setBody
final Unit setBody(CollisionBodyInterface body)
-
getOrientation
final Mat2 getOrientation()
-
setOrientation
final Unit setOrientation(Mat2 orientation)
-
calcMass
Unit calcMass(Double density)
Implementation of calculating the mass of a polygon.
- Parameters:
density- The desired density to factor into the calculation.
-
createAABB
Unit createAABB()
Generates an AABB encompassing the polygon and binds it to the body.
-
isPointInside
Boolean isPointInside(Vec2 startPoint)
Method to check if point is inside a body in world space.
- Parameters:
startPoint- Vector point to check if its inside the first body.
-
rayIntersect
Shape.IntersectionReturnElement rayIntersect(Vec2 startPoint, Vec2 endPoint, Double maxDistance, Double rayLength)
Checks if a ray intersects with the shape.
- Parameters:
startPoint- The start point of the ray.endPoint- The end point of the ray.maxDistance- The ray information.
-
-
-
-