WTF... ITextSceneNode moving to wierd places for no reason!

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
d00d
Posts: 7
Joined: Tue Jan 23, 2007 7:07 pm

WTF... ITextSceneNode moving to wierd places for no reason!

Post by d00d »

ok, so i wanna make your opponents name float above their head.
when i have this, everything works, but the text appears in the middle of the mesh.

Code: Select all

ISceneNode nameNode = smgr.addTextSceneNode(font, name, new SColor(225, 0,225, 0));
node.addChild(nameNode);
so obivosly i have to move it up, right?

Code: Select all

ISceneNode nameNode = smgr.addTextSceneNode(font, name, new SColor(225, 0,225, 0));
nameNode.setPosition(nameNode.getPosition().addOperator(new vector3df(0,45,0))); 
node.addChild(nameNode);
however, as SOON as i add that setPosition line, the textscenenode locates itsself majically above the fpscam and follows it along just as if id done:

Code: Select all

ISceneNode nameNode = smgr.addTextSceneNode(font, name, new SColor(225, 0,225, 0));
nameNode.setPosition(fpscam.getPosition().addOperator(new vector3df(0,45,0))); 
fpscam.addChild(nameNode);

now, what the HELL is happening???
is this an irrlicht glitch or something?
please help.
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

Are you setting its position the loop or only once at creation time? Try printing out the text node's position coordinates at every frame. The text scene node looks the same no matter how far away it is, so it could be that it is simply so extremely high that it looks like it is above the camera all the time.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Do I miss something ???
But if you set the nameNode as a child of the camNode (fpscam) and the position of the nameNode at y=45, then it's correct that the nameNode is always over the camera and following it... :shock:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
d00d
Posts: 7
Joined: Tue Jan 23, 2007 7:07 pm

Post by d00d »

Acki: true, but thats not what im actually doing, i was just using code to show you how it text scene node actually acts. I am ACTUALLY using the code from the 2nd box, but it acts just as if i was using code from the 3rd box.


Klasker: I'm setting it only once at creation time. I will try the coordinates and get back to you. I've got to switch over to windows :( for it to work properly, and i don't wanna loose my place in Die Hard 2. follow up coming.
Warchief
Posts: 204
Joined: Tue Nov 22, 2005 10:58 am

Post by Warchief »

If its a child it should have relative position to parent. For example, child.SetPosition( vector3df(0,1,0) ) doesn't mean that the child will be at 0,1,0 in the world, but 0,1,0 from its parent's position.
Warchief's Warboard 3D Now hotseat release
d00d
Posts: 7
Joined: Tue Jan 23, 2007 7:07 pm

Post by d00d »

thanks very much, it turns out that i misjudged the setScale function. when I set the scale to make the mesh taller, it also sets the scale of everything you do to it and its children. so when i moved the name up 40, it was moving it up 3600 because the y-scale was increased by 90. thanks klasker, it never occurred to me that it was simply very very far away.
Post Reply