I made a tool for editing a .scene and therefore I needed to swich between ST_GENERIC and ST_EXTERIOR_CLOSE to support landscape in scenes.
You can also use this code to switch between any type of SceneManager, e.g. to switch between outdoor and indoor rendering.
Note: For a whole framework around this code, check out Basic Tutorial 8. If you just want the essential code, read on.
Code:
void SwitchManager(SceneType mType) { mWnd->removeAllViewports(); mScene->removeAllCameras(); mScene = Root::getSingleton().getSceneManager(mType); mCam = mScene->createCamera("Main Camera"); mCam->setPosition(0, 0, 300); mCam->lookAt(0, 0, 0); mWnd->addViewport(mCam); currSceneType = mType; }
mWnd is a RenderWindow pointer to the window that I created in my Init function. mScene is a SceneManager pointer and mCam is a Camera pointer.
If your window is automatically created, you can add this code before the removeAllViewports() to get it:
mWnd = Root::getSingleton().getAutoCreatedWindow();
The idea is that you can change your SceneManager if you remove your viewport. So this code removes the viewports, changes the SceneManager and recreates the viewport and camera.
Note: The camera has to be recreated, otherwise it will display the old scene.