OSG简化几何体显示
来源:互联网 发布:剑三成男捏脸数据截图 编辑:程序博客网 时间:2024/04/28 16:50
#include <osgViewer/ViewerEventHandlers>#include <osg/Node>#include <osg/Geode>#include <osg/Group>#include <osg/PositionAttitudeTransform>#include <osgDB/ReadFile>#include <osgDB/WriteFile>#include <osgGA/StateSetManipulator>#include <osgUtil/Optimizer>#include <osgUtil/Simplifier>int main(){ osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer() ; viewer->addEventHandler(new osgGA::StateSetManipulator(viewer->getCamera()->getOrCreateStateSet())) ; osg::ref_ptr<osg::Group> root = new osg::Group() ; float sampleRatio = 0.3f ; // 设置点的最大误差 float maxError = 4.0f ; //创建简化对象 osgUtil::Simplifier simplifier(sampleRatio , maxError) ; // osg::ref_ptr<osg::Node> node1 = osgDB::readNodeFile("cow.osg") ; // 深拷贝 osg::ref_ptr<osg::Node> node2 = (osg::Node *)(node1->clone(osg::CopyOp::DEEP_COPY_ALL)) ; // 创建一个位置变换节点 osg::ref_ptr<osg::PositionAttitudeTransform> pat = new osg::PositionAttitudeTransform() ; pat->setPosition(osg::Vec3(10.0f , 0.0f , 0.0f)) ; pat->addChild(node2.get()) ; //简化处理 pat->accept(simplifier) ; root->addChild(node1.get()) ; root->addChild(pat.get()) ; //优化场景数据 osgUtil::Optimizer optimizer ; optimizer.optimize(root.get()) ; viewer->setSceneData(root.get()) ; viewer->realize() ; viewer->run() ; return 0 ;}
0 0
- OSG简化几何体显示
- osg入门系列13-几何体简化
- osg入门系列11- 预订义几何体
- osg预定义几何体设置颜色
- osg中几何体绘制笔记(一)
- osg预定义几何体设置颜色
- OSG学习:基本几何体绘制示例
- OSG 学习第二天:几何体的绘制
- osg几何体的图元的遍历
- OSG学习:使用OSG中预定义的几何体
- OSG+Duilib显示osg
- OSG基本几何体的透明效果和网格模型
- osg入门系列10-以索引方式的几何体绘制
- OSG绘制几何体学习总结(超全)
- OSG绘制几何体学习总结(超全)
- OSG-Win32窗口显示osg
- osg显示点云
- osg如何显示文字
- 64 位 Hook
- ABC算法
- SH脚本入门总结
- Android最佳的开源库集锦
- bzoj2243: [SDOI2011]染色
- OSG简化几何体显示
- 进化算法(EP)
- React Native 基础教程
- 验证码识别平台推荐
- 【数据结构与算法】希尔排序
- 用c语言写单链表
- activemq消息确认机制
- Intellj Idea 16添加Maven新建模块
- CentOS6.5下Redis安装与配置