guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
mesh.hpp
1/*
2 Copyright (c) 2026 ETIB Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22
23#pragma once
24
25#include <optional>
26#include <string>
27
28#include "guillaume/ecs/component.hpp"
29
31{
56 class Mesh: public ecs::Component
57 {
58 private:
59 std::string _meshPath {};
60 std::string _texturePath {};
61 std::optional<float> _fitSize {};
62
63 public:
67 Mesh(void) = default;
68
72 ~Mesh(void) = default;
73
83 Mesh &setMeshPath(const std::string &path);
84
94 Mesh &setTexturePath(const std::string &path);
95
100 std::string getMeshPath(void) const;
101
107 std::string getTexturePath(void) const;
108
114 const std::optional<float> &getFitSize(void) const noexcept;
115
125 Mesh &setFitSize(std::optional<float> size);
126
134 float scaleFor(float modelWidth, float modelHeight) const noexcept;
135 };
136} // namespace guillaume::components
const std::optional< float > & getFitSize(void) const noexcept
Get the size the model is scaled to.
Definition mesh.cpp:59
Mesh(void)=default
Default constructor for the Mesh component.
std::string getMeshPath(void) const
Get the path of the model file.
Definition mesh.cpp:39
Mesh & setTexturePath(const std::string &path)
Choose the texture applied to the model.
Definition mesh.cpp:44
float scaleFor(float modelWidth, float modelHeight) const noexcept
Get the factor that turns model units into dp.
Definition mesh.cpp:73
Mesh & setMeshPath(const std::string &path)
Choose the model to show.
Definition mesh.cpp:29
std::string getTexturePath(void) const
Get the path of the texture file.
Definition mesh.cpp:54
~Mesh(void)=default
Default destructor for the Mesh component.
Mesh & setFitSize(std::optional< float > size)
Scale the model so its longest side has this length.
Definition mesh.cpp:64
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
Definition component.hpp:72
State. Every class here is plain data attached to an entity.