guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::components::Mesh Class Reference

A 3D model shown at the entity's pose: the model file and an optional texture. More...

#include <headers/guillaume/components/mesh.hpp>

Inheritance diagram for guillaume::components::Mesh:
Collaboration diagram for guillaume::components::Mesh:

Public Member Functions

 Mesh (void)=default
 Default constructor for the Mesh component.
 ~Mesh (void)=default
 Default destructor for the Mesh component.
Mesh & setMeshPath (const std::string &path)
 Choose the model to show.
Mesh & setTexturePath (const std::string &path)
 Choose the texture applied to the model.
std::string getMeshPath (void) const
 Get the path of the model file.
std::string getTexturePath (void) const
 Get the path of the texture file.
const std::optional< float > & getFitSize (void) const noexcept
 Get the size the model is scaled to.
Mesh & setFitSize (std::optional< float > size)
 Scale the model so its longest side has this length.
float scaleFor (float modelWidth, float modelHeight) const noexcept
 Get the factor that turns model units into dp.
Public Member Functions inherited from guillaume::ecs::Component
bool hasChanged (void) const
 Tell whether a value of the component changed since the flags were last reset (the end of the previous frame).
void setHasChanged (bool hasChanged)
 Raise or lower the changed flag.
 Component (void)=default
 Create a component that is not marked as changed.
virtual ~Component (void)=default
 Virtual destructor, so components can be destroyed through the base class.

Detailed Description

A 3D model shown at the entity's pose: the model file and an optional texture.

entities::Mesh (or the application) writes the two paths. systems::MeasureMesh (Measure phase) loads the model and writes the width and height of its bounding box into the entity's components::Bound. systems::MeshRender (Render phase) loads the model at the pose of the entity's components::Transform and uploads its meshes to the engine.

registry.getComponent<components::Mesh>(id)
.setMeshPath("models/chair.obj")
.setTexturePath("models/chair.png");
A 3D model shown at the entity's pose: the model file and an optional texture.
Definition mesh.hpp:57
Mesh & setTexturePath(const std::string &path)
Choose the texture applied to the model.
Definition mesh.cpp:44
Mesh & setMeshPath(const std::string &path)
Choose the model to show.
Definition mesh.cpp:29
Note
The Bound of the entity is overwritten every frame with the size of the model; setting it does not resize the model.
This class is the model file reference. The geometry type the render systems build is utility::graphic::Mesh.
See also
systems::MeasureMesh, systems::MeshRender, entities::Mesh

Definition at line 56 of file mesh.hpp.

Member Function Documentation

◆ getFitSize()

const std::optional< float > & guillaume::components::Mesh::getFitSize ( void ) const
noexcept

Get the size the model is scaled to.

Returns
The length of the model's longest side, in dp, or nothing when the model is drawn in its file's own units.

Definition at line 59 of file mesh.cpp.

◆ getMeshPath()

std::string guillaume::components::Mesh::getMeshPath ( void ) const

Get the path of the model file.

Returns
A copy of the path; empty by default.

Definition at line 39 of file mesh.cpp.

◆ getTexturePath()

std::string guillaume::components::Mesh::getTexturePath ( void ) const

Get the path of the texture file.

Returns
A copy of the path; empty (the default) when the model has no texture.

Definition at line 54 of file mesh.cpp.

◆ scaleFor()

float guillaume::components::Mesh::scaleFor ( float modelWidth,
float modelHeight ) const
noexcept

Get the factor that turns model units into dp.

Parameters
modelWidthThe model's width, in model units.
modelHeightThe model's height, in model units.
Returns
The fit size divided by the longest side, or 1 without a fit size or for an empty model.

Definition at line 73 of file mesh.cpp.

◆ setFitSize()

Mesh & guillaume::components::Mesh::setFitSize ( std::optional< float > size)

Scale the model so its longest side has this length.

Model files use arbitrary units; a fit size makes the model take a known room in a layout. Marks the component changed only when the value differs.

Parameters
sizeThe length, in dp, or nothing for the file's units.
Returns
Reference to this component for chaining.

Definition at line 64 of file mesh.cpp.

Here is the call graph for this function:

◆ setMeshPath()

Mesh & guillaume::components::Mesh::setMeshPath ( const std::string & path)

Choose the model to show.

Marks the component changed only when the path differs.

Parameters
pathThe path of the model file, as understood by the application's resource provider.
Returns
This component, for chaining.

Definition at line 29 of file mesh.cpp.

Here is the call graph for this function:

◆ setTexturePath()

Mesh & guillaume::components::Mesh::setTexturePath ( const std::string & path)

Choose the texture applied to the model.

Marks the component changed only when the path differs.

Parameters
pathThe path of the texture file; empty to draw the model with the default material.
Returns
This component, for chaining.

Definition at line 44 of file mesh.cpp.

Here is the call graph for this function:

The documentation for this class was generated from the following files: