natiny_mesh_capsule
C
NatinyMesh natiny_mesh_capsule(float radius, float height, uint32_t segments, uint32_t rings);
Builds a one-part capsule standing upright along Y and centred on the origin:
a cylindrical side closed by a hemisphere at each end. The generated mesh has
normals and UV coordinates but no texture.
Parameters
| Name |
Type |
Description |
radius |
float |
Radius of the side and of both hemispheres; negative values are clamped to 0 |
height |
float |
Total height end to end, hemispheres included |
segments |
uint32_t |
Meridians - the detail around the Y axis; clamped up to 3 |
rings |
uint32_t |
Rings per hemisphere - the detail from equator to pole; clamped up to 1 |
Returns
| Type |
Description |
NatinyMesh |
Mesh handle |
Example
C
NatinyMesh capsule = natiny_mesh_capsule(0.4f, 1.8f, 32, 8);
NatinyModel player = natiny_model_create();
natiny_model_set_mesh(player, capsule);
Notes
height is the whole shape, so the cylindrical side is height - 2 * radius
tall and the mesh spans -height / 2 to +height / 2 along Y.
- A
height at or below 2 * radius produces a sphere: the side is clamped to
zero height rather than inverted, and the band that would draw it is skipped.
rings counts the rings of one hemisphere, so a capsule at rings = 8 has
the same cap detail as natiny_mesh_sphere at rings = 16.
- UVs wrap once around Y in
u, and v runs from the +Y pole to -Y
proportionally to arc length, so a long side is not stretched against the
caps. Normals point outward.
natiny_physics_capsule takes the same radius
and height and produces a collider that lines up with this mesh.