Cogs.Core
Text3DComponent.cpp
1#include "Text3DComponent.h"
2
3#include "Types.h"
4
5using namespace Cogs::Reflection;
6
8{
9 static constexpr EnumeratorDef vEnumerators[] = {
10 { "TopLeft", Cogs::Core::Alignment::TopLeft },
11 { "TopCenter", Cogs::Core::Alignment::TopCenter },
12 { "TopRight", Cogs::Core::Alignment::TopRight },
13
14 { "MiddleLeft", Cogs::Core::Alignment::MiddleLeft },
15 { "MiddleCenter", Cogs::Core::Alignment::MiddleCenter },
16 { "MiddleRight", Cogs::Core::Alignment::MiddleRight },
17
18 { "BottomLeft", Cogs::Core::Alignment::BottomLeft },
19 { "BottomCenter", Cogs::Core::Alignment::BottomCenter },
20 { "BottomRight", Cogs::Core::Alignment::BottomRight },
21 };
22
23 TypeDatabase::createType<Cogs::Core::Alignment>().setEnumerators(vEnumerators);
24 TypeDatabase::createType<std::vector<Cogs::Core::Alignment>>();
25
26 Field fields [] = {
32 Field(Name("alignments"), &Text3DComponent::alignments),
33 Field(Name("fontHandle"), &Text3DComponent::fontHandle),
34 Field(Name("defaultColor"), &Text3DComponent::defaultColor),
35 Field(Name("defaultAlignment"), &Text3DComponent::defaultAlignment),
36 };
37
38 TypeDatabase::createType<Text3DComponent>().setBase<Component>().setFields(fields);
39}
40
42 if (!texts.empty()) {
43 if ((positions.size() == texts.size()) && (hAxes.size() == texts.size()) && (vAxes.size() == texts.size())) {
44 if (colors.empty() || (colors.size() == texts.size())) {
45 if (alignments.empty() || (alignments.size() == texts.size())) {
46 return true;
47 }
48 }
49 }
50 }
51 return false;
52}
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.
Field definition describing a single data member of a data structure.
Definition: Field.h:68
Contains reflection support.
Definition: Component.h:11
Represents an unique name.
Definition: Name.h:70