Ogre output screen 2d text (Overlay text), ogreoverlay

Source: Internet
Author: User

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)

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.