OSG 裁剪回调
来源:互联网 发布:生日提醒软件 编辑:程序博客网 时间:2024/05/21 22:32
struct DrawableCullCallback : public osg::Drawable::CullCallback//自定义裁剪回调节点{/** do customized cull code.*/virtual bool cull(osg::NodeVisitor*, osg::Drawable* drawable, osg::State* /*state*/) const{std::cout<<"Drawable cull callback "<<drawable<<std::endl;return false;}};geode.getDrawable(i)->setCullCallback(new DrawableCullCallback());//为节点设置裁剪回调void ViewerBase::frame(double simulationTime){renderingTraversals();//从渲染回调更新开始} void ViewerBase::renderingTraversals(){for(Cameras::iterator camItr = cameras.begin();camItr != cameras.end();++camItr){osg::Camera* camera = *camItr;Renderer* renderer = dynamic_cast<Renderer*>(camera->getRenderer());if (renderer){if (!renderer->getGraphicsThreadDoesCull() && !(camera->getCameraThread())){renderer->cull();}}}} void Renderer::cull(){sceneView->cull();// osgUtil::SceneView* sceneView } void SceneView::cull(){bool computeNearFar = cullStage(getProjectionMatrix(),getViewMatrix(),_cullVisitor.get(),_stateGraph.get(),_renderStage.get(),getViewport());} bool SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& modelview, osgUtil::CullVisitor* cullVisitor, osgUtil::StateGraph* rendergraph, osgUtil::RenderStage* renderStage, osg::Viewport *viewport){// traverse the scene graph to generate the rendergraph. // If the camera has a cullCallback execute the callback which has the // requirement that it must traverse the camera's children.{osg::NodeCallback* callback = _camera->getCullCallback();if (callback) (*callback)(_camera.get(), cullVisitor);else cullVisitor->traverse(*_camera);}} inline void NodeVistor:: traverse(Node& node)//裁剪回调的Vistor{if (_traversalMode==TRAVERSE_PARENTS) node.ascend(*this);else if (_traversalMode!=TRAVERSE_NONE) node.traverse(*this);} inline void CullVisitor:: handle_cull_callbacks_and_traverse(osg::Node& node){osg::NodeCallback* callback = node.getCullCallback();//调用的Node的Callback,再经过一系列的过程,调用Node下Drawable的callback,如下if (callback) (*callback)(&node,this);else traverse(node);} void CullVisitor::apply(Geode& node){for(unsigned int i=0;i<node.getNumDrawables();++i){Drawable* drawable = node.getDrawable(i);const BoundingBox &bb =drawable->getBound();if( drawable->getCullCallback() ){if( drawable->getCullCallback()->cull( this, drawable, &_renderInfo ) == true )continue;}} }virtual bool Drawable::cull(osg::NodeVisitor* nv, osg::Drawable* drawable, osg::RenderInfo* renderInfo) const{ return cull(nv, drawable, renderInfo? renderInfo->getState():0); }
- OSG 裁剪回调
- OSG回调机制
- OSG学习:裁剪变换(1)
- OSG学习:裁剪变换(2)
- OSG-更新和回调
- OSG 更新回调(二种方法)
- osg的NodeCallback回调使用方法
- OSG节点访问、更新和回调
- osg的NodeCallback回调使用方法
- OSG
- osg
- OSG
- osg-
- OSG
- osg
- OSG
- OSG学习1——事件回调
- 矩阵变换、osg的回调、动画路径和Geometry
- Android入门教程(三)之------导入现有Android工程
- qt中显示汉字乱码问题
- Android入门教程(四)之------Android工程目录结构介绍
- PHP-Fcgi下PHP的执行时间设置方法
- Android入门教程(五)之------第一个Android工程HelloAndroid
- OSG 裁剪回调
- linux kernel data struct : 随机产生一副扑克牌
- access 2003 取消数据库密码
- int * * a[10] int * (*a)[10]和 int(*a[10])()的区别
- 怎样在WIN7系统下安装IIS
- Python 之 list 使用
- win7 打开防火墙端口
- 建库报错,ORA-04080
- Sorting Mini-HOW TO