90 std::shared_ptr<utility::RessourceProvider> ressourceProvider,
91 const utility::graphic::PoseF &anchor,
92 const utility::graphic::Color32Bit &color,
93 const std::string &content, uint32_t fontSize,
94 const std::string &font)
95 : utility::graphic::Text(ressourceProvider,
96 utility::graphic::PoseF(), color, content,
117 void bake(
const utility::graphic::PoseF &anchor)
119 if (_meshes.empty() || _meshes.front() ==
nullptr) {
123 const auto &source = _meshes.front();
124 const auto &vertices = source->getVertices();
126 if (vertices.empty()) {
130 float minX = std::numeric_limits<float>::max();
131 float maxY = std::numeric_limits<float>::lowest();
133 for (
const auto &vertex: vertices) {
134 const auto &position = vertex.getPosition();
135 minX = std::min(minX, position[0]);
136 maxY = std::max(maxY, position[1]);
141 const utility::graphic::PositionF localTopLeft(minX, maxY, 0.0f);
142 const auto rotatedOffset =
144 localTopLeft, anchor.getOrientation());
145 const auto &anchorPosition = anchor.getPosition();
147 const utility::graphic::PositionF origin(
148 anchorPosition[0] - rotatedOffset[0],
149 anchorPosition[1] - rotatedOffset[1],
150 anchorPosition[2] - rotatedOffset[2]);
152 auto baked = std::make_shared<utility::graphic::Mesh>(
153 std::vector<utility::graphic::VertexF> {},
154 std::vector<uint32_t> {});
156 for (
const auto &vertex: vertices) {
158 vertex.getPosition(), anchor.getOrientation());
160 auto bakedVertex = vertex;
161 bakedVertex.setPosition(utility::graphic::PositionF(
162 origin[0] + rotated[0], origin[1] + rotated[1],
163 origin[2] + rotated[2]));
164 baked->addVertex(bakedVertex);
167 for (
const auto index: source->getIndices()) {
168 baked->addIndex(index);
171 _meshes.front() = baked;
172 _pose = utility::graphic::PoseF();
~TextRenderable(void) override=default
Default destructor.
TextRenderable(std::shared_ptr< utility::RessourceProvider > ressourceProvider, const utility::graphic::PoseF &anchor, const utility::graphic::Color32Bit &color, const std::string &content, uint32_t fontSize, const std::string &font)
Lay out a text and place its glyphs in world coordinates.