zoukankan      html  css  js  c++  java
  • NodeVisitor的使用-遍历Geode节点并在它与父节点之间添加一个LOD节点

    #include <osgNodeVisitor>
    #include <osgMatrixTransform>
    #include <osgPagedLOD>
    #include <osgDBFileNameUtils>
    #include <osgGeode>
    #include <strstream>

    //只能处理osgExp插件导出的单个ive文件
    class InsideLODVisitor : public osg::NodeVisitor
    {
    public:
    InsideLODVisitor(float_rangeScale=50):rangeScale(_rangeScale),
    osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
    {
    }
    virtual void apply(osg::Geode& geode)
    {
    //检测是否处理过
    if (markedGeode.find(&geode)!=markedGeode.end())
    {
    return;
    }
    //记录已经处理
    markedGeode.insert(&geode);
    //在geode的父节点和geode之间插入一个LOD节点
    unsigned int parentNum=geode.getNumParents();
    osg::Node::ParentList parents=geode.getParents();
    for (osg::Node::ParentList::iterator itr =parents.begin(); itr<parents.end(); itr++)
    {
    osg::ref_ptr<osg::LOD> lod=new osg::LOD;
    lod->addChild(&geode, 0, geode.getBound().radius()*rangeScale);
    //osg::ref_ptr<osg::Geode> tmpGeode=dynamic_cast<osg::Geode*>(geode.clone(osg::CopyOp::DEEP_COPY_ALL));
    //osgUtil::Simplifier simplifier(0.5);
    //tmpGeode->accept(simplifier);
    //lod->addChild(tmpGeode, geode.getBound().radius()*rangeScale, FLT_MAX);
    (*itr)->replaceChild(&geode, lod);
    }
    }
    private:
    std::set<osg::Geode*> markedGeode;
    float rangeScale;
    };

  • 相关阅读:
    leetcode18
    CSS 1. 选择器
    HTML
    练习题|MySQL
    练习题||并发编程
    第八章| 3. MyAQL数据库|Navicat工具与pymysql模块 | 内置功能 | 索引原理
    mysql练习
    第八章| 2. MySQL数据库|数据操作| 权限管理
    第八章| 1. MySQL数据库|库操作|表操作
    第七章|7.4并发编程| I/O模型
  • 原文地址:https://www.cnblogs.com/coolbear/p/4587744.html
Copyright © 2011-2022 走看看