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;
};
NodeVisitor的使用-遍历Geode节点并在它与父节点之间添加一个LOD节点的更多相关文章
- NodeVisitor的使用-遍历Geode节点下的Geometry并获取顶点、法向量等数据
struct Subset { std::vector<float> vertexs;//位置 std::vector<float> normals;//法向 std::vec ...
- centos8平台redis cluster集群添加/删除node节点(redis5.0.7)
一,当前redis cluster的node情况: 我们的添加删除等操作都是以这个cluster作为demo cluster采用六台redis,3主3从 redis1 : ip: 172.17.0.2 ...
- SQL SERVER 2000 遍历父子关系数据的表(二叉树)获得所有子节点 所有父节点及节点层数函数
---SQL SERVER 2000 遍历父子关系數據表(二叉树)获得所有子节点 所有父节点及节点层数函数---Geovin Du 涂聚文--建立測試環境Create Table GeovinDu([ ...
- [leetcode-117]填充每个节点的下一个右侧节点指针 II
(1 AC) 填充每个节点的下一个右侧节点指针 I是完美二叉树.这个是任意二叉树 给定一个二叉树 struct Node { int val; Node *left; Node *right; Nod ...
- easyui 获取树的平级根节点的父节点&选择性展示树的一个根节点
1.easyui的树的根节点一般是几个平级的,怎样获取这些父节点的id? 可以将获取到的平级根节点放在一个数组中 var roots=[]; roots=$("#tree1").t ...
- JavaScript---Dom树详解,节点查找方式(直接(id,class,tag),间接(父子,兄弟)),节点操作(增删改查,赋值节点,替换节点,),节点属性操作(增删改查),节点文本的操作(增删改查),事件
JavaScript---Dom树详解,节点查找方式(直接(id,class,tag),间接(父子,兄弟)),节点操作(增删改查,赋值节点,替换节点,),节点属性操作(增删改查),节点文本的操作(增删 ...
- 剑指offer25:复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),结果返回复制后复杂链表的head。
1 题目描述 输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的head.(注意,输出结果中请不要返回参数中的节点引用 ...
- 117. 填充每个节点的下一个右侧节点指针 II
Q: 给定一个二叉树 struct Node { int val; Node *left; Node *right; Node *next; } 填充它的每个 next 指针,让这个指针指向其下一个右 ...
- Java实现 LeetCode 117 填充每个节点的下一个右侧节点指针 II(二)
117. 填充每个节点的下一个右侧节点指针 II 给定一个二叉树 struct Node { int val; Node *left; Node *right; Node *next; } 填充它的每 ...
随机推荐
- protect和private 的区别
protect和private 的区别 public 表示全局,类内部外部子类都可以访问: private表示私有的,只有本类内部可以使用: protected表示受保护的,只有本类或子类或父类中可以 ...
- 输入三个数a,b,c,要示按由小到大的顺序输出
#include<stdio.h>int main(){ double a,b,c,t; scanf("%lf %lf %lf",&a, ...
- 【C语言入门教程】2.7 表达式
表达式由运算符.常量及变量构成,C语言的表达式基本遵循一般代数规则.有几种运算法则是 C 语言表达式特有的. 2.7.1 表达式中的类型转换 同一表达式中的不同类型常量及变量在运算时需要变量为同一数据 ...
- Linux 开机启动方式设置 inittab 详解,开机直接进入“命令行”模式
Linux下的 /etc/inittab 中的英文解释: This file describes how the INIT process should set up the system in a ...
- Mac Pro 编译安装 PHP 5.6.21 及 问题汇总
[系统环境] 操作系统:OS X 10.11.5 Xcode:7.3.1 [注意] 编译之前,需要安装 xcode.Homebrew 套件! Mac Pro 安装 Homebrew 软件包管理工具 1 ...
- ubutu安装搜狗
1.下载deb文件 下载32位 wget "http://pinyin.sogou.com/linux/download.php?f=linux&bit=32" -O &q ...
- springMVC之国际化
1.工程结构 2.jar包 3.配置文件spring-config.xml,springMVC配置文件 <?xml version="1.0" encoding=" ...
- Unity3D性能优化--- 收集整理的一堆
http://www.cnblogs.com/willbin/p/3389837.html 官方优化文档--优化图像性能http://docs.unity3d.com/Documentation/Ma ...
- 快速排序python实现
#--×--coding:utf-8-*- def main(): nlist = [] while 1: tmp = raw_input("Please input your elemen ...
- Intent flag 与启动模式的对应关系
Activity有四种启动模式: 1.standard(标准) 2.singleTop 3.singleTask 4.singleInstance 标识某个Activity的启动模式,有 ...