I'm having trouble getting the scene manager to fully clear the current scene.
I have separated my code into lots of different "modes." Modes are things like:
splash_screen_mode
main_menu_mode
graphics_menu_mode
audio_menu_mode
level_1_mode
level_2_mode
...
game_over_mode
Each mode has an "init_scene" member that looks like this (for example):
Code: Select all
void level_1_mode::init_scene(irr::scene::ISceneManager *scene)
{
m_camera_node = scene->addCameraSceneNode();
m_camera_node->setUpVector(v3f(0.0f, 0.0f, 1.0f));
m_camera_node->setFOV(0.6f * math::pi);
irr::scene::ILightSceneNode *light = scene->addLightSceneNode();
light->getLightData().SpecularColor.set(0.3f, 0.3f, 0.3f);
light->setLightType(irr::video::ELT_DIRECTIONAL);
light->setRotation(v3f(45.0f, 135.0f, 0.0f));
m_world_center_node = scene->addEmptySceneNode();
m_world_center_node->setPosition(v3f(0.0f, -WORLD_RADIUS, 0.0f));
irr::scene::IAnimatedMesh *world_mesh = scene->getMesh("level_a1.obj");
scene->getMeshManipulator()->scale(world_mesh, v3f(WORLD_MODEL_SCALE, WORLD_MODEL_SCALE, WORLD_MODEL_SCALE));
scene->addMeshSceneNode(world_mesh, m_world_center_node, -1, v3f(0.0f, WORLD_RADIUS, 0.0f));
}
Code: Select all
while (m_device->run())
{
if (change_to_new_mode)
{
// Clear everything from the current mode's scene
m_scene->clear();
// Switch to the new mode
m_current_mode = new_mode;
// Initialize the new mode's scene
m_game_modes[m_current_mode]->init_scene(m_scene);
}
}
How do I really clear the scene so that all meshes are fully reloaded each time I switch to a new mode? I've experimented and found that completely destroying and recreating the Irrlicht device does the trick, but that isn't very desirable, because it closes the whole window, etc...