Since we can't really ask for a background loader without redesigning the
whole engine. Would be nice to have at least that:
An initial "loadScene_count()" command that -count- the nodes of the scene, but don't load anything at all
A "loadScene_nextNode()" type command that load the next occurence of a node in the current loaded scene in sequence. (mesh, terrain, occtree, light, etc.)
We could have a status function like "sceneloaded() "for example by checking that function that will return the remaining nodes to load. So
this could be used to determine the remaining items in the scene and could update the screen at each nodes loaded remaining. So easy to put in a user defined loop. (Refreshing, the screen at each step)
(Getting the value when ititiating the "loadScene()" command will get the number of remaining nodes when the load was started, giving the total numbers of nodes.)
I've already posted this on the features request on the sourceforge site.
Update: Just checked again the source code! Seen that you already have worked that out! Is the command readSceneNode() is exposed to the user? It does exactly that!
Code: Select all
//! Loads a scene. Note that the current scene is not cleared before.
bool CSceneManager::loadScene(io::IReadFile* file, ISceneUserDataSerializer* userDataSerializer)
{
if (!file)
{
os::Printer::log("Unable to open scene file", ELL_ERROR);
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return false;
}
io::IXMLReader* reader = FileSystem->createXMLReader(file);
if (!reader)
{
os::Printer::log("Scene is not a valid XML file", file->getFileName(), ELL_ERROR);
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return false;
}
// for mesh loading, set collada loading attributes
bool oldColladaSingleMesh = getParameters()->getAttributeAsBool(COLLADA_CREATE_SCENE_INSTANCES);
getParameters()->setAttribute(COLLADA_CREATE_SCENE_INSTANCES, false);
// read file
while(reader->read())
{
readSceneNode(reader, 0, userDataSerializer);
}
// restore old collada parameters
getParameters()->setAttribute(COLLADA_CREATE_SCENE_INSTANCES, oldColladaSingleMesh);
// finish up
reader->drop();
return true;
}
Also instead of having the readSceneNode having a VOID, it could return the node type. Would be really interesting that you expose all the functions related to the scene loading.