Page 1 of 1
How to display Text on a surface
Posted: Tue Aug 08, 2006 11:19 am
by cr_itm
Hello,
what I need is simple: Text on a surface. I tried the addTextSceneNode, but a TextSceneNode is always the same size to the user. In my case, I have an object, and obove the object I need to display some information with text. Now I'm using a Billboard to display a background for that information, and I need to get some text onto the billboard.
How can I achieve this? Must I use rendering into texture so the billboard does use that texture? If yes, is there some tutorial? If no, what other possibilities do I have to display text?
(The text must of course not be a static texture, I must be able to change the text at runtime.)
Thanks a lot for your help!
changing texture at runtime
Posted: Mon Oct 23, 2006 4:02 pm
by sivagiri
Does someone know how to change texture at runtime?????
Plizzzzzzzzzzzzz!
Thx
Posted: Tue Oct 24, 2006 6:19 am
by kornerr
I can't remember any game using text in 3d. All rpgs I seen, all players, no matter how far they are, have the same text sizes (which displays player's nick).
Posted: Tue Oct 24, 2006 6:48 am
by CodeDog
Model each of the letters of the alphabet in a modeling program.
Build your words from these models.
You could even make a class that accepts a string and returns a node with the correct letter nodes attached in the right order.
I used this method to build a 3D string in VRML once upon a time.
You can see it here
http://www.kencocomputers.com/
Hold the mouse down over the logo and when you move it you will see you are actually in a 3D world not just an animated logo. You can even fly through the logo and see it from behind.
Note: You will need the parallel graphics ActiveX VRML plug-in to see it.
Posted: Tue Oct 24, 2006 8:06 am
by strale
if i well interpred the problem:
you could:
lock the texture of the 3d model
u32* dP = (u32*) tex->lock();
with the class IGUIFont draw on the texture what you want to write
and then unlock the texture
tex->unlock();
i never tied this metod so im not sure it work
cheers
Re: changing texture at runtime
Posted: Tue Oct 24, 2006 6:38 pm
by Emil_halim
sivagiri wrote:Does someone know how to change texture at runtime?????
Plizzzzzzzzzzzzz!
Thx
changing data of texture on the fly is so simple , just lock the texture to get a pointer to texture's data then get the pitch (width of line) then change the data and finally unlock the texture.
l have made a tutorial for playing movie on a texture , also made a texture manipulatore class that allows you to write a text on texture
here is a link to it in the wiki
http://www.irrforge.org/index.php/Drawi ... in_texture
also i have included this classes in my Magic Library for direct use.
hope it helps you.
Bey
Posted: Thu Oct 26, 2006 6:37 am
by sivagiri
Hi,
I used irrforge's draw text in texture, but now when I reached the following problem I cannot load irrforge.org page to find how to solve it.
Why???
Posted: Thu Oct 26, 2006 7:43 am
by sivagiri
This is part of my code when I draw text in texture and wanted to load the second text and clear the text before...
Code: Select all
IAnimatedMeshSceneNode* GroupTherapyExercise::loadBoard(irr::scene::ISceneManager *smgr,
irr::video::IVideoDriver *driver)
{
MyMesh* mesh = new MyMesh("Virtual_Therapy/Models/Room/exported_objects/clearboard.3DS",
vector3df(-30,-60,0),
vector3df(4,4,3), vector3df(0,0,0));
IAnimatedMeshSceneNode* node = _meshLoader->loadMesh(mesh, smgr, driver); if (node) {
//node->setMD2Animation(scene::EMAT_STAND);
//node->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
if (getExercise() != NULL) {
drawExerciseToBoard(node, smgr, driver);
}
}
return node;
}
void GroupTherapyExercise::drawExerciseToBoard(irr::scene::IAnimatedMeshSceneNode *node,
irr::scene::ISceneManager *smgr, irr::video::IVideoDriver *driver)
{
ITexture* blackBoardTexture = node->getMaterial(0).Texture1;
bool needsUnlock = false;
if (blackBoardTexture != NULL) {
blackBoardTexture->lock();
needsUnlock = true;
}
blackBoardTexture = driver->getTexture(
"Virtual_Therapy/Models/Room/temp/boardtex120b.jpg");
driver->setTextureCreationFlag(ETCF_ALWAYS_32_BIT , true);
driver->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false);
blackBoardTexture->regenerateMipMapLevels();
node->getMaterial(0).Texture1 = blackBoardTexture;
if (needsUnlock) {
blackBoardTexture->unlock();
}
/*if (_previousAnwerSet.size() != 0) {
doClearTable(_blackBoardTexture, driver);
}*/
if (_whiteFont == NULL) {
_whiteFont = new TFont(driver);
_whiteFont->load("Virtual_Therapy/Fonts/fontcourier.bmp",BGR(255,255,255));
}
_whiteFont->DrawString(blackBoardTexture,400,10,getExercise()->getTitle());
_whiteFont->DrawString(blackBoardTexture,60,30,getExercise()->getDescription());
set<Answer*> currentAnswers = getExercise()->getAnswersByDifficulty(_currentDifficultyLevel);
set<Answer*>::iterator it = currentAnswers.begin();
int index = 0;
while (it != currentAnswers.end()) {
if (index == 0) {
_whiteFont->DrawString(blackBoardTexture,100,50,(*it)->getQuestion());
}
_whiteFont->DrawString(blackBoardTexture,350,(70 + (index * 25)),(*it)->getText());
if ((*it)->isCorrect()) {
_correctAnswerIndex = index;
printf("\nCorrect index %i", index);
}
index++;
it++;
}
_previousAnwerSet = currentAnswers;
}
ITexture* GroupTherapyExercise::doClearTable(ITexture* texture, IVideoDriver *driver){
if (_greenFont == NULL) {
_greenFont = new TFont(driver);
_greenFont->load("Virtual_Therapy/Fonts/fontcourier.bmp",BGR(81,103,55));
}
set<Answer*>::iterator it = _previousAnwerSet.begin();
int index = 0;
while (it != _previousAnwerSet.end()) {
if (index == 0) {
_whiteFont->DrawString(texture,100,50,(*it)->getQuestion());
}
_whiteFont->DrawString(texture,350,(70 + (index * 25)),(*it)->getText());
index++;
it++;
}
return texture;
}
What's the problem with it??
sivagiri
Posted: Fri Oct 27, 2006 6:57 am
by sivagiri
I've got it!
sivagiri
Re: changing texture at runtime
Posted: Sun Jan 21, 2007 2:29 pm
by sunnygraphy
Hi..
the following link is brokend..
http://www.irrforge.org/index.php/Drawi ... in_texture
Is there any other link for that?
thanks