[SOLVED] irrSceneMg->addChild calls addSkyBoxSceneNode

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
dc740
Posts: 12
Joined: Fri Dec 26, 2014 1:48 am

[SOLVED] irrSceneMg->addChild calls addSkyBoxSceneNode

Post by dc740 »

I'm trying to re-implement the billboard with a minor changes and I'm experiencing this behavior:
When CSceneManager calls the constructor of the billboard in addBillboardSceneNode, the ISceneNode calls parent->addChild... where the parent is the CSceneManager object in memory.
For a few extra reasons, I'm doing this from outside CSceneManager (I'm re-implementing the billboard), and when I do this:

Code: Select all

 
    ((ISceneNode*) irrSceneMgr)->addChild(bill);
calling ((ISceneNode*) irrSceneMgr)->addChild ends up calling addSkyBoxSceneNode all the time! Why?!

Does anyone know what could be happening?
Thanks for reading!

EDIT:
while I still don't know what's wrong, I used getRootSceneNode() to get the right ISceneNode to use as parent and create the billboard. I guess we can say this has been "solved"
Last edited by dc740 on Mon Dec 29, 2014 1:47 am, edited 2 times in total.
dc740
Posts: 12
Joined: Fri Dec 26, 2014 1:48 am

Re: ((ISceneNode*) irrSceneMg->addChild calls addSkyBoxScene

Post by dc740 »

here is the debug output and object information about the SceneManager


p irrSceneMgr
$1 = (irr::scene::CSceneManager *) 0x10b1bc0
> ptype irrSceneMgr
type = /* real type = irr::scene::CSceneManager * */
class irr::scene::ISceneManager : public virtual irr::IReferenceCounted {
...methods...
} *
[/quote]


It says it implements ISceneManager and IReferenceCounter, but the irrlicht source code declares it like this:

Code: Select all

class CSceneManager : public ISceneManager, public ISceneNode
Yet the documentation in include/ESceneNodeTypes.h states:

Code: Select all

//! of type CSceneManager (note that ISceneManager is not(!) an ISceneNode)
Can anyone with experience in the irrlicht code help me here? what am I missing?
Ovan
Posts: 70
Joined: Thu Dec 18, 2008 12:41 am
Contact:

Re: ((ISceneNode*) irrSceneMg->addChild calls addSkyBoxScene

Post by Ovan »

don't cast, use smgr->getRootSceneNode()
irrlicht.sourceforge.net/docu/classirr_1_1scene_1_1_i_scene_manager.html#a4f7075320f1a3bf2838f29c23f78635f

you trying to cast to a different type, so he doesn't have a connection on the vtable, the called member is undetermined
CSceneManager is ISceneManager and ISceneNode but ISceneManager isn't an ISceneNode
so the vtable of the returned type match the first type not the second (static_cast could help you)

edit:
search for "vtable cast c++" on google for sample
dc740
Posts: 12
Joined: Fri Dec 26, 2014 1:48 am

Re: ((ISceneNode*) irrSceneMg->addChild calls addSkyBoxScene

Post by dc740 »

Thank you Ovan. I learned that the hard way through experimenting, but I just started assuming a lot of things, without being sure about anything (I edited the original thread about an hour ago). Now it's clear.

http://stackoverflow.com/questions/9138 ... -cast-here

PS: it's also clear that I need a good book on C++. Tutorials are cool for starting on the subject, but that's about it.
Ovan
Posts: 70
Joined: Thu Dec 18, 2008 12:41 am
Contact:

Re: [SOLVED] irrSceneMg->addChild calls addSkyBoxSceneNode

Post by Ovan »

personally i haven't any book, most of them explain the base of cpp and not enter in the depth like this problem
you just need to know the name in the low level and try to connect to your problem with, them ask in google/stackoverflow/isocpp
try to read some Wikipedia article
Post Reply