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; } }
bool OSGSceneItem::init(UInt32 uiInitPhase, App *pApp) { fprintf(stderr, "OSGSceneItem::init %s (%x)\n", getName(this), uiInitPhase); if(0x0000 != (uiInitPhase & ::OSG::InitPhase::LoadReferences)) { if(_sfMatchedUrl.getValue().empty() == false) { fprintf(stderr, "Loading %s\n", _sfMatchedUrl.getValue().c_str()); NodeUnrecPtr pRoot = SceneFileHandler::the()->read( _sfMatchedUrl.getValue().c_str(), NULL, NULL, false); fprintf(stderr, "got %p\n", pRoot.get()); if(pRoot != NULL) { setRoot(pRoot); } else { fprintf(stderr, " failed\n"); } } if(_sfMatchedGlobalUrl.getValue().empty() == false) { fprintf(stderr, "Loading global %s\n", _sfMatchedGlobalUrl.getValue().c_str()); FieldContainerUnrecPtr pRes(NULL); _oPathHandler.pushState(); _oPathHandler.setBaseFile(_sfMatchedGlobalUrl.getValue().c_str()); ImageFileHandler::the()->setPathHandler(&_oPathHandler); fprintf(stderr, "loading osg file %s ...\n", _sfMatchedGlobalUrl.getValue().c_str()); pRes = OSG::OSGSceneFileType::the().readContainer( _sfMatchedGlobalUrl.getValue().c_str(), NULL); ImageFileHandler::the()->setPathHandler(NULL); _oPathHandler.popState(); fprintf(stderr, "got global %p\n", pRes.get()); if(pRes != NULL) { ContainerCollectionUnrecPtr pColl = dynamic_pointer_cast<ContainerCollection>(pRes); if(pColl != NULL) { MFUnrecFieldContainerPtr::const_iterator fIt = pColl->getMFContainers()->begin(); MFUnrecFieldContainerPtr::const_iterator fEnd = pColl->getMFContainers()->end(); while(fIt != fEnd) { this->pushToGlobals(*fIt); ++fIt; } } } else { fprintf(stderr, " failed\n"); } fprintf(stderr, "got %ld globals\n", _mfGlobals.size()); if(_sfActiveCamera.getValue().empty() == false) { FieldContainer *pCnt = findNamedComponent( _sfActiveCamera.getValue().c_str()); Camera *pCam = dynamic_cast<Camera *>(pCnt); fprintf(stderr, "found camera %p\n", pCam); setCamera(pCam); } } } return true; }