/* OpenSceneGraph example, osgterrain. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include #include #include #include #include struct CustomCompileCompletedCallback : public osgUtil::IncrementalCompileOperation::CompileCompletedCallback { CustomCompileCompletedCallback(): completed(false) {} virtual bool compileCompleted(osgUtil::IncrementalCompileOperation::CompileSet* compileSet) { OSG_NOTICE<<"compileCompleted"< incrementalCompile = new osgUtil::IncrementalCompileOperation; viewer.setIncrementalCompileOperation(incrementalCompile.get()); double timeBetweenMerges = 2.0; while(arguments.read("--interval",timeBetweenMerges)) {} typedef std::vector< osg::ref_ptr > Models; Models models; for(int pos=1;posgetName().empty()) node->setName( arguments[pos] ); models.push_back(node); } } } OSG_NOTICE<<"models.size()="< group = new osg::Group; unsigned int modelIndex = 0; group->addChild(models[modelIndex++].get()); viewer.setSceneData(group); viewer.realize(); double timeOfLastMerge = viewer.getFrameStamp()->getReferenceTime(); osg::ref_ptr compileCompletedCallback; while(!viewer.done()) { viewer.frame(); double currentTime = viewer.getFrameStamp()->getReferenceTime(); if (!compileCompletedCallback && modelIndextimeBetweenMerges) { OSG_NOTICE<<"Compiling model "< compileSet = new osgUtil::IncrementalCompileOperation::CompileSet(models[modelIndex].get()); compileCompletedCallback = new CustomCompileCompletedCallback; compileSet->_compileCompletedCallback = compileCompletedCallback; incrementalCompile->add(compileSet.get()); } if (compileCompletedCallback.valid() && compileCompletedCallback->completed) { OSG_NOTICE<<"Merging model "<removeChildren(0,group->getNumChildren()); group->addChild(models[modelIndex++].get()); viewer.home(); } } return 0; }