Skylicht Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
TextBillboard
CTextBillboardManager.h
1
/*
2
!@
3
MIT License
4
5
Copyright (c) 2025 Skylicht Technology CO., LTD
6
7
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10
subject to the following conditions:
11
12
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20
This file is part of the "Skylicht Engine".
21
https://github.com/skylicht-lab/skylicht-engine
22
!#
23
*/
24
25
#pragma once
26
27
#include "Utils/CSingleton.h"
28
#include "Graphics2D/SpriteFrame/IFont.h"
29
#include "Graphics2D/SpriteFrame/CSpriteFrame.h"
30
#include "Material/CMaterial.h"
31
32
namespace
Skylicht
33
{
34
class
SKYLICHT_API CRenderTextData
35
{
36
public
:
37
enum
EPositionType
38
{
39
Billboard,
40
Text2D
41
};
42
43
enum
EVerticalAlign
44
{
45
Top,
46
Middle,
47
Bottom
48
};
49
50
enum
EHorizontalAlign
51
{
52
Left,
53
Center,
54
Right
55
};
56
57
public
:
58
EPositionType Type;
59
core::vector3df
Position;
60
SColor
Color;
61
int
ShaderID;
62
CMaterial
* Material;
63
bool
Visible;
64
core::matrix4
Transform;
65
EVerticalAlign VAlign;
66
EHorizontalAlign HAlign;
67
void
* UserData;
68
69
std::function<void(CRenderTextData*)> UpdateTransformCallback;
70
71
protected
:
72
std::wstring m_text;
73
74
IFont
* m_font;
75
std::vector<std::vector<SModuleOffset*>> m_arrayCharRender;
76
77
float
m_textHeight;
78
float
m_textOffsetY;
79
float
m_linePadding;
80
float
m_spacePadding;
81
public
:
82
83
CRenderTextData();
84
85
~CRenderTextData();
86
87
void
init();
88
89
void
setText(
IFont
* font,
const
char
* text);
90
91
void
setText(
IFont
* font,
const
wchar_t
* text);
92
93
void
setText(
const
char
* text);
94
95
void
setText(
const
wchar_t
* text);
96
97
inline
std::vector<std::vector<SModuleOffset*>>& getModules()
98
{
99
return
m_arrayCharRender;
100
}
101
102
inline
float
getTextHeight()
103
{
104
return
m_textHeight;
105
}
106
107
inline
float
getLinePadding()
108
{
109
return
m_linePadding;
110
}
111
112
inline
void
setLinePadding(
float
p)
113
{
114
m_linePadding = p;
115
}
116
117
inline
float
getSpacePadding()
118
{
119
return
m_spacePadding;
120
}
121
122
inline
void
setSpacePadding(
float
p)
123
{
124
m_spacePadding = p;
125
}
126
127
inline
float
getTextOffsetY()
128
{
129
return
m_textOffsetY;
130
}
131
};
132
133
class
SKYLICHT_API CTextBillboardManager
134
{
135
public
:
136
DECLARE_SINGLETON
(CTextBillboardManager)
137
138
protected
:
139
core::array<CRenderTextData*>
m_texts;
140
141
IFont
* m_defaultFont;
142
143
int
m_defaultShader;
144
145
float
m_viewportWidth;
146
float
m_viewportHeight;
147
148
public
:
149
150
CTextBillboardManager();
151
152
virtual
~CTextBillboardManager();
153
154
void
clear();
155
156
void
remove(
CRenderTextData
* text);
157
158
CRenderTextData
* addText(
const
core::vector3df
& position,
const
char
* text);
159
160
CRenderTextData
* addText(
const
core::vector3df
& position,
const
wchar_t
* text);
161
162
CRenderTextData
* addText(
const
core::vector3df
& position,
const
char
* text,
IFont
* font);
163
164
CRenderTextData
* addText(
const
core::vector3df
& position,
const
wchar_t
* text,
IFont
* font);
165
166
CRenderTextData
* addText2D(
const
core::vector2df
& position,
const
char
* text);
167
168
CRenderTextData
* addText2D(
const
core::vector2df
& position,
const
wchar_t
* text);
169
170
CRenderTextData
* addText2D(
const
core::vector2df
& position,
const
char
* text,
IFont
* font);
171
172
CRenderTextData
* addText2D(
const
core::vector2df
& position,
const
wchar_t
* text,
IFont
* font);
173
174
void
initDefaultFont();
175
176
const
core::array<CRenderTextData*>
& getRenderTexts()
177
{
178
return
m_texts;
179
}
180
181
inline
float
getViewportWidth()
182
{
183
return
m_viewportWidth;
184
}
185
186
inline
float
getViewportHeight()
187
{
188
return
m_viewportHeight;
189
}
190
191
inline
void
setViewport(
float
w,
float
h)
192
{
193
m_viewportWidth = w;
194
m_viewportHeight = h;
195
}
196
};
197
198
}
Skylicht::CMaterial
The object class describes material information such as which shader it's associated with,...
Definition
CMaterial.h:84
Skylicht::CRenderTextData
Definition
CTextBillboardManager.h:35
Skylicht::IFont
Definition
IFont.h:32
irr::core::array
Self reallocating template array (like stl vector) with additional features.
Definition
irrArray.h:23
irr::video::SColor
Class representing a 32 bit ARGB color.
Definition
SColor.h:285
DECLARE_SINGLETON
#define DECLARE_SINGLETON(className)
Declare the standard singleton accessors for a class.
Definition
CSingleton.h:36
Skylicht
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition
AudioDebugLog.h:29
irr::core::vector3df
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition
vector3d.h:445
irr::core::vector2df
vector2d< f32 > vector2df
Typedef for f32 2d vector.
Definition
vector2d.h:323
irr::core::matrix4
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition
matrix4.h:2241
Generated by
1.17.0