Cogs.Core
Text3DComponent.h
1#pragma once
2
3#include "../../Flags.h"
4#include "Resources/Resources.h"
5
6#include "Foundation/ComponentModel/Component.h"
7
8#include <glm/vec3.hpp>
9#include <glm/vec4.hpp>
10
11#include <vector>
12
13namespace Cogs {
14 namespace Core {
15 class TransformComponent;
16
17 enum class Alignment : uint32_t {
18 Left = 0x00, // Position the left of the text at the specified position.
19 Center = 0x01, // Horizontally centre the text around the position.
20 Right = 0x02, // Position the right of the text at the specified position.
21
22 Top = 0x00, // Position the top of the text at the given position.
23 Middle = 0x10, // Vertically centre the text around the position.
24 Bottom = 0x20, // Position the bottom of the text on the position.
25
26 TopLeft = Left | Top,
27 TopCenter = Center | Top,
28 TopRight = Right | Top,
29
30 MiddleLeft = Left | Middle,
31 MiddleCenter = Center | Middle,
32 MiddleRight = Right | Middle,
33
34 BottomLeft = Left | Bottom,
35 BottomCenter = Center | Bottom,
36 BottomRight = Right | Bottom,
37
38 Horizontal = 0x0F,
39 Vertical = 0xF0,
40
41 Default = TopLeft,
42 };
43
44 ENABLE_ENUM_FLAGS(Alignment);
45
50 public:
52 static void registerType();
53
59 std::vector<std::string> texts;
60
64 std::vector<glm::vec3> positions;
65
74 std::vector<glm::vec3> hAxes;
75
84 std::vector<glm::vec3> vAxes;
85
92 std::vector<glm::vec4> colors;
93
99 std::vector<Alignment> alignments;
100
107
111 glm::vec4 defaultColor = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f);
112
116 Alignment defaultAlignment = Alignment::TopLeft;
117
121 bool isValid() const;
122 };
123 }
124}
125
126template<> inline Cogs::StringView getName<Cogs::Core::Alignment>() { return "Alignment"; }
127template<> inline Cogs::StringView getName<std::vector<Cogs::Core::Alignment>>() { return "vector<Alignment>"; }
128template<> inline Cogs::StringView getName<Cogs::Core::Text3DComponent>() { return "Text3DComponent"; }
Base class for Component instances.
Definition: Component.h:143
Renders the given text(s) as 3D mesh data.
std::vector< glm::vec3 > hAxes
Horizontal axes along which the text will be orientated.
FontHandle fontHandle
Handle to the font resource to use when rendering text.
std::vector< glm::vec3 > vAxes
Vertical axes which, with the horizonal axes, defines the plane in which the text will be placed.
glm::vec4 defaultColor
Single color value to apply to all text strings.
Alignment defaultAlignment
Single alignment to apply to all text strings.
bool isValid() const
Determine whether this component is valid enough to be processed by the Text3DSystem.
std::vector< Alignment > alignments
Alignment settings for each text string.
std::vector< glm::vec4 > colors
Colors for individual strings in text.
static void registerType()
Register the type in the type system.
std::vector< glm::vec3 > positions
Offset positions for each of the strings in texts.
std::vector< std::string > texts
A set of text strings to render.
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
static const ResourceHandle_t NoHandle
Handle representing a default (or none if default not present) resource.