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.
koso
Posts: 27
Joined: Thu May 21, 2009 11:10 am

geting node by name

Post by koso »

I have small question.How can i get scene node from irr file, by name?
thanks for answers
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, exactly like you described. getSceneNodeByName()
koso
Posts: 27
Joined: Thu May 21, 2009 11:10 am

Post by koso »

when i search for this function in manual i cant find it.please help
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
koso
Posts: 27
Joined: Thu May 21, 2009 11:10 am

Post by koso »

Well, I'am big noob so i have lot of errors there when i try compile it.Can someone, who did it, post me some kind of tutorial?I will be very grateful.Please.
EDIT:For example edit "load irr file" example where is geting nodes by type.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Check the examples. Example 15 does exactly what you want.
koso
Posts: 27
Joined: Thu May 21, 2009 11:10 am

Post by koso »

example 15 show getting node by type.I need getting by name. :cry:
koso
Posts: 27
Joined: Thu May 21, 2009 11:10 am

Post by koso »

OK i reduced my problems to one.

Code: Select all

scene::ISceneNode * node = node;
		scene::ITriangleSelector * selector = 0;
		
		
		
			switch(smgr->getSceneNodeFromName(node->getName(), node))
			{
			 case scene::"room":
			 selector = smgr->createTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
		 	 break;
and this is error:
main.cpp(105) : error C2450: switch expression of type 'irr::scene::ISceneNode *' is illegal
Help me please
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

koso wrote:OK i reduced my problems to one.

Code: Select all

scene::ISceneNode * node = node;
		scene::ITriangleSelector * selector = 0;
			switch(smgr->getSceneNodeFromName(node->getName(), node))
			{
			 case scene::"room":
			 selector = smgr->createTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
		 	 break;
and this is error:
main.cpp(105) : error C2450: switch expression of type 'irr::scene::ISceneNode *' is illegal
Help me please
wow, that's very bad, maybe (for sure) you should do some C/C++ research !?!?! :shock:

Code: Select all

scene::ISceneNode * node = node;
this is bad, you're using the same variable name two times, also why do you dublicate the node, having it once is enough !!!

Code: Select all

switch(smgr->getSceneNodeFromName(node->getName(), node))
you can't switch for a pointer (only integers can be switched) !!!
well, you could if you cast the pointer, but that's not what you want...
also why do you search for the node by name when you already have the node !?!?!

Code: Select all

case scene::"room":
where is scene::"room": declared ??? Nowhere, because this is an illegal expression, and remember only integers can be switched !!!

I'm not sure what you want to do, but I guess something like this:

Code: Select all

// scene::ISceneNode * node = node; // wrong and not needed !!!

scene::ITriangleSelector * selector = 0;
if(core::stringc(node->getName()).equals_ignore_case("room")) 
{
  selector = smgr->createTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
}
and don't forget to drop the selector later... ;)

and please do yourself a favour and grab some C/C++ book and do some learning !!! ;)
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 »

Acki wrote:

Code: Select all

scene::ISceneNode * node = /////node/////;
this is bad, you're using the same variable name two times, also why do you dublicate the node, having it once is enough !!!
i missed. i have nodes there.
you should read irr example 15 and then you realize what i want.I want get scene node by name from irrEdit file.
koso
Posts: 27
Joined: Thu May 21, 2009 11:10 am

Post by koso »

Acki wrote:

Code: Select all

scene::ISceneNode * node = /////node/////;
this is bad, you're using the same variable name two times, also why do you dublicate the node, having it once is enough !!!
i missed. i have nodes there.
you should read irr example 15 and then you realize what i want.I want get scene node by name from irrEdit file.

and that "room" is name of node wich i want get from scene
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

koso wrote:i missed. i have nodes there.
and where do this nodes come from ???
even if you have this nodes, then you already have a node, so no need to dublicate the pointer... :lol:

koso wrote:and that "room" is name of node wich i want get from scene
I thought so, but that doesn't change the fact that scene::"room" is illegal !!!
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 »

there are loop wich test all nodes in scene."nodes" is from that loop.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

koso wrote:there are loop wich test all nodes in scene."nodes" is from that loop.
and how did you get those nodes ???
maybe show the complete loop and how you get this array... ;)

well, let's assume you realy got this array correctly:

Code: Select all

scene::ITriangleSelector * selector = 0;
if(core::stringc(nodes[i]->getName()).equals_ignore_case("room"))
{
  selector = smgr->createTriangleSelector(((scene::IMeshSceneNode*)nodes[i])->getMesh(), nodes[i]);
}
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.now it works :)
Post Reply