资源简介
osg用约束线去掉想去掉三角网的区域,实现地形的裁剪和编辑,方便灵活。

代码片段和文件信息
/**********************************************************
*Write by FlySky
*zzuxp@163.com http://www.OsgChina.org
**********************************************************/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “Tex.h“
int main()
{
osg::ref_ptr viewer = new osgViewer::Viewer();
//方便查看在多边形之间切换,以查看三角网
viewer->addEventHandler( new osgGA::StateSetManipulator(viewer->getCamera()->getOrCreateStateSet()) );
osg::ref_ptr root = new osg::Group();
//画约束线
osgUtil::DelaunayConstraint * dc=new osgUtil::DelaunayConstraint;
//std::ostringstream what;
osg::ref_ptr bounds = new osg::Vec3Array();
bounds->push_back(osg::Vec3(600041461-32.0));
bounds->push_back(osg::Vec3(600641461-32.0));
bounds->push_back(osg::Vec3(600641461+32.0));
bounds->push_back(osg::Vec3(600041461+32.0));
dc->setVertexArray(bounds);
dc->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP04) );
//创建顶点数组
osg::ref_ptr coords = new osg::Vec3Array();
//计算顶点数组的大小
int n;
n = sizeof(vertex)/sizeof(float[3]);
//添加顶点数据
for( unsigned int i = 0; i < n; i++ )
{
coords->push_back( osg::Vec3(vertex[i][0] vertex[i][1] vertex[i][2] ));
}
//创建Delaunay三角网对象
osg::ref_ptr dt = new osgUtil::DelaunayTriangulator(coords.get());
dt->addInputConstraint(dc);
//生成三角网
dt->triangulate();
dt->removeInternalTriangles(dc);
//创建几何体
osg::ref_ptr geometry = new osg::Geometry();
//设置顶点数组
geometry->setVertexArray(coords.get());
//加入到绘图基元
geometry->addPrimitiveSet(dt->getTriangles());
//添加到叶节点
osg::ref_ptr geode = new osg::Geode();
geode->addDrawable( geometry.get());
root->addChild(geode.get()) ;
//osgDB::writeNodeFile(*(root)“SJW.osg“);
//优化场景数据
osgUtil::Optimizer optimizer ;
optimizer.optimize(root.get()) ;
viewer->setSceneData(root.get());
viewer->realize();
viewer->addEventHandler(new osgViewer::WindowSizeHandler);
viewer->run();
return 0 ;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2496 2016-01-15 17:38 main.cpp
文件 46586 2015-03-06 11:20 Tex.h
----------- --------- ---------- ----- ----
49082 2
- 上一篇:EXCEL简繁体转换工具
- 下一篇:PB程序自动升级,检测版本自动更新程序
相关资源
- OSG 72集视频教程和资料140620
- osg爆炸仿真及火烟模拟
- OpenSceneGraph 3.0 Beginner’s Guide.pdf
- 点云数据读取 使用osg 附带点云数据
- osg显示点云
- OSG入门书籍之一:OpenSceneGraph Quick S
- osg3.0.0.rar
- 本人亲自编译的最全的64位osg3.4第三方
- 可以在osg3.4+osgEarth2.8中使用的64位VP
- osgi自定义控制台命令demo
- OSG与OSGB批量转化工具
- osg入门级教材
- OSGB模型3MX索引生成工具v0.1.exe
- CISSP官方學習指南英文第七版
- OSG官方入门教程包含程序代码
- OSG3.4.0读取FBX插件
- osgbobjdae格式数据相互转换工具
- osg地形绘制
- OpenSceneGraph-3.4.0版本安装包
- VPB的所有版本
- OSG-Cookbook.pdf一本学习OSG难得的好书
- OpenSceneGraph-OpenSceneGraph-3.4.0.rar
- OsgEarth2.8 使用高程和影像
- osg经典入门教程
- 用OSG实现的实时仿真的雷达波效果
- osg天空盒源程序
- OSG载入地形和模型文件
- OpenSceneGraph快速入门指导.pdf
- OpenSceneGraph三维渲染引擎设计与实践
- osg 海量数据处理
评论
共有 条评论