newton.utils.create_capsule_mesh#

newton.utils.create_capsule_mesh(radius, half_height, up_axis=1, segments=default_num_segments)[source]#

Create a capsule (pill-shaped) mesh with hemispherical ends.

Generates vertices and triangle indices for a capsule shape consisting of a cylinder with hemispherical caps at both ends.

Parameters:
  • radius (float) – Radius of the capsule.

  • half_height (float) – Half the height of the cylindrical portion (distance from center to hemisphere start).

  • up_axis (int) – Axis along which the capsule extends (0=X, 1=Y, 2=Z). Defaults to 1 (Y-axis).

  • segments (int) – Number of segments for tessellation. Defaults to default_num_segments.

Returns:

A tuple containing:
  • vertices (np.ndarray): Float32 array of shape (N, 8) where each vertex contains [x, y, z, nx, ny, nz, u, v] (position, normal, UV coords).

  • indices (np.ndarray): Uint32 array of triangle indices for rendering.

Return type:

tuple[np.ndarray, np.ndarray]