Why not expose the scenemanager in Node

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
powerpop
Posts: 171
Joined: Thu Jan 08, 2004 1:39 am
Location: san francisco

Why not expose the scenemanager in Node

Post by powerpop »

I noticed that Node has a private variable for the scenemanager but does not have a getSceneNode method - why is that? - it would be fantastic if i did not have to store the scenemanager with every instance of Node that i make in my game - if i can just say node->getSceneManager(); !!
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

You're just storing a pointer to the scene manager, it's only 4 bytes.
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

boog, i think PP's point is that its already in Node, so why should he have to keep an seperate, extra pointer of his own. especially when its only used in conjunction with the Node anyway.
a screen cap is worth 0x100000 DWORDS
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

Ohh, ok. Good point.
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

The variable is actually protected, not private, so you should be able to access it if you need it, from every scene node. If you need the manager outside of a scene node, you could get it by callind IrrlichtDevice->getSceneManager(). Isn't that enough?
powerpop
Posts: 171
Joined: Thu Jan 08, 2004 1:39 am
Location: san francisco

Post by powerpop »

possibly (i didnt realize it was only protected) - but i still see some cases in my app where i have a handle to node and want to walk the scenemanager tree to find other objects nearby - so it still would be good to expose the scenemanager - since the primary purpose of nodes is to hang on the scenemanager tree it would be nice for apps to be able to climb that tree starting at any node - so i would still ask that it be exposed through a get function while remaining a private variable (i dont think apps should be able to set it - unless there is a plan to allow multiple scenemanagers in the future ;)
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

If you want to visit every scene node, you can use ISceneNode::getChildren(). The very first scene node of the scene can be accessed by calling ISceneManager::getRootSceneNode (). Maybe this helps you a little bit - unless I didn't misunderstand your problem.
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

Also, getParent() will climb up the tree.

You would probably benefit from making your IrrlichtDevice a global object in your project. It's important enough to want access to it from anywhere. Keless's ICE project sounds like it does something like this for you (I haven't checked it out myself yet). OO conventions are great and all, but don't really ideally fit every programming situation.
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

technically the IrrLicht device is hidden as a member variable of the very base class game_StateHandler, however it is passed down to practically every graphics-related class thereafter, so it may as well be global.

"OO conventions are great and all, but don't really ideally fit every programming situation"

thats true. for instance, my ICE framework has a great state-based core. This works very well for most applications, but if you've got a super-intense engine with a virtual machine sort of concept-- where you actually have a kernal processing 'tasks' (such as Richard Fine's "Enginuity"), ICE wont be the best approach. No one here is doing that sort of thing yet though, as far as I know :wink:
a screen cap is worth 0x100000 DWORDS
powerpop
Posts: 171
Joined: Thu Jan 08, 2004 1:39 am
Location: san francisco

Post by powerpop »

ah, those calls are good for climbing the node tree

i just hate passing around scenemanager as a global AND currently i store a pointer to scenemanager in every object i create - this also seems like a waster because it is already embedded in each node - why not have a get function for something so important?

i use it for instance when i want to tell an object to clone itself - so i need to know the scenemanager and get another copy of the mesh, etc.

it just seems like the scenemanager does a lot of the heavy lifting around nodes and i am trying to limit how much of my code is exposed to irrlicht dependencies - so i dont want a scenemanager global - nor do i want a state object that every object also has to know about to get a handle to the scenemanager - by exposing the scenemanager with a get function i can bury the object manipulation down in my lowest class and never look at it again!
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

Not to bring this topic back from the dead but how do you climb back up the scene node tree? No getParent() function exists which is a pain in the arse because I need it to check where in the screen graph I am.
Post Reply