void FltExportVisitor::apply( osg::LOD& lodNode ) { _firstNode = false; ScopedStatePushPop guard( this, lodNode.getStateSet() ); // LOD center - same for all children osg::Vec3d center = lodNode.getCenter(); // Iterate children of the LOD and write a separate LOD record for each, // with that child's individual switchIn and switchOut properties for ( size_t i = 0; i < lodNode.getNumChildren(); ++i ) { osg::Node* lodChild = lodNode.getChild(i); // Switch-in/switch-out distances may vary per child double switchInDist = lodNode.getMaxRange(i); double switchOutDist = lodNode.getMinRange(i); writeLevelOfDetail( lodNode, center, switchInDist, switchOutDist); writeMatrix( lodNode.getUserData() ); writeComment( lodNode ); // Traverse each child of the LOD writePushTraverseWritePop( *lodChild ); } }
void apply(osg::LOD& lod) { // find the highest LOD: int minIndex = 0; float minRange = FLT_MAX; for(unsigned i=0; i<lod.getNumRanges(); ++i) { if ( lod.getRangeList()[i].first < minRange ) { minRange = lod.getRangeList()[i].first; minIndex = i; } } //remove all but the highest: osg::ref_ptr<osg::Node> highestLOD = lod.getChild( minIndex ); lod.removeChildren( 0, lod.getNumChildren() ); //add it back with a full range. lod.addChild( highestLOD.get(), 0.0f, FLT_MAX ); traverse(lod); }