NodeVisitor的使用-遍历Geode节点并在它与父节点之间添加一个LOD节点
#include <osg\NodeVisitor>
#include <osg\MatrixTransform>
#include <osg\PagedLOD>
#include <osgDB\FileNameUtils>
#include <osg\Geode>
#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;
};
最新文章
- ABP(现代ASP.NET样板开发框架)系列之1、ABP总体介绍
- 关于DataTable添加新列到指定列的方法
- [Android]电话拨号器开发
- 任务调度开源框架Quartz动态添加、修改和删除定时任务
- ORACLE 10G 闪回建议
- [ACM_模拟] The Willy Memorial Program (poj 1073 ,联通水管注水模拟)
- ios-点击图片放大,背景变半透明
- 在xargx命令中如何使用重定向
- ThinkPHP之中的getField、Find、select、返回数据类型详解(ThinkPHP之中所有数据读取了)
- Path Sum的变体
- 【POJ 3162】 Walking Race (树形DP-求树上最长路径问题,+单调队列)
- winform音频播放器(有声小说[凡人修仙传])
- Tess4J OCR简单使用教程
- WordPress在Centos下Apache设置伪静态方法
- ajax post 提交数据和文件
- virtualization - Ubuntu Budgie screen distortion in Hyper-V - Ask Ubuntu
- Win10一直弹出 用户账户控制 解决
- Docker for windows10 配置阿里云镜像
- TCC细读 - 3 恢复流程
- idea找不到import project
热门文章
- 【PHP面向对象(OOP)编程入门教程】1.什么是面向对象?
- Linux/CentOS 同步网络时间
- php curl 库使用
- Code First02---CodeFirst配置实体与数据库映射的两种方式
- 谈谈jQuery之绑定事件
- 线段树区间更新&;&;求和poj3486
- dp题目列表
- Python自动化之IO多路复用
- ubuntu下配置apache2多域名(apache2.4.6)
- Linux CAT与ECHO命令详解 <;<;EOF EOF