From a9c19ea5e26a61d2ce0120b8ea06780e86bacdae Mon Sep 17 00:00:00 2001 From: seele2 Date: Mon, 23 Jun 2025 11:32:33 +0800 Subject: [PATCH] first commit --- .gitignore | 4 ++++ 210/210.pro | 36 ++++++++++++++++++++++++++++ 210/main.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 320/320.pro | 20 ++++++++++++++++ 320/main.cpp | 3 +++ readme.md | 3 +++ startOSG.pro | 6 +++++ 7 files changed, 138 insertions(+) create mode 100644 .gitignore create mode 100644 210/210.pro create mode 100644 210/main.cpp create mode 100644 320/320.pro create mode 100644 320/main.cpp create mode 100644 readme.md create mode 100644 startOSG.pro diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3b3f08b --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +build +*.pro.user* +*/third_party +!*/third_party/.gitkeep \ No newline at end of file diff --git a/210/210.pro b/210/210.pro new file mode 100644 index 0000000..3eaab6a --- /dev/null +++ b/210/210.pro @@ -0,0 +1,36 @@ +QT += core gui widgets + +CONFIG += c++17 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + main.cpp + +HEADERS += + +FORMS += + +INCLUDEPATH += $$PWD/third_party/include +LIBS += -L$$PWD/third_party/lib -losgViewerd \ + -losgd \ + -losgDBd \ + -losgUtild \ + -losgGAd \ + -losgEarthd \ + -losgEarthUtild \ + -lOpenThreadsd \ + -losgTextd \ + -losgEarthSymbologyd \ + -losgEarthAnnotationd \ + -losgEarthFeaturesd \ + -losgFXd \ + -losgWidgetd \ + -losgManipulatord + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/210/main.cpp b/210/main.cpp new file mode 100644 index 0000000..c7bca77 --- /dev/null +++ b/210/main.cpp @@ -0,0 +1,66 @@ +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + Q_UNUSED(argc); + Q_UNUSED(argv); + + osgViewer::Viewer viewer; + + viewer.setUpViewInWindow(0, 100, 800, 600); + + viewer.setReleaseContextAtEndOfFrameHint(false); + + // 添加操作器 + viewer.setCameraManipulator(new osgEarth::Util::EarthManipulator()); + + /// 在旧版本的osgEarth中需通过options来指定使用的哪种ImageLayer + + // 创建GDAL图层 + osgEarth::Drivers::GDALOptions options; + options.url() = osgEarth::URI("D:/Code/freespace/JGisEngine/data/image_3d_globel.tif"); + osg::ref_ptr imagelayer = new osgEarth::ImageLayer( + osgEarth::ImageLayerOptions("gdal", options)); + + // 创建MB图层 + osgEarth::Drivers::MBTilesTileSourceOptions mbOpt; + mbOpt.filename() + = "D:/Share/Map/MBTiles/satellite-google-gcj02-zxy-all-9-sc-15-cd-18-3h-21.mbtiles"; + mbOpt.format() = "png"; + mbOpt.computeLevels() = false; + mbOpt.maxDataLevel() = 21; + mbOpt.minValidValue() = 4; + + osg::ref_ptr MBImagelayer = new osgEarth::ImageLayer( + osgEarth::ImageLayerOptions("mb", mbOpt)); + + // string mbtilesFilename = "D:/codes/osgEarth-Projects/osgearth3.4/data/world_countries.mbtiles"; + + // osg::ref_ptr mbtLayer = new MBTilesImageLayer(); + + // mbtLayer->setURL(osgEarth::URI(mbtilesFilename)); + + // osgEarth::GeoExtent mbtExtent = mbtLayer->getExtent(); + + // 添加图层到Map + osg::ref_ptr map = new osgEarth::Map(); + + // map->addImageLayer(imagelayer); + map->addImageLayer(MBImagelayer); + + // 添加Map到Node + osg::ref_ptr mapNode = new osgEarth::MapNode(map); + + // 添加到场景 + viewer.setSceneData(mapNode); + + viewer.realize(); + + return viewer.run(); +} diff --git a/320/320.pro b/320/320.pro new file mode 100644 index 0000000..66d0616 --- /dev/null +++ b/320/320.pro @@ -0,0 +1,20 @@ +QT += core gui widgets + +CONFIG += c++17 + +HEADERS += + +SOURCES += \ + main.cpp + +INCLUDEPATH += $$PWD/third_party/include +LIBS += -L$$PWD/third_party/lib -losgViewerd \ + -losgd \ + -losgDBd \ + -losgUtild \ + -losgGAd \ + -losgFXd \ + -losgEarthd \ + -lOpenThreadsd \ + -losgTextd \ + -losgManipulatord diff --git a/320/main.cpp b/320/main.cpp new file mode 100644 index 0000000..07d6ce4 --- /dev/null +++ b/320/main.cpp @@ -0,0 +1,3 @@ + + +int main() {} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..55b5b1e --- /dev/null +++ b/readme.md @@ -0,0 +1,3 @@ +# OSG与OE学习项目 + +由于种种原因需还有旧版的项目,故此添加210(即OE2.10)版本 \ No newline at end of file diff --git a/startOSG.pro b/startOSG.pro new file mode 100644 index 0000000..6229c80 --- /dev/null +++ b/startOSG.pro @@ -0,0 +1,6 @@ +TEMPLATE = subdirs + +SUBDIRS = 210 \ + 320 + +DEFINES += readme.md