Cannot scene

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
lenchis001
Posts: 17
Joined: Sun Sep 18, 2016 5:44 pm
Location: Belarus, Grodno

Cannot scene

Post by lenchis001 »

Hello. I am trying load scene from *.irr file with loadScene() method. When not set a root node - all good, but with root node (for example EmptySceneNode) - fail. Viewport is empty. Help me please.

Code: Select all

void TLMManager::addSubScene(wstring name, wstring pathToSceneDescriptor, wstring pathToIDsMap)
{
    std::map<wstring, int> currentSubSceneIDs = loadIDsMap(pathToIDsMap);
    currentSubSceneIDs.insert({ name, this->getUniqueID() });
 
    ISceneNode *rootSceneNode = _sceneManager->addEmptySceneNode(nullptr, currentSubSceneIDs.at(name));
 
    _sceneManager->loadScene(pathToSceneDescriptor.c_str(), nullptr, rootSceneNode);
    ...
}
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: Cannot scene

Post by Seven »

the rootSceneNode does not have a parent

the scenemanager has a built in rootscenenode that all scenenodes are a child of
make it the parent of your rootSceneNode

ISceneNode *rootSceneNode = _sceneManager->addEmptySceneNode( _sceneManager->getRootSceneNode(), currentSubSceneIDs.at(name));

Code: Select all

 
        //! Gets the root scene node.
        /** This is the scene node which is parent
        of all scene nodes. The root scene node is a special scene node which
        only exists to manage all scene nodes. It will not be rendered and cannot
        be removed from the scene.
        \return Pointer to the root scene node.
        This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
        virtual ISceneNode* getRootSceneNode() = 0;
 
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: Cannot scene

Post by Seven »

also, if you truly have independent scenes that you want to make visible / not visible (thereby only rendering the scenenodes in that scene), you might want to create a new scenemanager for each of your scenes

example :

the main smgr is the default irrlicht smgr, it is auto created when irrlicht device is created
ISceneManager* mainSmgr = getDevice()->getSceneManager();


in each of your independent scenes, use the main smgr to create individual smgrs
ISceneManager* anotherSmgr = mainSmgr->createNewSceneManager();

in the manager, simply decide which smgr you want to render.

switch (game_state)
{
case INTRO : getIntroScene()->getSmgr()->draw(); break;
case MENU : getMenuScene()->getSmgr()->draw(); break;
case GAME : getGameScene()->getSmgr()->draw(); break;
}
lenchis001
Posts: 17
Joined: Sun Sep 18, 2016 5:44 pm
Location: Belarus, Grodno

Re: Cannot scene

Post by lenchis001 »

Thank you!
lenchis001
Posts: 17
Joined: Sun Sep 18, 2016 5:44 pm
Location: Belarus, Grodno

Re: Cannot scene

Post by lenchis001 »

But camera from main scene manager does not see meshes from sub scenes managers..
I want draw meshes from few scene managers at the same time.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Cannot scene

Post by CuteAlien »

If you want it to draw together then use a single scenemanager. Thought in theory you can also draw one after the other (calling drawAll from each one), but this will change the order of drawing Irrlicht usually uses and should only be done if you know what you do. For example if transparent things are drawn suddenly before solid objects the transparency will no longer work. Basically the main reason for different scenemanagers is to keep scenes completely independent (not drawing at the same time), or sometimes to ensure some stuff is drawn on top of each other (as you have control over the order of rendering when using more than one scenemanager).
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
Post Reply