Getting node parent

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
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Getting node parent

Post by Tyn »

Hey

It appears that there is no function to get a node's parent, is there a way to get access to the node.Parent attribute without having to add a getParent function to ISceneNode?

Also, before I get the parent node, how can I check whether the node has a parent? It would only cause error's if I try to store a non-existant parent into a node, once I try to use that node it will cause a crash.

Cheers.
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

Hi Tyn,
seems there is no other way to get the parent than implementing getParent() in ISceneNode. But it's easy (no other file has to be changed) and works well. I wonder why it's not in there by default. Maybe Niko just forgot.

ISceneNode.h

Code: Select all

virtual ISceneNode* getParent() {
	return Parent;
}
Also checkin if there is a parent has same easyness:

Code: Select all

if (node->getParent()) {
	...
}
greets,
jox
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

Yeah, that's what I was planning to do. Should be something that is in the engine by default, like you said.
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

This is a very important feature. It must be set as default.
Post Reply