53 lines
1.6 KiB
C
53 lines
1.6 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "display/mesh/mesh.h"
|
|
#include "display/color.h"
|
|
|
|
#define CAPSULE_CAP_RINGS 4
|
|
#define CAPSULE_SECTORS 16
|
|
#define CAPSULE_VERTEX_COUNT ((2 * CAPSULE_CAP_RINGS + 1) * CAPSULE_SECTORS * 6)
|
|
#define CAPSULE_PRIMITIVE_TYPE MESH_PRIMITIVE_TYPE_TRIANGLES
|
|
|
|
extern mesh_t CAPSULE_MESH_SIMPLE;
|
|
extern meshvertex_t CAPSULE_MESH_SIMPLE_VERTICES[CAPSULE_VERTEX_COUNT];
|
|
|
|
/**
|
|
* Initializes the simple unit capsule mesh centered at (0,0,0) with radius 0.5
|
|
* and a cylindrical half-height of 0.5 (total height 2.0).
|
|
*
|
|
* @return Error for initialization of the capsule mesh.
|
|
*/
|
|
errorret_t capsuleInit();
|
|
|
|
/**
|
|
* Buffers a capsule (cylinder + two hemisphere caps) into the provided vertex
|
|
* array. The capsule's long axis is Y. Total vertex count is
|
|
* (2*capRings + 1) * sectors * 6.
|
|
*
|
|
* @param vertices Vertex array to write into.
|
|
* @param center Center position of the capsule.
|
|
* @param radius Radius of the cylinder and hemisphere caps.
|
|
* @param halfHeight Half the height of the cylindrical section only (caps
|
|
* extend an additional radius above/below).
|
|
* @param capRings Number of latitude rings per hemisphere cap.
|
|
* @param sectors Number of longitude segments around the circumference.
|
|
* @param color Color applied to all vertices.
|
|
*/
|
|
void capsuleBuffer(
|
|
meshvertex_t *vertices,
|
|
const vec3 center,
|
|
const float_t radius,
|
|
const float_t halfHeight,
|
|
const int32_t capRings,
|
|
const int32_t sectors
|
|
#if MESH_ENABLE_COLOR
|
|
, const color_t color
|
|
#endif
|
|
);
|