drawing a text(SOLVED)

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
MasterM
Posts: 128
Joined: Sat Oct 20, 2007 2:38 am
Location: netherlands antilles, Curacao

drawing a text(SOLVED)

Post by MasterM »

Hey guys, how do i draw a text on a model?for example infront of a cube saying "cube"...i tried

Code: Select all

guienv->addStaticText(L"Cube",core::rect<s32>(480,445,630,465),false);
but it displays the text on the screen but i want to place the text on the model...but i dont know what to do can anyone help me?
Thanks in advance.
Last edited by MasterM on Sun Nov 23, 2008 4:41 pm, edited 1 time in total.
C++ is not the Magdalena...it takes patience...shes like the well aged prostitute, it takes years to learn her tricks! she is cruel...laughs at you when you are naked...
Life of a programmer == Const abuse
frostysnowman
Posts: 83
Joined: Fri Apr 11, 2008 3:06 am
Location: Beaverton, Oregon, US

Post by frostysnowman »

On the model? For that, you want to use a texture. addStaticText() will add a 2d static text on the screen.
MasterM
Posts: 128
Joined: Sat Oct 20, 2007 2:38 am
Location: netherlands antilles, Curacao

Post by MasterM »

No no, not on the texture i mean like make a text and place it infront of the model like this for example Image notice how the cube text is infront of the man model...how do i make a text apear infront of a model like that?
C++ is not the Magdalena...it takes patience...shes like the well aged prostitute, it takes years to learn her tricks! she is cruel...laughs at you when you are naked...
Life of a programmer == Const abuse
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

In case your model is also drawn with 2d methods or GUI elements you can just aling the positions. If you want to do this for 3d models, you have to use a 3d text node. Best option is the TextBillboardSceneNode, which you can simply parent to the model and the text will move together with the model.
MasterM
Posts: 128
Joined: Sat Oct 20, 2007 2:38 am
Location: netherlands antilles, Curacao

Post by MasterM »

hmmm i gave a shot at addBillboardTextSceneNode using the following parameters :

Code: Select all

 ISceneNode *test=smgr->addBillboardTextSceneNode(0,L"TESdfgdfgdfgdsgsaadT",0, core::dimension2d< f32 >(10.0f, 10.0f),sars->getPosition()+vector3df(0,0.5,0),0, 0xFFFFFFFF, 0xFFFFFFFF);
But i dont see nothing, what am i doing wrong(i never used this function before so i may be doing something horribly wrong)
Thanks in advance.
C++ is not the Magdalena...it takes patience...shes like the well aged prostitute, it takes years to learn her tricks! she is cruel...laughs at you when you are naked...
Life of a programmer == Const abuse
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The declaration for the method you are calling is...

Code: Select all

  832 		virtual IBillboardTextSceneNode* addBillboardTextSceneNode( gui::IGUIFont* font, const wchar_t* text,
  833 			ISceneNode* parent = 0,
  834 			const core::dimension2d<f32>& size = core::dimension2d<f32>(10.0f, 10.0f),
  835 			const core::vector3df& position = core::vector3df(0,0,0), s32 id=-1,
  836 			video::SColor shade_top = 0xFFFFFFFF, video::SColor shade_down = 0xFFFFFFFF) = 0;

The documentation provided doesn't say this, but that method will do nothing if the font parameter is NULL. You should also pass your scene node pointer as the third parameter. That way the text will move with the mesh.

The following code should get something to appear on your screen...

Code: Select all

scene::ISceneNode* cube = smgr->addCubeSceneNode(10.f);

gui::IGUIFont* font = gui->getFont("../../media/fontlucida.png");
if (!font)
  font = gui->getBuiltInFont();

scene::IBillboardTextSceneNode* cube_name = smgr->addBillboardTextSceneNode(font, L"Cube", cube);
cube_name->setPosition (core::vector3df(0.f, 10.f, 0.f));
Travis
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

vitek wrote:The documentation provided doesn't say this, but that method will do nothing if the font parameter is NULL.
As of SVN 1798, we use the default GUI font if none is specified. Thanks for pointing this out.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
MasterM
Posts: 128
Joined: Sat Oct 20, 2007 2:38 am
Location: netherlands antilles, Curacao

Post by MasterM »

The documentation provided doesn't say this, but that method will do nothing if the font parameter is NULL. You should also pass your scene node pointer as the third parameter. That way the text will move with the mesh
Thanks, i figure it had something to do with the font tho but did not know how fonts work(until now).
Well i did a test and this is what i got : Image
its good and all but does anyone know how to make the text transparent(the black parts)
Thanks in advance.
C++ is not the Magdalena...it takes patience...shes like the well aged prostitute, it takes years to learn her tricks! she is cruel...laughs at you when you are naked...
Life of a programmer == Const abuse
MasterM
Posts: 128
Joined: Sat Oct 20, 2007 2:38 am
Location: netherlands antilles, Curacao

Post by MasterM »

Can someone help me with this, i been trying and trying and still no results.
C++ is not the Magdalena...it takes patience...shes like the well aged prostitute, it takes years to learn her tricks! she is cruel...laughs at you when you are naked...
Life of a programmer == Const abuse
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

MasterM wrote:its good and all but does anyone know how to make the text transparent(the black parts)
it works like expected for me:
Image

using Irrlicht v1.4.2 (OGL and DX9) with this code:

Code: Select all

#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

int main(){
  IrrlichtDevice *device = createDevice(EDT_DIRECT3D9);
  IVideoDriver* driver = device->getVideoDriver();
  ISceneManager* smgr = device->getSceneManager();
  IGUIEnvironment* guienv = device->getGUIEnvironment();

  IAnimatedMesh* mesh = smgr->getMesh("media/sydney.md2");
  IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
  node->setMaterialFlag(EMF_LIGHTING, false);
  node->setMD2Animation ( EMAT_STAND );
  node->setMaterialTexture( 0, driver->getTexture("media/sydney.bmp") );

  IGUIFont* font = guienv->getFont("media/fontlucida.png");
  if (!font) font = guienv->getBuiltInFont();
  ITextSceneNode* cube_name = smgr->addBillboardTextSceneNode(font, L"Cube", node);
  cube_name->setPosition (vector3df(0.f, 10.f, 0.f));

  smgr->addCameraSceneNodeFPS();
  while(device->run()){
    driver->beginScene(true, true, SColor(255,100,101,140));
    smgr->drawAll();
    guienv->drawAll();
    driver->endScene();
  }
  device->drop();

  return 0;
}
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
MasterM
Posts: 128
Joined: Sat Oct 20, 2007 2:38 am
Location: netherlands antilles, Curacao

Post by MasterM »

Stupid me, i forgot to change my device type to OPENGL (it was software)
No wonder, i was starting to get blue when the error was right there.
Thank you very much.
C++ is not the Magdalena...it takes patience...shes like the well aged prostitute, it takes years to learn her tricks! she is cruel...laughs at you when you are naked...
Life of a programmer == Const abuse
Post Reply