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

A 3D model loaded from a file, with an optional texture. More...

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

Inheritance diagram for guillaume::entities::Mesh:
Collaboration diagram for guillaume::entities::Mesh:

Classes

class  Builder
 Configures Mesh widgets and registers them in the scene's entity registry. More...

Public Member Functions

 ~Mesh (void)
 Destructor.
Mesh & setMeshPath (const std::string &meshPath)
 Change the model to draw.
Mesh & setTexturePath (const std::string &texturePath)
 Change the texture applied to the model.
Mesh & setFitSize (std::optional< float > size)
 Scale the model so its longest side has this length.
Public Member Functions inherited from guillaume::ecs::EntityFiller< components::Transform, components::Bound, components::Mesh >
 EntityFiller (ComponentRegistry &componentRegistry)
 Create the entity, its listed components and its components::Hierarchy.
virtual ~EntityFiller (void)=default
 Destroy the entity object; its components stay in the registry (see EntityRegistry::removeEntity).
Public Member Functions inherited from guillaume::ecs::Entity
 Entity (void)
 Create an entity with a fresh identifier, an empty signature, no parent and no component.
virtual ~Entity (void)=default
 Destroy the entity object.
Entity::Identifier getIdentifier (void) const noexcept
 Get the identifier of the entity.
Entity::Signature getSignature (void) const noexcept
 Get the set of component types the entity declares.
void setSignature (const Signature &signature)
 Replace the signature of the entity.
std::int32_t getLayer (void) const noexcept
 Get the depth of the entity in the tree.
Entity & setParent (std::shared_ptr< Entity > parent)
 Attach the entity under another one, or detach it.
std::vector< Identifier > releaseComponents (void)
 Drop the entity's place in the tree and all its components.
std::shared_ptr< Entity > getParent (void) const noexcept
 Get the parent entity.

Static Public Member Functions

template<typename... Arguments>
static std::shared_ptr< Mesh > create (Arguments &&...arguments)
 Build a mesh without registering it in an entity registry.
Static Public Member Functions inherited from guillaume::ecs::Entity
template<InheritFromComponent... ComponentTypes>
static Signature getSignatureFromTypes (void)
 Build the signature that has exactly the bits of the given component types.

Additional Inherited Members

Public Types inherited from guillaume::ecs::Entity
using Identifier = std::size_t
 The key under which an entity's components are stored. Systems and components refer to entities by this value.
using Signature = std::bitset<128>
 A set of component types, one bit per type (bit position given by ComponentTypeId, MaxComponentTypes bits).
Static Public Attributes inherited from guillaume::ecs::Entity
static constexpr Identifier InvalidIdentifier
 "No entity": never the identifier of a real entity
Protected Member Functions inherited from guillaume::ecs::EntityFiller< components::Transform, components::Bound, components::Mesh >
ComponentRegistry & getComponentRegistry (void)
 Get the registry that stores this entity's components.
Protected Member Functions inherited from guillaume::ecs::Entity
void attachHierarchy (ComponentRegistry &componentRegistry)
 Give the entity a components::Hierarchy in a registry and add that component to its signature.
template<InheritFromComponent... ComponentTypes>
void setSignature (void)
 Replace the signature by the one made of the given component types.

Detailed Description

A 3D model loaded from a file, with an optional texture.

Mesh is a leaf widget: it has no children. Its state lives in components::Mesh (model path, texture path) and components::Transform. Each frame systems::MeasureMesh writes the width and height of the model's bounding box into components::Bound, in the Measure phase, and systems::MeshRender draws the model at the Transform pose, in the Render phase. The class itself holds no field.

Mesh::Builder builder(getComponentRegistry(), getEntityRegistry());
auto model = builder.makeMesh(parent, "models/chair.obj",
"textures/wood.png");
Configures Mesh widgets and registers them in the scene's entity registry.
Definition mesh.hpp:75

Mesh::create(registry, meshPath) builds the same widget without registering it in an entity registry; call setTexturePath() afterwards to give it a texture.

Watch out: the Bound is overwritten every frame with the size of the model, so a mesh cannot be resized through its Bound.

See also
components::Mesh, systems::MeasureMesh, systems::MeshRender

Definition at line 65 of file mesh.hpp.

Constructor & Destructor Documentation

◆ ~Mesh()

guillaume::entities::Mesh::~Mesh ( void )

Destructor.

Definition at line 82 of file mesh.cpp.

Member Function Documentation

◆ create()

template<typename... Arguments>
std::shared_ptr< Mesh > guillaume::entities::Mesh::create ( Arguments &&... arguments)
inlinestatic

Build a mesh without registering it in an entity registry.

The arguments are forwarded to the private constructor: (registry, meshPath). A mesh has no children to build.

Template Parameters
ArgumentsThe constructor argument types.
Parameters
argumentsThe constructor arguments, as listed above.
Returns
The new mesh. The caller owns it.

Definition at line 148 of file mesh.hpp.

Here is the caller graph for this function:

◆ setFitSize()

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

Scale the model so its longest side has this length.

Parameters
sizeThe length, in dp, or nothing to draw the model in its file's own units.
Returns
Reference to this mesh for chaining.
See also
components::Mesh::setFitSize

Definition at line 104 of file mesh.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMeshPath()

Mesh & guillaume::entities::Mesh::setMeshPath ( const std::string & meshPath)

Change the model to draw.

The Bound follows at the next Measure phase.

Parameters
meshPathThe path of the new model file, written to components::Mesh.
Returns
Reference to this mesh for chaining.

Definition at line 86 of file mesh.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTexturePath()

Mesh & guillaume::entities::Mesh::setTexturePath ( const std::string & texturePath)

Change the texture applied to the model.

Parameters
texturePathThe path of the new texture file, written to components::Mesh, or an empty string for the default material.
Returns
Reference to this mesh for chaining.

Definition at line 95 of file mesh.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

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