Libraries.Game.Collision.Shapes.Polygon Documentation
This class extends the CollisionShape2D by rewritting specific actions that are blueprint actions in CollisionShape2D for the shape of a polygon. This class records all of the geometric properties that a polygon should have. To display the polygon with the properties that you've set, you have to use "Libraries.Game.Graphics.Drawable".
Inherits from: Libraries.Game.Collision.Shapes.CollisionShape2D, Libraries.Language.Object
Summary
Variable Summary Table
Variables | Description |
---|---|
integer MAXIMUM_POLYGON_VERTICES |
Actions Summary Table
Actions | Description |
---|---|
Centroid(Libraries.Game.Collision.PhysicsPosition2D transform) | This action returns the centroid of the polygon in the global coordinates. |
Compare(Libraries.Language.Object object) | This action compares two object hash codes and returns an integer. |
ComputeArea() | This action computes the area of the polygon based on the geometry of the polygon that is stored inside this Polygon class. |
ComputeBoundingBox(Libraries.Game.Collision.BoundingBox2D boundingBox, Libraries.Game.Collision.PhysicsPosition2D transform, integer childIndex) | This action calculates the BoundingBox2D for the polygon shape. |
ComputeCentroid(Libraries.Containers.Array<Libraries.Compute.Vector2> vectors, integer count) | This action finds the centroid of the polygon based on the geometry of the polygon. |
ComputeDistance(Libraries.Game.Collision.PhysicsPosition2D transform, Libraries.Compute.Vector2 point, integer childIndex, Libraries.Compute.Vector2 normalOut) | This action finds the closest distance between the point of interest and the polygon. |
ComputeMass(Libraries.Game.Physics.Mass2D mass, number density) | This action finds ths mass and mass rotational of inertia of the polygon based on the density of the polygon passed in and the geometry of the polygon. |
Copy() | This action sets another polygon shape using the current polygon shape. |
Equals(Libraries.Language.Object object) | This action determines if two objects are equal based on their hash code values. |
GetCentroid() | This action returns the centroid of the polygon in the local coordinates of that polygon. |
GetChildCount() | Because each polygon can be seen as an primitive shape, therefore, a polygon is its own child and parent. |
GetHashCode() | This action gets the hash code for an object. |
GetNormals() | This action returns all of the normals to the edges of the current polygon. |
GetRadius() | This action returns the radius of the shape. |
GetType() | This action gets the type of the shape that is used to collide with another 2D shape. |
GetVertex(integer index) | This action gets the point at which the vertex of interest is at. |
GetVertexCount() | This action returns how many vertices the polygon has. |
GetVertices() | This action returns all of the vertices of the current polygon. |
IsBox() | This action returns whether the polygon is a box or not. |
Scale(number scaleX, number scaleY) | This action shrinks or expands the polygon shape. |
Set(Libraries.Containers.Array<Libraries.Compute.Vector2> passedVertices, integer count) | This action records the passed vertices to this class and also calculate the normal vectors to the edges from the polygon created using the vertices passed. |
SetAsBox(number width, number height) | This action sets the polygon shape to an untilted box centered at the origin. |
SetAsBox(number width, number height, Libraries.Compute.Vector2 center, number angle) | This action creates a polygon as a rectangle with present center point and tilted angle. |
SetRadius(number radius) | This action sets the radius of the shape. |
SetType(integer type) | This action sets the type of the shape that will be used to collide with another 2D shape. |
TestPoint(Libraries.Game.Collision.PhysicsPosition2D transform, Libraries.Compute.Vector2 point) | |
Validate() | This action checks whether the polygon is convex. |
Actions Documentation
Centroid(Libraries.Game.Collision.PhysicsPosition2D transform)
This action returns the centroid of the polygon in the global coordinates.
Parameters
Return
Compare(Libraries.Language.Object object)
This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.
Example Code
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
Parameters
- Libraries.Language.Object: The object to compare to.
Return
integer: The Compare result, Smaller, Equal, or Larger.
ComputeArea()
This action computes the area of the polygon based on the geometry of the polygon that is stored inside this Polygon class.
Return
number:
ComputeBoundingBox(Libraries.Game.Collision.BoundingBox2D boundingBox, Libraries.Game.Collision.PhysicsPosition2D transform, integer childIndex)
This action calculates the BoundingBox2D for the polygon shape.
Parameters
ComputeCentroid(Libraries.Containers.Array<Libraries.Compute.Vector2> vectors, integer count)
This action finds the centroid of the polygon based on the geometry of the polygon.
Parameters
Return
ComputeDistance(Libraries.Game.Collision.PhysicsPosition2D transform, Libraries.Compute.Vector2 point, integer childIndex, Libraries.Compute.Vector2 normalOut)
This action finds the closest distance between the point of interest and the polygon.
Parameters
Return
number:
ComputeMass(Libraries.Game.Physics.Mass2D mass, number density)
This action finds ths mass and mass rotational of inertia of the polygon based on the density of the polygon passed in and the geometry of the polygon.
Parameters
Copy()
This action sets another polygon shape using the current polygon shape.
Return
Libraries.Game.Collision.Shapes.CollisionShape2D:
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Example Code
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
GetCentroid()
This action returns the centroid of the polygon in the local coordinates of that polygon.
Return
GetChildCount()
Because each polygon can be seen as an primitive shape, therefore, a polygon is its own child and parent.
Return
integer:
GetHashCode()
This action gets the hash code for an object.
Example Code
Object o
integer hash = o:GetHashCode()
Return
integer: The integer hash code of the object.
GetNormals()
This action returns all of the normals to the edges of the current polygon.
Return
GetRadius()
This action returns the radius of the shape.
Return
number:
GetType()
This action gets the type of the shape that is used to collide with another 2D shape.
Return
integer:
GetVertex(integer index)
This action gets the point at which the vertex of interest is at.
Parameters
Return
GetVertexCount()
This action returns how many vertices the polygon has.
Return
integer:
GetVertices()
This action returns all of the vertices of the current polygon.
Return
IsBox()
This action returns whether the polygon is a box or not.
Return
boolean:
Scale(number scaleX, number scaleY)
This action shrinks or expands the polygon shape.
Parameters
Set(Libraries.Containers.Array<Libraries.Compute.Vector2> passedVertices, integer count)
This action records the passed vertices to this class and also calculate the normal vectors to the edges from the polygon created using the vertices passed.
Parameters
SetAsBox(number width, number height)
This action sets the polygon shape to an untilted box centered at the origin.
Parameters
SetAsBox(number width, number height, Libraries.Compute.Vector2 center, number angle)
This action creates a polygon as a rectangle with present center point and tilted angle.
Parameters
SetRadius(number radius)
This action sets the radius of the shape.
Parameters
SetType(integer type)
This action sets the type of the shape that will be used to collide with another 2D shape.
Parameters
TestPoint(Libraries.Game.Collision.PhysicsPosition2D transform, Libraries.Compute.Vector2 point)
Parameters
- Libraries.Game.Collision.PhysicsPosition2D
- Libraries.Compute.Vector2: The point of interest in global coordinates.
Return
boolean:
Validate()
This action checks whether the polygon is convex.
Return
boolean: