Showing posts with label Movable Text. Show all posts
Showing posts with label Movable Text. Show all posts

Wednesday, July 18, 2007

Portuguese Characters

In the last thread I mencioned that we introduced MovableText. The text was fine, but it didn't suport special portuguese characters like L'ç' L'é' or L'À' . Here's somethings I learn today:

In C++ normal char's take 8 bit's while wide chars take 16 bits.

char:

char c = 'a';

wide char:

wchar_t wc = L'ç';

you have to put an L before the char literal to say that it is a wide char.
Theres also std::wstring for strings of wide chars.

In the MovableText class they use the Ogre::Font class. This class loads a true type font into the ogre system. It supports all types of UTF formats, but by default, it only loads to the memory the characters with unicode between 33 and 166. That's all fine if you're writing English, but if you're writing a language with accents like I am the first 166 characteres are just not enough.

I changed the range to [33, 255] before the Font's loading.

I added this code to MovableText in the setFontName function:
...
mpFont->addCodePointRange( Font::CodePointRange( 33, 255 ));
mpFont->load();
...

and there it is "ÇçáàéèíÍ..."

Tuesday, July 17, 2007

Mesh Exporting, Billboards, Movable Text

After importing my model with the help of an exporter, I started to animate the scene.
The wheels roll nicely and the car bounces a little bit.


fig.1 - Lexi Exporter


There are two more innovations in this scene.
I introduced the billboards which are textures that are always facing the camera.

BillboardSet* bbset = mSceneMgr->createBillboardSet("BBSet",1); bbset->setMaterialName("Examples/Flare"); Billboard* bb = bbset->createBillboard( Vector3( 0,0,0 ) ); FloatRect coords( 0.0, 0.0, 1.0, 1.0 ); bb->setTexcoordRect(coords); billboardNode->attachObject( bbset );

In fig.2 we can see a flare made with a billboard.

fig.2- Animated Car Scene with Flare and Label

We also added the MovableText class to put text on top of objects.

MovableText * msg = new MovableText("fireCarLabel", "Carro dos
bombeiros","Console",12,ColourValue(0.5f,1.0,0.5,1.0f));