Shape¶
-
struct nvShape¶
Collision shape.
Do not initialize manually. Use shape creation functions.
Enums¶
Methods¶
-
nvShape *nvCircleShape_new(nvVector2 center, nv_float radius)¶
Create a new circle shape.
Returns
NULLon error. Use nv_get_error to get more information.- Parameters:
center – Center position relative to body position
radius – Radius
- Returns:
nvShape *
-
nvShape *nvPolygonShape_new(nvVector2 *vertices, size_t num_vertices, nvVector2 offset)¶
Create a new convex polygon shape.
Returns
NULLon error. Use nv_get_error to get more information.- Parameters:
vertices – Array of vertices
offset – Offset to centroid
- Returns:
nvShape *
-
nvShape *nvRectShape_new(nv_float width, nv_float height, nvVector2 offset)¶
Create a new polygon shape that is a rectangle.
Returns
NULLon error. Use nv_get_error to get more information.- Parameters:
width – Width
height – Height
offset – Offset to centroid
- Returns:
nvShape *
-
nvBoxShape_new(width, height, offset)¶
Create a new polygon shape that is a rectangle.
Returns
NULLon error. Use nv_get_error to get more information.- Parameters:
width – Width
height – Height
offset – Offset to centroid
- Returns:
nvShape *
-
nvShape *nvNGonShape_new(size_t n, nv_float radius, nvVector2 offset)¶
Create a new polygon shape that is a regular n-gon.
Returns
NULLon error. Use nv_get_error to get more information.- Parameters:
n – Number of vertices or edges
radius – Length of a vertex from the centroid
offset – Offset to centroid
- Returns:
nvShape *
-
nvShape *nvConvexHullShape_new(nvVector2 *points, size_t num_points, nvVector2 offset, nv_bool center)¶
Create a new polygon shape from a convex hull of an array of points.
Returns
NULLon error. Use nv_get_error to get more information.- Parameters:
points – Points to generate a convex hull from
num_points – Number of points
offset – Offset to centroid
bool – Transform hull so the centroid is at origin?
- Returns:
nvShape *
-
void nvShape_free(nvShape *shape)¶
Free shape.
It’s safe to pass
NULLto this function.- Parameters:
shape – Shape
-
nvAABB nvShape_get_aabb(nvShape *shape, nvTransform xform)¶
Get AABB of shape.
- Parameters:
shape – Shape
xform – Shape transform
- Returns:
-
nvShapeMassInfo nvShape_calculate_mass(nvShape *shape, nv_float density)¶
Calculate mass information of shape.
Returns a struct filled with -1 on error. Use nv_get_error to get more information.
- Parameters:
shape – Shape
- Returns:
nvShapeMassInfo