void ComplexSceneManager::addGlobals(const std::string &filename)
{
    if(_sfDrawManager.getValue() == NULL)
    {
        return;
    }

    std::string szFilenameResolved = _oPathHandler.findFile(filename.c_str());

    if(szFilenameResolved.empty() == true)
    {
        return;
    }

    FieldContainerUnrecPtr pRes = 
        readOSGFile(szFilenameResolved,
                    boost::bind(&ComplexSceneManager::resolve, this, 
                                _1, _2, _3));

    if(pRes == NULL)
        return;

    ContainerCollectionUnrecPtr pColl = 
        dynamic_pointer_cast<ContainerCollection>(pRes);

    if(pColl == NULL)
        return;

    MFUnrecFieldContainerPtr::const_iterator fIt  = 
        pColl->getMFContainers()->begin();

    MFUnrecFieldContainerPtr::const_iterator fEnd = 
        pColl->getMFContainers()->end();

    while(fIt != fEnd)
    {
        this->pushToGlobals(*fIt);
        ++fIt;
    }   
}
void ComplexSceneManager::addStaticGlobals(const Char8 *szFilename)
{
    std::string szFilenameResolved = _oPathHandler.findFile(szFilename);

    if(szFilenameResolved.empty() == true)
    {
        fprintf(stderr, "Could not find static global file %s\n",
                szFilename);

        return;
    }

    FieldContainerUnrecPtr pRes = 
        readOSGFile(szFilenameResolved,
                    boost::bind(&ComplexSceneManager::resolveStatic, 
                                _1, _2, _3));
    
    if(pRes == NULL)
        return;

    ContainerCollectionUnrecPtr pColl = 
        dynamic_pointer_cast<ContainerCollection>(pRes);

    if(pColl == NULL)
        return;

    MFUnrecFieldContainerPtr::const_iterator fIt  = 
        pColl->getMFContainers()->begin();

    MFUnrecFieldContainerPtr::const_iterator fEnd = 
        pColl->getMFContainers()->end();

    while(fIt != fEnd)
    {
        _vStaticGlobals.push_back(*fIt);

        ++fIt;
    }
}
void ComplexSceneManager::startFrom(const std::string &szParamFilename)
{
    setVBOUsageOnPropertyProtos(true);

    _oPathHandler.clearPathList();
    _oPathHandler.clearBaseFile();

    _oPathHandler.push_frontCurrentDir();

    std::string szParamFileResolved = 
        _oPathHandler.findFile(szParamFilename.c_str());

    if(szParamFileResolved.empty() == true)
    {
        fprintf(stderr, "Could not find param file %s\n", 
                szParamFilename.c_str());

        return;
    }

    _oPathHandler.setBaseFile(szParamFileResolved.c_str());

    OSG::SceneFileHandler::the()->setPathHandler(&_oPathHandler);

    std::vector<std::string> vParams;

    scanParamFile(szParamFileResolved.c_str(), vParams);
    
    scanPreSystem(vParams);

    std::string szSystemFile         = vParams[0];

    std::string szSystemFileResolved = 
        _oPathHandler.findFile(szSystemFile.c_str());

    if(szSystemFileResolved.empty() == true)
    {
        fprintf(stderr, "Could not find system file %s\n",
                szSystemFile.c_str());

        return;
    }

    readOSGFile(szSystemFileResolved,
                boost::bind(&ComplexSceneManager::resolveStatic, _1));

    _vStaticGlobals.clear();

    if(OSG::ComplexSceneManager::the() == NULL)
    {
        fprintf(stderr, "Error could not find any complex scenemanager\n");
        return;
    }

    OSG::SceneFileHandler::the()->setGlobalResolver(
        boost::bind(&ComplexSceneManager::resolve, _the.get(), _1));

    OSG::ComplexSceneManager::the()->init(vParams);
    
    OSG::ComplexSceneManager::the()->run();
}