OsgEarth開發筆記(四):Qt5.15.2整合Osg3.6.3+OsgEarth+OsgQt的vs2019x64
前言
前提
Demo演示:Qt5.15.2+OSG3.6.3+OsgEarth3.1的QtCreator下的msvc2019x64版本
Demo執行程式下載
OsgQt下載
osgQt編譯
步驟一:下載解壓
步驟二:CMake配置
步驟三:CMake配置新增osg環境
步驟四:CMake配置新增Qt環境
步驟五:CMake修改CMakeLists檔案內容:
步驟六:配置透過
步驟七:生成成功
步驟八:開啟工程,進行編譯
模組化
配置檔案
INCLUDEPATH += $$PWD DEPENDPATH += $$PWD QT += opengl FORMS += \ $$PWD/OsgWidget.ui HEADERS += \ $$PWD/OsgViewerWidget.h \ $$PWD/OsgWidget.h \ $$PWD/define.h \ $$PWD/osgQt/include/osgQOpenGL/Export.h SOURCES += \ $$PWD/OsgViewerWidget.cpp \ $$PWD/OsgWidget.cpp \ $$PWD/define.cpp# osgINCLUDEPATH += $$PWD/osg3.6.3-vs2019/include DEPENDPATH += $$PWD/osg3.6.3-vs2019/include LIBS += -L$$PWD/osg3.6.3-vs2019/lib LIBS += -lOpenThreads \ -losg \ -losgAnimation \ -losgDB \ -losgFX \ -losgGA \ -losgManipulator \ -losgParticle \ -losgPresentation \ -losgShadow \ -losgText \ -losgUI \ -losgUtil \ -losgViewer \ -losgVolume \ -losgWidget \ # -losgQt \ -losgSim \ -losgTerrain# osgQtINCLUDEPATH += $$PWD/osgQt/include DEPENDPATH += $$PWD/osgQt/include HEADERS += \ $$PWD/osgQt/include/osgQOpenGL/CullVisitorEx \ $$PWD/osgQt/include/osgQOpenGL/GraphicsWindowEx \ $$PWD/osgQt/include/osgQOpenGL/OSGRenderer \ $$PWD/osgQt/include/osgQOpenGL/RenderStageEx \ $$PWD/osgQt/include/osgQOpenGL/StateEx \ $$PWD/osgQt/include/osgQOpenGL/osgQOpenGLWidget \ $$PWD/osgQt/include/osgQOpenGL/osgQOpenGLWindow SOURCES += \ $$PWD/osgQt/include/osgQOpenGL/CullVisitorEx.cpp \ $$PWD/osgQt/include/osgQOpenGL/GraphicsWindowEx.cpp \ $$PWD/osgQt/include/osgQOpenGL/OSGRenderer.cpp \ $$PWD/osgQt/include/osgQOpenGL/RenderStageEx.cpp \ $$PWD/osgQt/include/osgQOpenGL/StateEx.cpp \ $$PWD/osgQt/include/osgQOpenGL/osgQOpenGLWidget.cpp \ $$PWD/osgQt/include/osgQOpenGL/osgQOpenGLWindow.cpp# osgEarthINCLUDEPATH += $$PWD/osgearth3.1-vs2019/include LIBS += -L$$PWD/osgearth3.1-vs2019/lib LIBS += -losgEarth
Demo原始碼
osg::ref_ptr<osg::Node> OsgWidget::getEarthSphiere(){ osg::ref_ptr<osg::Group> pGroup = new osg::Group; osgEarth::initialize(); const char* styles_css = R"( p { altitude-clamping: terrain-drape; render-backface-culling: false; } p1: p{ fill: #ff3f3f9f; } p2: p{ fill: #3fff3f9f; } p3: p{ fill: #3f3fff9f; } p4: p{ fill: #ff3fff9f; } p5: p{ fill: #ffff3f9f; } )"; const char* script_source = R"( function getStyleClass() { // Exclude any countries beginning with the letter A: if ( feature.properties.name.charAt(0) === 'A' ) return null; // If it starts with the letter C, return an inline style: if ( feature.properties.name.charAt(0) == 'C' ) return '{ _fill: #ffc838; stroke: #8f8838; extrusion-height: 250000; }'; // Otherwise, return a named style based on some calculations: var pop = parseFloat(feature.properties.pop); if ( pop <= 14045470 ) return "p1"; else if ( pop <= 43410900 ) return "p2"; else if ( pop <= 97228750 ) return "p3"; else if ( pop <= 258833000 ) return "p4"; else return "p5"; } )"; osg::ref_ptr<Map> map = new Map(); GDALImageLayer* basemap = new GDALImageLayer(); basemap->setURL("world.tif"); map->addLayer(basemap); // Next we add a layer to provide the feature data. OGRFeatureSource* features = new OGRFeatureSource(); features->setName("vector-data"); features->setURL("world.shp"); map->addLayer(features); Style style; LineSymbol* ls = style.getOrCreateSymbol<LineSymbol>(); ls->stroke()->color() = Color::Yellow; ls->stroke()->width() = 2.0f; ls->tessellationSize()->set(100, Units::KILOMETERS); FeatureModelLayer* layer = new FeatureModelLayer(); layer->setFeatureSource(features); StyleSheet* styleSheet = new StyleSheet(); styleSheet->addStyle(style); layer->setStyleSheet(styleSheet); map->addLayer(layer); LayerVector layers; map->getLayers(layers); for (LayerVector::const_iterator i = layers.begin(); i != layers.end(); ++i) { Layer* layer = i->get(); if (layer->getStatus().isError() && layer->getEnabled()) { OE_WARN << layer->getName() << " : " << layer->getStatus().toString() << std::endl; } } MapNode* mapNode = new MapNode(map.get()); _pViewer->setCameraManipulator(new EarthManipulator()); pGroup->addChild(mapNode); return pGroup.get();}
工程模板
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70010283/viewspace-2849232/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Spring筆記(四)整合MybatisSpring筆記MyBatis
- osgEarth使用筆記4——載入向量資料筆記
- iOS開發筆記(四):frame與bounds的區別詳解iOS筆記
- 低開開發筆記(四):實現編輯器內拖拽筆記
- FFmpeg開發筆記(四)FFmpeg的動態連結庫介紹筆記
- fyne 開發筆記筆記
- Laravel 開發筆記Laravel筆記
- golang 開發筆記Golang筆記
- 【筆記】敏捷開發筆記敏捷
- 嵌入式c++軟體開發第四講筆記C++筆記
- FFmpeg開發筆記(十一)Windows環境給FFmpeg整合vorbis和amr筆記WindowsORB
- FFmpeg開發筆記(四十)Nginx整合rtmp模組實現RTMP推拉流筆記Nginx
- FFmpeg開發筆記(三十五)Windows環境給FFmpeg整合libsrt筆記Windows
- 從零開始學Electron筆記(四)筆記
- FFmpeg開發筆記(三十九)給Visual Studio的C++工程整合FFmpeg筆記C++
- ssm框架整合筆記SSM框架筆記
- RUST 筆記(四)Rust筆記
- git筆記四Git筆記
- FFmpeg開發筆記(十七)Windows環境給FFmpeg整合字幕庫libass筆記Windows
- FFmpeg開發筆記(十)Linux環境給FFmpeg整合vorbis和amr筆記LinuxORB
- 元件包開發筆記元件筆記
- 小程式開發筆記筆記
- Android開發筆記Android筆記
- EBS開發筆記-1筆記
- EBS開發筆記-2筆記
- IOS 開發筆記2iOS筆記
- Java 開發筆記16Java筆記
- 《Java EE網際網路輕量級框架整合開發》讀書筆記Java框架筆記
- FFmpeg開發筆記(二十九)Windows環境給FFmpeg整合libxvid筆記Windows
- FFmpeg開發筆記(十三)Windows環境給FFmpeg整合libopus和libvpx筆記Windows
- FFmpeg開發筆記(二十五)Linux環境給FFmpeg整合libwebp筆記LinuxWeb
- J2EE開發筆記(四)—— pom.xml檔案詳解筆記XML
- Java_EE企業級開發學習筆記——spring學習筆記第四章Java筆記Spring
- 敏捷開發讀書筆記——隨筆敏捷筆記
- 英國史筆記(四)筆記
- 【開發筆記】swift語法小記筆記Swift
- Java併發程式設計實戰--筆記四Java程式設計筆記
- Memcached筆記——(四)應對高併發攻擊筆記