Get ChildNode of IRRScene Node

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
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Get ChildNode of IRRScene Node

Post by cookie »

Hello, I'm loading my IRRScene File which got many childrens at one parent-node. I just know the name of the Parent node and want to get one Child Node out of the children list, but I don't know how I could do this. I just know the typeName of the ChildNode.

Thanks for help
randomMesh
Posts: 1187
Joined: Fri Dec 29, 2006 12:04 am

Re: Get ChildNode of IRRScene Node

Post by randomMesh »

You could do something like this

Code: Select all

	// find all nodes
	irr::core::array<irr::scene::ISceneNode*> nodes;
	sceneManager->getSceneNodesFromType(irr::scene::ESNT_ANY, nodes);

	const irr::u32 numNodes = nodes.size();

	for (irr::u32 n = 0; n < numNodes; ++n)
	{
		irr::scene::ISceneNode* const node = nodes[n];

		const irr::scene::ESCENE_NODE_TYPE& type = node->getType();
		const irr::s32 id = node->getID();
		const irr::c8* name = node->getName();

		//check type, id and name of node and do something with it
	}
or even better:

Code: Select all

	irr::scene::ISceneNode* parentNode = sceneManager->getSceneNodeFromName("parentNodesName");
	irr::core::list<irr::scene::ISceneNode*> children = parentNode->getChildren();
	irr::core::list<irr::scene::ISceneNode*>::ConstIterator start = children.begin();
	const irr::core::list<irr::scene::ISceneNode*>::ConstIterator& end = children.end();

	for (; start != end; ++start)
	{
		irr::scene::ISceneNode* const node = (*start);

		const irr::scene::ESCENE_NODE_TYPE& type = node->getType();
		const irr::s32 id = node->getID();
		const irr::c8* name = node->getName();
	}
"Whoops..."
Post Reply