Page 1 of 2

geting node by name

Posted: Wed Jun 17, 2009 6:45 pm
by koso
I have small question.How can i get scene node from irr file, by name?
thanks for answers

Posted: Wed Jun 17, 2009 6:48 pm
by hybrid
Well, exactly like you described. getSceneNodeByName()

Posted: Wed Jun 24, 2009 11:37 am
by koso
when i search for this function in manual i cant find it.please help

Posted: Wed Jun 24, 2009 11:52 am
by Brainsaw

Posted: Wed Jun 24, 2009 1:34 pm
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.

Posted: Wed Jun 24, 2009 1:47 pm
by hybrid
Check the examples. Example 15 does exactly what you want.

Posted: Wed Jun 24, 2009 2:01 pm
by koso
example 15 show getting node by type.I need getting by name. :cry:

Posted: Wed Jun 24, 2009 3:44 pm
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

Posted: Wed Jun 24, 2009 4:12 pm
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 !!! ;)

Posted: Wed Jun 24, 2009 4:44 pm
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.

Posted: Wed Jun 24, 2009 4:50 pm
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

Posted: Wed Jun 24, 2009 5:01 pm
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 !!!

Posted: Wed Jun 24, 2009 5:18 pm
by koso
there are loop wich test all nodes in scene."nodes" is from that loop.

Posted: Wed Jun 24, 2009 5:22 pm
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]);
}

Posted: Wed Jun 24, 2009 5:47 pm
by koso
thanks.now it works :)