cubos::engine::RenderMeshVertex struct

Vertex data type stored in the RenderMeshPool's vertex buffer.

Public static functions

static auto addVertexElements(const char* position, const char* normal, const char* material, std::size_t bufferIndex, core::gl::VertexArrayDesc& desc) -> bool
Generates a vertex element description for this vertex type.
static void generate(const VoxelGrid& grid, std::vector<RenderMeshVertex>& vertices)
Generates a vertex mesh for the given voxel grid.

Public variables

glm::u8vec3 position
Vertex position within the mesh.
glm::uint8 normal
Vertex normal (0 for +X, 1 for -X, 2 for +Y, 3 for -Y, 4 for +Z, 5 for -Z).
glm::uint32 material
Vertex material.

Function documentation

static bool cubos::engine::RenderMeshVertex::addVertexElements(const char* position, const char* normal, const char* material, std::size_t bufferIndex, core::gl::VertexArrayDesc& desc)

Generates a vertex element description for this vertex type.

Parameters
position Position attribute name in the pipeline.
normal Normal attribute name in the pipeline.
material Material attribute name in the pipeline.
bufferIndex Index of the vertex buffer where the elements will be stored.
desc Vertex array description to add the elements to.
Returns Whether the vertex elements fitted in the vertex array description.

Assumes a vertex buffer stores this and only this type, as an array of ivec2, where the x component is the positionAndSize, and the colorAndNormal is the y component.

static void cubos::engine::RenderMeshVertex::generate(const VoxelGrid& grid, std::vector<RenderMeshVertex>& vertices)

Generates a vertex mesh for the given voxel grid.

Parameters
grid Voxel grid.
vertices out Vertices generated from the voxel grid.