|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
Mesh builders shared by the shape render systems. More...
#include <vector>#include <utility/graphic/color.hpp>#include <utility/graphic/mesh.hpp>#include <utility/graphic/orientation.hpp>#include <utility/graphic/pose.hpp>#include <utility/math/vector.hpp>

Go to the source code of this file.
Namespaces | |
| namespace | guillaume |
| A C++20 UI framework for desktop and XR, built as an entity-component-system. | |
| namespace | guillaume::systems |
| Rules. Every class here runs each frame on the entities that have the components it declares. | |
Functions | |
| utility::graphic::PositionF | guillaume::systems::shape::rotatePositionByQuaternion (const utility::graphic::PositionF &position, const utility::graphic::OrientationF &orientation) |
| Rotate a 3D point around the origin by a quaternion. | |
| std::vector< utility::graphic::PositionF > | guillaume::systems::shape::transformToWorldVertices (const std::vector< utility::math::Vector2F > &localVertices, const utility::graphic::PositionF ¢er, const utility::graphic::OrientationF &orientation) |
| Move 2D points of a shape's plane into world space. | |
| bool | guillaume::systems::shape::isInvisible (const utility::graphic::Color32Bit &color) |
| Whether a color draws nothing. | |
| utility::graphic::Color32Bit | guillaume::systems::shape::opaqueColor (const utility::graphic::Color32Bit &color) |
| Turn a translucent color into the opaque color it looks like. | |
| utility::graphic::VertexF | guillaume::systems::shape::createVertex (const utility::graphic::PositionF &position, const utility::graphic::Color32Bit &color) |
| Make a mesh vertex from a position and a color. | |
| void | guillaume::systems::shape::buildTriangleFanVertices (utility::graphic::Mesh &mesh, const utility::graphic::PositionF ¢er, const std::vector< utility::graphic::PositionF > &outline, const utility::graphic::Color32Bit &color) |
| Fill a closed outline with a fan of triangles around its center. | |
| void | guillaume::systems::shape::buildRingMesh (utility::graphic::Mesh &mesh, const utility::graphic::PositionF ¢er, const utility::graphic::OrientationF &orientation, float outerHalfWidth, float outerHalfHeight, float thickness, float startAngle, float sweepAngle, int segments, bool closed, const utility::graphic::Color32Bit &color) |
| Build a ring, or a part of one, as a strip of triangles. | |
| void | guillaume::systems::shape::buildLineMesh (utility::graphic::Mesh &mesh, const utility::graphic::PositionF ¢er, const utility::graphic::OrientationF &orientation, float halfLength, float halfThickness, bool dashed, float dashLength, float gapLength, const utility::graphic::Color32Bit &color) |
| Build a straight stroke along X, solid or dashed. | |
| void | guillaume::systems::shape::buildRoundedStrokeMesh (utility::graphic::Mesh &mesh, const utility::graphic::PositionF ¢er, const utility::graphic::OrientationF &orientation, float halfWidth, float halfHeight, float radius, float width, int arcSegments, const utility::graphic::Color32Bit &color) |
| Build the border of a rounded rectangle as a band of constant width. | |
Mesh builders shared by the shape render systems.
The functions of guillaume::systems::shape turn a center, an orientation and a few lengths into the vertices and triangle indices of a flat shape: a filled outline, a ring or arc, a straight stroke, a rounded-rectangle border. They read no component and keep no state.
Used by RectangleRender, EllipseRender, RingRender, ArcRender, LineRender, ScrimRender and FocusRingRender.
Shapes are described in their own plane (X to the right, Y along the height) around a center, then rotated by the orientation and moved to the center. Lengths are in the unit of components::Bound (dp).
Every builder writes indices counted from the first vertex of the mesh: pass an empty mesh, one per shape.
Definition in file shape_mesh.hpp.
| void guillaume::systems::shape::buildLineMesh | ( | utility::graphic::Mesh & | mesh, |
| const utility::graphic::PositionF & | center, | ||
| const utility::graphic::OrientationF & | orientation, | ||
| float | halfLength, | ||
| float | halfThickness, | ||
| bool | dashed, | ||
| float | dashLength, | ||
| float | gapLength, | ||
| const utility::graphic::Color32Bit & | color ) |
Build a straight stroke along X, solid or dashed.
The stroke runs from -halfLength to +halfLength around the center and is centered on the X axis. A dashed stroke starts with a dash at the left end; the last dash is cut at the right end.
| mesh | The mesh to fill. It must be empty: indices start at 0. |
| center | World position of the middle of the stroke. |
| orientation | World orientation of the stroke. |
| halfLength | Half the length of the stroke, in dp. The sign is ignored. |
| halfThickness | Half the thickness of the stroke, in dp. The sign is ignored. |
| dashed | True to split the stroke into dashes. |
| dashLength | Length of one dash, in dp. With a value of zero or less the stroke is drawn solid even when dashed is true. |
| gapLength | Empty length between two dashes, in dp. A negative value is treated as zero. |
| color | Color given to every vertex. |
Definition at line 210 of file shape_mesh.cpp.
| void guillaume::systems::shape::buildRingMesh | ( | utility::graphic::Mesh & | mesh, |
| const utility::graphic::PositionF & | center, | ||
| const utility::graphic::OrientationF & | orientation, | ||
| float | outerHalfWidth, | ||
| float | outerHalfHeight, | ||
| float | thickness, | ||
| float | startAngle, | ||
| float | sweepAngle, | ||
| int | segments, | ||
| bool | closed, | ||
| const utility::graphic::Color32Bit & | color ) |
Build a ring, or a part of one, as a strip of triangles.
The outer edge is the ellipse of half extents (outerHalfWidth, outerHalfHeight). The inner edge is the same ellipse with both half extents reduced by thickness, never below zero. With closed true the last segment joins the first one (a full ring: pass a sweep of 2 * pi); with closed false the strip has two flat ends (an arc).
| mesh | The mesh to fill. It must be empty: indices start at 0. |
| center | World position of the center of the ring. |
| orientation | World orientation of the ring. |
| outerHalfWidth | Outer half extent along X, in dp. The sign is ignored. |
| outerHalfHeight | Outer half extent along Y, in dp. The sign is ignored. |
| thickness | Distance between the outer and inner edges, in dp. |
| startAngle | Angle of the first sample, in radians. Zero points along +X and the angle grows towards +Y. |
| sweepAngle | Angle covered from startAngle, in radians. A negative value sweeps the other way. |
| segments | Number of quads along the ring. A value of zero or less is treated as 1. |
| closed | True to join the end to the start. |
| color | Color given to every vertex. |
Definition at line 149 of file shape_mesh.cpp.
| void guillaume::systems::shape::buildRoundedStrokeMesh | ( | utility::graphic::Mesh & | mesh, |
| const utility::graphic::PositionF & | center, | ||
| const utility::graphic::OrientationF & | orientation, | ||
| float | halfWidth, | ||
| float | halfHeight, | ||
| float | radius, | ||
| float | width, | ||
| int | arcSegments, | ||
| const utility::graphic::Color32Bit & | color ) |
Build the border of a rounded rectangle as a band of constant width.
The band lies between the rounded rectangle of half extents (halfWidth, halfHeight) and corner radius radius, and the same rectangle inset by width on every side, whose corner radius is reduced by width (never below zero). It grows inwards: the outer edge never exceeds the given half extents.
| mesh | The mesh to fill. It must be empty: indices start at 0. |
| center | World position of the center of the rectangle. |
| orientation | World orientation of the rectangle. |
| halfWidth | Outer half width, in dp. |
| halfHeight | Outer half height, in dp. |
| radius | Outer corner radius, in dp. It is clamped between zero and the smaller half extent. |
| width | Width of the band, in dp. It is clamped to the smaller half extent. |
| arcSegments | Number of segments per corner. A value of zero or less is treated as 1. |
| color | Color given to every vertex. |
Definition at line 268 of file shape_mesh.cpp.
| void guillaume::systems::shape::buildTriangleFanVertices | ( | utility::graphic::Mesh & | mesh, |
| const utility::graphic::PositionF & | center, | ||
| const std::vector< utility::graphic::PositionF > & | outline, | ||
| const utility::graphic::Color32Bit & | color ) |
Fill a closed outline with a fan of triangles around its center.
Adds the center as vertex 0, then the outline, and one triangle per outline edge, including the edge that closes the outline. The result is correct for convex outlines such as rectangles, rounded rectangles and ellipses.
| mesh | The mesh to fill. It must be empty: indices start at 0. |
| center | World position shared by every triangle. |
| outline | World positions of the outline, in drawing order. With fewer than two points no visible triangle is produced. |
| color | Color given to every vertex. |
Definition at line 113 of file shape_mesh.cpp.
| utility::graphic::VertexF guillaume::systems::shape::createVertex | ( | const utility::graphic::PositionF & | position, |
| const utility::graphic::Color32Bit & | color ) |
Make a mesh vertex from a position and a color.
| position | World position of the vertex. |
| color | Color of the vertex. |
Definition at line 84 of file shape_mesh.cpp.
| bool guillaume::systems::shape::isInvisible | ( | const utility::graphic::Color32Bit & | color | ) |
Whether a color draws nothing.
The shape builders add no geometry for such a color, and the render systems then submit nothing, so a transparent shape is not drawn.
| color | The color to test. |
Definition at line 93 of file shape_mesh.cpp.
| utility::graphic::Color32Bit guillaume::systems::shape::opaqueColor | ( | const utility::graphic::Color32Bit & | color | ) |
Turn a translucent color into the opaque color it looks like.
The engine draws shapes with an opaque material, so alpha is ignored. A translucent color (a state layer, a disabled container, a shadow) is composited over the active scheme's Surface, which is what it is drawn on in most cases. Opaque and fully transparent colors are returned unchanged.
| color | The color. |
Definition at line 99 of file shape_mesh.cpp.

| utility::graphic::PositionF guillaume::systems::shape::rotatePositionByQuaternion | ( | const utility::graphic::PositionF & | position, |
| const utility::graphic::OrientationF & | orientation ) |
Rotate a 3D point around the origin by a quaternion.
| position | The point to rotate. |
| orientation | The rotation. It is normalized before use. |
Definition at line 33 of file shape_mesh.cpp.
| std::vector< utility::graphic::PositionF > guillaume::systems::shape::transformToWorldVertices | ( | const std::vector< utility::math::Vector2F > & | localVertices, |
| const utility::graphic::PositionF & | center, | ||
| const utility::graphic::OrientationF & | orientation ) |
Move 2D points of a shape's plane into world space.
Each point gets a zero depth, is rotated by orientation and is then translated by center.
| localVertices | The points, relative to the center of the shape. |
| center | World position of the center of the shape. |
| orientation | World orientation of the shape. |
Definition at line 64 of file shape_mesh.cpp.