コード例 #1
0
ファイル: FltExportVisitor.cpp プロジェクト: joevandyk/osg
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 );
    }

}
コード例 #2
0
void
CountsVisitor::apply(osg::LOD& node)
{
    pushStateSet(node.getStateSet());

    _lods++;
    osg::ref_ptr<osg::Object> rp = (osg::Object*)&node;
    _uLods.insert(rp);
    _totalChildren += node.getNumChildren();
    apply(node.getStateSet());

    if (++_depth > _maxDepth)
        _maxDepth = _depth;
    traverse((osg::Node&)node);
    _depth--;

    popStateSet();
}
コード例 #3
0
		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);
		}