62 lines
1.9 KiB
C
62 lines
1.9 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 PLANE_VERTEX_COUNT 6
|
|
#define PLANE_PRIMITIVE_TYPE MESH_PRIMITIVE_TYPE_TRIANGLES
|
|
|
|
/** Which axis the plane's normal points along. */
|
|
typedef enum {
|
|
PLANE_AXIS_XY = 0, /**< Flat in XY, normal along +Z (billboard/wall face). */
|
|
PLANE_AXIS_XZ = 1, /**< Flat in XZ, normal along +Y (ground/floor plane). */
|
|
PLANE_AXIS_YZ = 2, /**< Flat in YZ, normal along +X (side wall). */
|
|
} planeaxis_t;
|
|
|
|
extern mesh_t PLANE_MESH_SIMPLE;
|
|
extern meshvertex_t PLANE_MESH_SIMPLE_VERTICES[PLANE_VERTEX_COUNT];
|
|
|
|
/**
|
|
* Initializes the simple unit XZ plane mesh (ground plane) from (0,0,0) to
|
|
* (1,0,1).
|
|
*
|
|
* @return Error for initialization of the plane mesh.
|
|
*/
|
|
errorret_t planeInit();
|
|
|
|
/**
|
|
* Buffers an axis-aligned plane into the provided vertex array.
|
|
* Writes PLANE_VERTEX_COUNT (6) vertices (two triangles, CCW winding).
|
|
*
|
|
* The min/max corners fully describe the plane in 3D space. The axis enum
|
|
* controls which dimension is treated as the "depth" (normal) axis:
|
|
* PLANE_AXIS_XY: spans X and Y, depth from min[2]/max[2] (uses min[2])
|
|
* PLANE_AXIS_XZ: spans X and Z, depth from min[1]/max[1] (uses min[1])
|
|
* PLANE_AXIS_YZ: spans Y and Z, depth from min[0]/max[0] (uses min[0])
|
|
*
|
|
* @param vertices Vertex array to write into (must hold PLANE_VERTEX_COUNT).
|
|
* @param axis Which axis the plane's normal points along.
|
|
* @param min Minimum XYZ corner.
|
|
* @param max Maximum XYZ corner.
|
|
* @param color Color applied to all vertices.
|
|
* @param uvMin Minimum UV coordinates.
|
|
* @param uvMax Maximum UV coordinates.
|
|
*/
|
|
void planeBuffer(
|
|
meshvertex_t *vertices,
|
|
const planeaxis_t axis,
|
|
const vec3 min,
|
|
const vec3 max
|
|
#if MESH_ENABLE_COLOR
|
|
, const color_t color
|
|
#endif
|
|
, const vec2 uvMin,
|
|
const vec2 uvMax
|
|
);
|