loadScene and rootNode

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
JLouisB
Posts: 67
Joined: Tue Jul 24, 2012 12:36 pm
Location: France

loadScene and rootNode

Post by JLouisB »

Hi,

I have a problem with ISceneManager::loadScene().
When I use the value by default rootNode = 0 to load my scene, it works well.
But when I want use a specific rootNode for my scene, my program crash...

Code: Select all

            if (!baseNode)
                baseNode = m_scnMgr->addEmptySceneNode(); 
            m_scnMgr->loadScene("fileName.irr", 0);
// Works
  

Code: Select all

 
 if (!baseNode)
                baseNode = m_scnMgr->addEmptySceneNode(); 
            m_scnMgr->loadScene("fileName.irr", 0, baseNode);
// Don't works
  
I have try to load example.irr of the media folder with a specific root node, and it works.
But with a basic scene exported with CopperCube-Irredit 4.0 I have a crash.

 

Code: Select all

 
 if (!baseNode)
                baseNode = m_scnMgr->addEmptySceneNode(); 
            m_scnMgr->loadScene("example.irr", 0, baseNode);
// Works
 
A basic .irr made with CopperCube :
https://dl.dropboxusercontent.com/u/24460773/test18.irr

Do you know why ?
Is it a bug ?
luthyr
Posts: 69
Joined: Wed Dec 30, 2009 5:47 pm

Re: loadScene and rootNode

Post by luthyr »

I'm not sure if this is similar to an issue I had at one point, but when I did something like this, I found out that the root node of the .irr file would come in with a scale of (0,0,0) which would cause crashes for me. I believe I had to edit ISceneNode.h to check if the attribute "Scale" existed before setting it in deserialize (otherwise, it not existing would default to 0,0,0). Not sure if this will fix your issue. It's been a while, and I'm not in front of the code.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: loadScene and rootNode

Post by CuteAlien »

Sorry, but not crashing here when I modify the Irrlicht example 15 to load your .irr file like that:

Code: Select all

 
// load the scene
    if (argc>1)
        smgr->loadScene(argv[1]);
    else
    {
        irr::scene::ISceneNode * node = smgr->addEmptySceneNode();
        smgr->loadScene("../../test18.irr", 0, node);
    }
 
Though I don't have your textures etc - so maybe a problem there.
One think I wonder is - you do that !baseNode check. Does it crash _when_ it creates that node with addEmptySceneNode(), or does it maybe crash in your next run when it already has a node? In the latter case it might be a problem that your node-pointer is invalid (for example removed already).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
JLouisB
Posts: 67
Joined: Tue Jul 24, 2012 12:36 pm
Location: France

Re: loadScene and rootNode

Post by JLouisB »

I have done the test with the example 15.
When I didn't use rootNode like that :

Code: Select all

// load the scene
    if (argc>1)
        smgr->loadScene(argv[1]);
    else
    {
        irr::scene::ISceneNode * node = smgr->addEmptySceneNode();
        smgr->loadScene("../../test18.irr", 0);
    }
It works well.
When I use a rootNode :

Code: Select all

// load the scene
    if (argc>1)
        smgr->loadScene(argv[1]);
    else
    {
        irr::scene::ISceneNode * node = smgr->addEmptySceneNode();
        smgr->loadScene("../../test18.irr", 0, node);
    }
My scene is loaded but the scene isn't visible.
I haven't this problem with example.irr.

A basic .irr and ressources test :
https://dl.dropboxusercontent.com/u/244 ... 18.irr.zip
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: loadScene and rootNode

Post by CuteAlien »

OK, I'm going to move this to bugreports as the loader is simply handling this situation wrong - and that since at least 2 years it seems (it also didn't work before, but ignored the parent, which was arguably better). It tries to load the attributes of the scene (like AmbientLight and BackgroundColor) into the passed scenenode - and Irrlicht serialization of scenenodes is not coded in a way that it notices when this stuff goes wrong. So not only it ignores the parameters for the scene, but even overrides the whole parameters of the EmptySceneNode with zeros. Including it's scale and visibility - which is then really messing up stuff.

I have no quick way to fix this, so best solution for now would be to create a bugreport in the bugtracker and then link to this forum-post there.

There are some workarounds you could do:
1. Fix the root-node after loading by calling node->setVisible(true); and node->setScale( irr::core::vector3df(1,1,1));
Then you have the scene again, just losing the scene-manager attributes (AmbientLight, Backgroundcolor) which you would have to set by hand.
2. Clone a SceneManager (there's a function for that in the ISceneManager interface) and just use an own scenemanager per scene (maybe cleanest solution). That works if you don't need to load sub-scenes. If you need to load sub-scenes then you could still do that and copy over the nodes and even scenemanager settings to the real scenemanager.

Sorry that I can't do more currently. I hope it helps a little bit.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
JLouisB
Posts: 67
Joined: Tue Jul 24, 2012 12:36 pm
Location: France

Re: loadScene and rootNode

Post by JLouisB »

Ok, thank you for your answer.
Post Reply