How to display Text on a surface

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
cr_itm
Posts: 57
Joined: Sun May 01, 2005 10:13 am

How to display Text on a surface

Post 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!
sivagiri
Posts: 22
Joined: Sat Jun 10, 2006 4:31 pm

changing texture at runtime

Post by sivagiri »

Does someone know how to change texture at runtime?????



Plizzzzzzzzzzzzz!


Thx
kornerr
Posts: 245
Joined: Thu Jul 06, 2006 9:57 am
Location: Russia, Siberia, Kemerovo
Contact:

Post 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).
Open Source all the way, baby ;)
OSRPG
CodeDog
Posts: 106
Joined: Sat Oct 07, 2006 8:00 pm
Location: CA. USA
Contact:

Post 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.
strale
Posts: 119
Joined: Wed Nov 23, 2005 1:58 pm
Location: Lambrugo Italy
Contact:

Post 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
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Re: changing texture at runtime

Post 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
sivagiri
Posts: 22
Joined: Sat Jun 10, 2006 4:31 pm

Post 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???

:( :oops:
sivagiri
Posts: 22
Joined: Sat Jun 10, 2006 4:31 pm

Post 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
sivagiri
Posts: 22
Joined: Sat Jun 10, 2006 4:31 pm

Post by sivagiri »

I've got it!

sivagiri
sunnygraphy
Posts: 44
Joined: Mon Dec 05, 2005 8:15 am

Re: changing texture at runtime

Post 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
Post Reply