OSG 中 相交測试 模块 工作流程及原理
主要涉及三个类:
1. osgUtil::PolytopeIntersector // 详细不同算法实现类
2. osgUtil::IntersectionVisitor //用来遍历节点树的每一个节点
3.osg::Node * mNode; // 你要做相交測试的根节点
先看使用方法:
osg::ref_ptr<osgUtil::PolytopeIntersector> intersector = new osgUtil::PolytopeIntersector(osgUtil::Intersector::WINDOW, xMin, yMin, xMax, yMax);
intersector->setIntersectionLimit(osgUtil::Intersector::LIMIT_ONE_PER_DRAWABLE);
osgUtil::IntersectionVisitor iv( intersector.get() ); mRootNode->accept(iv);
关系
osgUtil::IntersectionVisitor 中含有一个osgUtil::PolytopeIntersector的实例化对象。功能是主要负责遍历每一个节点,然后把每一个节点的信息传入到 osgUtil::PolytopeIntersector 中
(含有一系列的apply方法)如:
void IntersectionVisitor::apply(osg::Group& group)
{
if (!enter(group)) return; traverse(group); leave();
} void IntersectionVisitor::apply(osg::Geode& geode)
{
// OSG_NOTICE<<"apply(Geode&)"<<std::endl; if (!enter(geode)) return; // OSG_NOTICE<<"inside apply(Geode&)"<<std::endl; for(unsigned int i=0; i<geode.getNumDrawables(); ++i)
{
intersect( geode.getDrawable(i) );
} leave();
}
当中enter、leave 、intersect 函数中又会反过来调用 osgUtil::PolytopeIntersector 中对应的方法,如:
inline bool enter(const osg::Node& node) { return _intersectorStack.empty() ? false : _intersectorStack.back()->enter(node); }
inline void leave() { _intersectorStack.back()->leave(); }
inline void intersect(osg::Drawable* drawable) { _intersectorStack.back()->intersect(*this, drawable); }
inline void push_clone() { _intersectorStack.push_back ( _intersectorStack.front()->clone(*this) ); }
inline void pop_clone() { if (_intersectorStack.size()>=2) _intersectorStack.pop_back(); }
这样差点儿全部的算法都集中到了 osgUtil::PolytopeIntersector 中 intersect 方法中
void PolytopeIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable)
假设想写自己的相交測试算法,也基本上仅仅需重写intersect 函数就可以。
OSG 中 相交測试 模块 工作流程及原理的更多相关文章
- 软件測试、ios中的測试概念以及步骤
软件測试: 软件測试的目标是应该服务于软件项目的目标,能够通过建议反馈使用更加高效的方法和工具,提升软件开发效率以及软件开发质量.同一时候还能够通过过一些手段,更早.更快.很多其它地发现缺陷.从容减少 ...
- Struts框架核心工作流程与原理
1.Struts2架构图 这是Struts2官方站点提供的Struts 2 的整体结构. 执行流程图 2.Struts2部分类介绍 这部分从Struts2参考文档中翻译就可以了. ActionM ...
- Mali GPU OpenGL ES 应用性能优化--測试+定位+优化流程
1. 使用DS-5 Streamline定位瓶颈 DS-5 Streamline要求GPU驱动启用性能測试,在Mali GPU驱动中激活性能測试对性能影响微不足道. 1.1 DS-5 Streamli ...
- TestNG的组測试和组中组測试
在编写測试的过程中,我们常常遇到仅仅想运行个别或者某一部分/某一类型的測试用例,这时我们能够使用TestNG的分组測试方法 分组測试在配置时.TestNG运行的原则是:仅仅保留最小集合进行运行 看代码 ...
- Cocos2d-x 3.0- 在Visual Studio 2012中执行測试项目
Cocos2d-x - 怎样在Win32执行cpp-tests 2014年4月30日 星期三 小雨 微凉 稍显疲惫 注:本篇文章来自Cocos2d-x官网,小巫仅仅是粗略翻译眼下最新版本号的,教大家怎 ...
- android中单元測试中的断言assert的使用与扩展
首先看一组对照,比方说我们要測试的结果是一个Linearlaout AssertJ Android: assertThat(layout).isVisible() .isVertical() .has ...
- SSM工作流程与原理详解
自学ssm->springboot->springcloud,所以很多东西会用但理解较浅,所以现在从最开始的ssm开始进行对原理以及运行过程的整理知识归纳,若有错误感谢指正. Spring ...
- Appium 框架工作流程及原理
目前Appium框架可以时支持android 和 ios 两个操作系统的App自动化测试,咱们分别对以下两款操作系统的工作流程进行说明. 一.appium-Android工作流 在Android端,a ...
- DNS工作流程及原理 域名、IP与DNS的关系
转自:http://blog.csdn.net/maminyao/article/details/7390208 一.DNS服务概述 DNS是Domain Name System的缩写,即域名系统.其 ...
随机推荐
- Drag & drop a button widget
In the following example, we will demonstrate how to drag & drop a button widget. #!/usr/bin/pyt ...
- javascript 获取页面尺寸/位置
************************************************************************//ie中如果全部不给定值则会都为零(宽和高在设置一个的 ...
- UML基本架构建模--类的辅助信息
Organizing Attributes and Operations 组织属性和操作 When drawing a class, you don't have to show every attr ...
- Android 8款开源游戏引擎
1.Angle (2D Java) Angle是一款专为Android平台设计的,敏捷且适合快速开发的2D游戏引擎,基于OpenGLES技术开发.该引擎全部用Java代码编写,并且可以根据自己 ...
- tomcat发布web项目,支持域名
首先需要安装JDK,不是Linux自带的OpenJDK,参考下面的文章: centos下 安装jdk 设置java环境变量:编辑这个/etc/profile文件: export JAVA_HOME=/ ...
- MySQL查看和修改wait_timeout
1.全局查看wait_timeout值 mysql> show global variables like 'wait_timeout'; 2.修改全局wait_timeout值 set glo ...
- 自定义规则,对List<Map<String,Object>> List<Object>进行排序
package lltse.java.collection; import java.util.ArrayList; import java.util.Collections; import java ...
- 使用VS2012遇到的问题
问题1:VS2012 编译程序时:无法查找或打开PDB文件 解决方法:调试-选项-符号-Microsoft符号服务器打钩,然后确定,就OK了. 问题2:按F5运行.c程序,dos窗口闪退 解决方法:C ...
- unity, water cube
<纪念碑谷>里有一关开始是一个宝箱展开后里面有一个water cube,其中还有小鱼在游.如下截图: 因为我们知道<纪念碑谷>是unity做的,而现在正开始学unity,所以也 ...
- java开发常用到的jar包总结
commons-io.jar: FileUtils 读取文件所有行 File file = new File("c:\\123.txt"); List<String> ...