Ogre output screen 2d text (Overlay text), ogreoverlay
Reference: http://www.cnblogs.com/wanghao111/archive/2009/08/11/1543495.html
Reference: http://www.cnblogs.com/gogoplayer/archive/2008/05/09/1189795.html
Reference: Pro OGRE 3D Programming
(Owed by: spring night rain http://blog.csdn.net/chunyexiyu reprint please indicate the source)
The Ogre text generation method is divided into configuration file creation and program creation. The two are similar in implementation of similar definition structures.
First, define the text description, then define the text 2d layer, add container to the layer, and then add TextArea.
2d-overlay
-> Container
-> Container/element
The configuration file configuration is flexible and easy to understand. The introduction is as follows: (special thanks to the author of the reference article. Otherwise, I really don't know what to do .)
1. Create a configuration file-create English text
If you create a file in the configuration file, the method is as follows:
For example
A. Configure the font definition in sample. fontdef.
MyFont1
{
Type truetype
Source solo5.ttf
Size 16
Resolution 96
}
B. Create sample. overlay, which defines
(Note: The range cannot be too large; otherwise, the display may fail)
(Note: material Core/StatsBlockCenter is the background color of the text)
MyOverlay
{
Z-order 499
Container BorderPanel (MyContainer3)
{
Metrics_mode pixels
Left 0
Top 10
Width 300
The height is 200.
Material Core/StatsBlockCenter
Element TextArea (MyTextArea3)
{
Metrics_mode pixels
Top 10
Left 50
Width 200
Height 50
Font_name MyFont1
Char_height 19
Caption who am I
Colour_top 1 0.7
Colour_bottom 1 0.7
}
}
}
C. Display MyOverlay in the program
// Load the font
Ogre: FontManager: getSingleton (). getByName ("MyFont1")-> load ();
// Display two-dimensional layers
Ogre: OverlayManager * p = Ogre: OverlayManager: getSingletonPtr ();
Ogre: Overlay * pOverlay = p-> getByName ("MyOverlay ");
POverlay-> show ();
3. Create a configuration file-Create Chinese Text
To create Chinese characters, you must support the Chinese Character Library.
Refer to Region
For example, you can use simhei. ttf to add several texts.
A. Configure the font definition in sample. fontdef.
MyChsFont1
{
Type truetype
Source simhei. ttf
Size 16
Resolution 96
Code_points 25105-25105 26159-26159 35841-35841 33-166
}
Note: In code_points, It is the wchar decimal value of unicode for Chinese characters and English letters. The Chinese Character Library is large and time-consuming for full loading. Which of the following methods is said to be more cost-effective.
B. Define in sample. overlay
MyOverlay
{
Z-order 499
Container BorderPanel (MyContainer3)
{
Metrics_mode pixels
Left 0
Top 10
Width 300
The height is 200.
Material Core/StatsBlockCenter
Element TextArea (MyTextArea4)
{
Metrics_mode pixels
Top 70
Left 50
Width 200
Height 50
Font_name MyChsFont1
Char_height 19
Caption who I am
Colour_top 1 0.7
Colour_bottom 1 0.7
}
}
}
C. Load the font in the program.
// Load the font
Ogre: FontManager: getSingleton (). getByName ("MyChsFont1")-> load ();
// Display two-dimensional layers
Ogre: OverlayManager * p = Ogre: OverlayManager: getSingletonPtr ();
Ogre: Overlay * pOverlay = p-> getByName ("MyOverlay ");
POverlay-> show ();
(Owed by: spring night rain http://blog.csdn.net/chunyexiyu reprint please indicate the source)