Mesh

template<IsSpectral TSpectral>
class Mesh : public huira::SceneObject<Mesh<TSpectral>, TSpectral>

Represents a 3D triangle mesh with vertex and index data.

Mesh stores geometry data as indexed triangles, with each triangle defined by three indices into a vertex buffer. The vertex buffer contains positions, normals, and spectral properties. Meshes are movable but not copyable.

Template Parameters:

TSpectral – The spectral representation type.

Public Functions

inline Mesh()
Mesh(IndexBuffer index_buffer, VertexBuffer<TSpectral> vertex_buffer) noexcept

Constructs a Mesh from index and vertex buffers.

Creates a new mesh by taking ownership of the provided buffers. The index buffer should contain triangle indices (groups of three) that reference vertices in the vertex buffer.

Parameters:
  • index_buffer – Buffer containing triangle vertex indices.

  • vertex_buffer – Buffer containing vertex data (positions, normals, etc.).

~Mesh() override = default
Mesh(const Mesh&) = delete
Mesh &operator=(const Mesh&) = delete
Mesh(Mesh&&) = default
Mesh &operator=(Mesh&&) = default
std::size_t index_count() const noexcept

Returns the number of indices in the mesh.

Returns:

The total number of indices (3 times the triangle count).

std::size_t vertex_count() const noexcept

Returns the number of vertices in the mesh.

Returns:

The total number of vertices in the vertex buffer.

std::size_t triangle_count() const noexcept

Returns the number of triangles in the mesh.

Returns:

The number of triangles (index count divided by 3).

const IndexBuffer &index_buffer() const noexcept

Returns a const reference to the index buffer.

Returns:

Const reference to the index buffer containing triangle indices.

const VertexBuffer<TSpectral> &vertex_buffer() const noexcept

Returns a const reference to the vertex buffer.

Returns:

Const reference to the vertex buffer containing vertex data.

inline virtual std::uint64_t id() const override

Get the object’s unique ID.

Returns:

std::uint64_t ID

inline virtual std::string type() const override

Get the object’s type string.

Returns:

std::string Type

inline bool is_scene_owned() const

Check if the object is owned by the scene.

Returns:

bool True if owned

inline void set_scene_owned(bool owned)

Set scene ownership flag.

Parameters:

owned – True if owned

inline std::string name() const

Get the object’s name.

Returns:

std::string Name

inline virtual std::string get_info() const

Get a descriptive info string for the object.

Returns:

std::string Info string