geting node by name

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.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

koso wrote:thanks.now it works :)
ok... ;)

and now for the good solution:
forget the complete loop and the array (maybe you need the array for something else, but not for this) !!! ;)

Code: Select all

scene::ISceneNode* tmpNode = smgr->getSceneNodeFromName("room");

scene::ITriangleSelector * selector = 0;
if(tmpNode)
{
  selector = smgr->createTriangleSelector(((scene::IMeshSceneNode*)tmpNode)->getMesh(), tmpNode);
}
this is all you need, no loop and no array is needed !!! :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
koso
Posts: 27
Joined: Thu May 21, 2009 11:10 am

Post by koso »

thanks man!! :D :wink:
m_krzywy
Posts: 133
Joined: Sat Nov 04, 2006 2:05 pm

Post by m_krzywy »

Acki wrote:
koso wrote:thanks.now it works :)
ok... ;)

and now for the good solution:
forget the complete loop and the array (maybe you need the array for something else, but not for this) !!! ;)

Code: Select all

scene::ISceneNode* tmpNode = smgr->getSceneNodeFromName("room");

scene::ITriangleSelector * selector = 0;
if(tmpNode)
{
  selector = smgr->createTriangleSelector(((scene::IMeshSceneNode*)tmpNode)->getMesh(), tmpNode);
}
this is all you need, no loop and no array is needed !!! :lol:
Working fine but only for one node. Tryed also in the loop with terrain etc. but not working. I have many trrees on my scene and wanted them to colide. It's like working on the same "tree1" again. Tryed also with GetSceneNodeFromId(2); and i gave all my trees Id 2, not working too :(

Acki's ones works in the nodes loop :D

Thanks
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Of you have many nodes with the same name, then you can't reliably search for them by name and get the right one, or all of them. You are likely to get the same node over and over again. You need to enumerate all of the scene nodes with that name, not just the first one. There is code in the 15.LoadIrrFile tutorial that does just what you need. I also wrote some code here that does the same thing just in a different way.

Travis
m_krzywy
Posts: 133
Joined: Sat Nov 04, 2006 2:05 pm

Post by m_krzywy »

Thanks i get it working.
Post Reply