OSGEARTH3 绘制点线面
Being--
已于 2022-07-26 20:06:29 修改
阅读量3.4k
收藏 50
点赞数 4
分类专栏: OSGEARTH笔记 知识总结 文章标签: gis c++ osgearth
版权
OSGEARTH笔记
同时被 2 个专栏收录
6 篇文章10 订阅
订阅专栏
知识总结
12 篇文章1 订阅
订阅专栏
OSGEARTH3 绘制点线面
创建点
创建面
地形无关的面
绘制一个贴地形的区域
创建线
虚线
直线
3D图元绘制
资源
结合OsgEarth3给的例子学习,并进行尝试后,整理的代码
osgEarth的main处初始化,加载绘制图元:
#include <osgEarth/Common>
#include <gdal_priv.h>
#include <ogr_api.h>
#include <ogr_core.h>
#include <ogr_feature.h>
#include <ogr_geometry.h>
#include <ogrsf_frmts.h>
#include "DrawShape.h"
int main(int argc, char** argv)
{
OGRRegisterAll();
GDALAllRegister();
CPLSetConfigOption("GDAL_DATA", "../../Data/gdal_data");
CPLSetConfigOption("CPL_DEBUG", "YES");
CPLSetConfigOption("CPL_LOG", "../LOG/gdal.log");
osgEarth::initialize();
DrawShapeNS::DoDrawTest();
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void DrawShapeNS::DoDrawTest()
{
// map
osg::Node* globe = osgDB::readNodeFile("../../Data/3d-data/Data/earth/FreeEarth_flat.earth");
osgEarth::MapNode* mapNode = osgEarth::MapNode::get(globe);
// viewer
osgViewer::Viewer viewer;
viewer.setSceneData(mapNode);
/// shape
osg::Group* annoGroup = new osg::Group();
mapNode->addChild(annoGroup);
osg::Group* labelGroup = new osg::Group();
annoGroup->addChild(labelGroup);
osg::ref_ptr<osg::Node> geoRect = DrawRectangle(mapNode->getMapSRS());
annoGroup->addChild(geoRect);
osg::ref_ptr<osg::Node> geoPath = DrawPath(mapNode->getMapSRS());
annoGroup->addChild(geoPath);
osg::ref_ptr<osg::Node> geoCircle = DrawCircle(mapNode->getMapSRS());
annoGroup->addChild(geoCircle);
osg::ref_ptr<osg::Node> geoVolume = DrawVolume(mapNode->getMapSRS());
annoGroup->addChild(geoVolume