AddTextSceneNode (try to change text )

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
miggs
Posts: 4
Joined: Mon Mar 17, 2008 11:18 am
Location: Delft, Netherlands

AddTextSceneNode (try to change text )

Post by miggs »

Hi

How do i change the text in AddTextSceneNode that as already been created??
Or how do i eliminate an AddTextSceneNode so i can creat a new one in the same place?

Here is the code i use to create the text:
device_.SceneManager.AddTextSceneNode(device_.GUIEnvironment.BuiltInFont,
caption, new Irrlicht.Video.Color(255, 255, 255, 255), sceneNode,new Vector3D(0, sceneNode.TransformedBoundingBox.MaxEdge.Y + 4, 0), 0);

thanks!
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

i don't know if the text scene node provides a setText function but checking the API for this would be a sensible thing to do. Obviously you'd store the pointer returned by addTextSceneNode so that you could later change it.

If there is no such function provided then you can remove the text scene node in the usual way you would remove a node, again requiring the pointer to have been stored, then you call remove() on that pointer (though it seems you're not using C++ so it wouldn't be a pointer i guess).
Image Image Image
miggs
Posts: 4
Joined: Mon Mar 17, 2008 11:18 am
Location: Delft, Netherlands

Post by miggs »

I'm using C#.

I think i have to do it how you said (stored each TextSceneNode in a field ), since i can't find a function to do it directly.

Thank's JP
Bob Finnie
Posts: 49
Joined: Tue Jan 23, 2007 12:36 pm
Location: Bedford, UK

Post by Bob Finnie »

Can you not do this:

Code: Select all

// create the text scene node
ITextSceneNode *txt = Device->getSceneManager()->addTextSceneNode  (...);

....

// change the text
txt->setText(L"New Text");
or the c# equivalent which would be:

Code: Select all

 txt.setText(L"New Text");
miggs
Posts: 4
Joined: Mon Mar 17, 2008 11:18 am
Location: Delft, Netherlands

Post by miggs »

Can you not do this:

Code:
// create the text scene node
ITextSceneNode *txt = Device->getSceneManager()->addTextSceneNode (...);

....

// change the text
txt->setText(L"New Text");


or the c# equivalent which would be:
Code:
txt.setText(L"New Text");
Nop...

Strangely addTextSceneNode doesn't have that function. :?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

of course it doesn't... addTextSceneNode is a function... not a class... function's don't have functions..

addTextSceneNode returns a pointer to the text scene node that's been created. Store that pointer in a ITextSceneNode* and then you can call the setText function as bob pointed out...
Image Image Image
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Found in 2.9 seconds:
Irrlicht Documentation wrote: virtual void setText (const wchar_t *text)=0
sets the text string
The best thing you can do when you know the class is open Irrlicht Class List Documentation then push Ctrl + F and type in the class name you want to find: ITextSceneNode. Finally, you push Ctrl + F again and search for a keyword in the function, or just browse the function list.
TheQuestion = 2B || !2B
miggs
Posts: 4
Joined: Mon Mar 17, 2008 11:18 am
Location: Delft, Netherlands

Post by miggs »

Thanks for all the help guys...

I'm using the API.NET....
So for what I'm seeing the AddTextSceneNode returns an ISceneNode.
After stored i don't have access to the setText method...

Probably this feature hasn't been ported yet...

Thanks
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Well if I recall correctly, the .NET port isn't being maintained anymore. But if you would like to port, and maintain this, then that would be cool!
TheQuestion = 2B || !2B
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

There is the well maintained Irrlicht.CP Net port which should provide a much more complete API and further features.
doraemonalex
Posts: 4
Joined: Sun Jan 20, 2008 7:37 am

Post by doraemonalex »

just another problem also related with AddTextSceneNode

I am now working on my project in which I will have a number be displayed above some nodes at certain instant. I have just tried this function and wanted to ask some further questions.

1. How can the font size be set larger ? It seems that setScale doesn't work for me.
2. Is the position fixed ? It seems that when i rotate the camera, the text started to displace to other positions ?

Thanks :D
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You can change the font by passing a different font to it when you create it. Unfortuantely irrlicht doesn't provide any way to change the size of fonts at runtime so you just have to create a larger bmp font using the font tool in the SDK.
Image Image Image
Leomar
Posts: 1
Joined: Fri Mar 06, 2009 12:35 pm

Post by Leomar »

Got the same problem, trying to change text of an already created scenenode. I`m also using the .net api and found no iSceneTextNode in it.

Any solutions so far ?

---edit---

I tried to remove the nodes and recreate them but that sometimes causes an accessviolationexception trying to access secured memory in the drawall() method of the scenemanger after several seconds.
Post Reply