57 lines
1.7 KiB
C
57 lines
1.7 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"
|
|
|
|
/**
|
|
* Vertex layout:
|
|
* 2 triangular end-caps (3 verts each) = 6
|
|
* 3 rectangular side faces (6 verts each) = 18
|
|
* Total = 24
|
|
*/
|
|
#define TRIPRISM_VERTEX_COUNT 24
|
|
#define TRIPRISM_PRIMITIVE_TYPE MESH_PRIMITIVE_TYPE_TRIANGLES
|
|
|
|
extern mesh_t TRIPRISM_MESH_SIMPLE;
|
|
extern meshvertex_t TRIPRISM_MESH_SIMPLE_VERTICES[TRIPRISM_VERTEX_COUNT];
|
|
|
|
/**
|
|
* Initializes the simple unit triangular prism. The cross-section triangle has
|
|
* vertices (0,0), (1,0), (0.5,1) in XY, extruded from z=0 to z=1.
|
|
*
|
|
* @return Error for initialization of the triangular prism mesh.
|
|
*/
|
|
errorret_t triPrismInit();
|
|
|
|
/**
|
|
* Buffers a triangular prism into the provided vertex array.
|
|
* The triangular cross-section is defined by three 2D points in the XY plane;
|
|
* the prism is extruded along the Z axis between minZ and maxZ.
|
|
* Writes TRIPRISM_VERTEX_COUNT (24) vertices (CCW winding).
|
|
*
|
|
* @param vertices Vertex array to write into (must hold TRIPRISM_VERTEX_COUNT).
|
|
* @param x0,y0 First triangle vertex (XY).
|
|
* @param x1,y1 Second triangle vertex (XY).
|
|
* @param x2,y2 Third triangle vertex (XY).
|
|
* @param minZ Near Z extent of the prism.
|
|
* @param maxZ Far Z extent of the prism.
|
|
* @param color Color applied to all vertices.
|
|
*/
|
|
void triPrismBuffer(
|
|
meshvertex_t *vertices,
|
|
const float_t x0, const float_t y0,
|
|
const float_t x1, const float_t y1,
|
|
const float_t x2, const float_t y2,
|
|
const float_t minZ,
|
|
const float_t maxZ
|
|
#if MESH_ENABLE_COLOR
|
|
, const color_t color
|
|
#endif
|
|
);
|