bool SoundUpdateCB_readLocalData(osg::Object &obj, osgDB::Input &fr) { SoundUpdateCB* cb = dynamic_cast<SoundUpdateCB*>( &obj ); /************************************************************************ * Using this code, apps like osgviewer could use this kind of nodes and work, * but they will exit with crash ! ************************************************************************/ if(!SoundManager::instance()->initialized()) { osg::notify(osg::WARN) << "osgdb_osgAudio::SoundUpdateCB_readLocalData(): WARNING!!! "; osg::notify(osg::WARN) << "The osgAudio plugin is initializing the SoundManager. "; osg::notify(osg::WARN) << "So surely nobody will shutdown it, and I will exit with a crash!" << std::endl; osgAudio::SoundManager::instance()->init(16); osgAudio::SoundManager::instance()->getEnvironment()->setDistanceModel(osgAudio::InverseDistance); osgAudio::SoundManager::instance()->getEnvironment()->setDopplerFactor(1); } bool itAdvanced = false; SoundState *ss = dynamic_cast<SoundState*>(fr.readObject()); if(ss != NULL) { cb->setSoundState(ss); itAdvanced = true; } OccludeCallback *oc = dynamic_cast<OccludeCallback*>(fr.readObject()); if(oc != NULL) { cb->setOccludeCallback(oc); itAdvanced = true; } return itAdvanced; }
bool ShadowedScene_readLocalData(osg::Object& obj, osgDB::Input &fr) { osgShadow::ShadowedScene& ss = static_cast<osgShadow::ShadowedScene&>(obj); bool iteratorAdvanced = false; osg::ref_ptr<osg::Object> object=0; while((object=fr.readObject())!=0) { osgShadow::ShadowTechnique* st = dynamic_cast<osgShadow::ShadowTechnique*>(object.get()); if (st) ss.setShadowTechnique(st); iteratorAdvanced = true; } return iteratorAdvanced; }