-
-
Field Summary
Fields Modifier and Type Field Description private Array<Vec2>
vertices
private Array<Vec2>
normals
private CollisionBodyInterface
body
private Mat2
orientation
-
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 Unit
setVertices(Array<Vec2> vertices)
final Array<Vec2>
getNormals()
final Unit
setNormals(Array<Vec2> normals)
final CollisionBodyInterface
getBody()
final Unit
setBody(CollisionBodyInterface body)
final Mat2
getOrientation()
final Unit
setOrientation(Mat2 orientation)
Unit
calcMass(Double density)
Implementation of calculating the mass of a polygon. Unit
createAABB()
Generates an AABB encompassing the polygon and binds it to the body. Boolean
isPointInside(Vec2 startPoint)
Method to check if point is inside a body in world space. Shape.IntersectionReturnElement
rayIntersect(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.
-
-
-
-