|
57 | 57 | #include <osgEarth/Map>
|
58 | 58 | #include <osgEarth/MapNode>
|
59 | 59 | #include <osgEarth/TileSource>
|
| 60 | +#if OSGEARTH_MIN_VERSION_REQUIRED(2,7,0) |
| 61 | +#include <osgEarthUtil/Sky> |
| 62 | +#else |
60 | 63 | #include <osgEarthUtil/SkyNode>
|
| 64 | +#endif |
61 | 65 | #include <osgEarthUtil/AutoClipPlaneHandler>
|
62 | 66 | #include <osgEarthDrivers/gdal/GDALOptions>
|
63 | 67 | #include <osgEarthDrivers/tms/TMSOptions>
|
@@ -394,9 +398,18 @@ void GlobePlugin::run()
|
394 | 398 | }
|
395 | 399 |
|
396 | 400 | // Set a home viewpoint
|
| 401 | +#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 7, 0 ) |
| 402 | + osgEarth::Util::Viewpoint vp; |
| 403 | + vp.focalPoint()->vec3d() = osg::Vec3d( -90, 0, 0 ); |
| 404 | + vp.heading() = 0.0; |
| 405 | + vp.pitch() = -90.0; |
| 406 | + vp.range() = 2e7; |
| 407 | + manip->setHomeViewpoint( vp, 1.0 ); |
| 408 | +#else |
397 | 409 | manip->setHomeViewpoint(
|
398 | 410 | osgEarth::Util::Viewpoint( osg::Vec3d( -90, 0, 0 ), 0.0, -90.0, 2e7 ),
|
399 | 411 | 1.0 );
|
| 412 | +#endif |
400 | 413 |
|
401 | 414 | setupControls();
|
402 | 415 |
|
@@ -454,12 +467,14 @@ void GlobePlugin::setupMap()
|
454 | 467 | //nodeOptions.proxySettings() =
|
455 | 468 | //nodeOptions.enableLighting() = false;
|
456 | 469 |
|
| 470 | +#if OSGEARTH_VERSION_LESS_THAN( 2, 7, 0 ) |
457 | 471 | //LoadingPolicy loadingPolicy( LoadingPolicy::MODE_SEQUENTIAL );
|
458 | 472 | TerrainOptions terrainOptions;
|
459 | 473 | //terrainOptions.loadingPolicy() = loadingPolicy;
|
460 | 474 | terrainOptions.compositingTechnique() = TerrainOptions::COMPOSITING_MULTITEXTURE_FFP;
|
461 | 475 | //terrainOptions.lodFallOff() = 6.0;
|
462 | 476 | nodeOptions.setTerrainOptions( terrainOptions );
|
| 477 | +#endif |
463 | 478 |
|
464 | 479 | // The MapNode will render the Map object in the scene graph.
|
465 | 480 | mMapNode = new osgEarth::MapNode( map, nodeOptions );
|
@@ -605,7 +620,15 @@ void GlobePlugin::syncExtent()
|
605 | 620 |
|
606 | 621 | OE_NOTICE << "map extent: " << height << " camera distance: " << distance << std::endl;
|
607 | 622 |
|
| 623 | +#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 7, 0 ) |
| 624 | + osgEarth::Util::Viewpoint viewpoint; |
| 625 | + viewpoint.focalPoint()->vec3d() = osg::Vec3d( extent.center().x(), extent.center().y(), 0.0 ); |
| 626 | + viewpoint.heading() = 0.0; |
| 627 | + viewpoint.pitch() = -90.0; |
| 628 | + viewpoint.range() = distance; |
| 629 | +#else |
608 | 630 | osgEarth::Util::Viewpoint viewpoint( osg::Vec3d( extent.center().x(), extent.center().y(), 0.0 ), 0.0, -90.0, distance );
|
| 631 | +#endif |
609 | 632 | manip->setViewpoint( viewpoint, 4.0 );
|
610 | 633 | }
|
611 | 634 |
|
@@ -930,17 +953,28 @@ void GlobePlugin::setSkyParameters( bool enabled, const QDateTime& dateTime, boo
|
930 | 953 | {
|
931 | 954 | // Create if not yet done
|
932 | 955 | if ( !mSkyNode.get() )
|
| 956 | +#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 7, 0 ) |
| 957 | + mSkyNode = SkyNode::create( mMapNode ); |
| 958 | +#else |
933 | 959 | mSkyNode = new SkyNode( mMapNode->getMap() );
|
| 960 | +#endif |
934 | 961 |
|
935 |
| -#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 4, 0 ) |
| 962 | +#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 4, 0 ) && OSGEARTH_VERSION_LESS_THAN( 2, 7, 0 ) |
936 | 963 | mSkyNode->setAutoAmbience( autoAmbience );
|
937 | 964 | #else
|
938 | 965 | Q_UNUSED( autoAmbience );
|
939 | 966 | #endif
|
| 967 | +#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 7, 0 ) |
| 968 | + mSkyNode->setDateTime( DateTime( dateTime.date().year() |
| 969 | + , dateTime.date().month() |
| 970 | + , dateTime.date().day() |
| 971 | + , dateTime.time().hour() + dateTime.time().minute() / 60.0 ) ); |
| 972 | +#else |
940 | 973 | mSkyNode->setDateTime( dateTime.date().year()
|
941 | 974 | , dateTime.date().month()
|
942 | 975 | , dateTime.date().day()
|
943 | 976 | , dateTime.time().hour() + dateTime.time().minute() / 60.0 );
|
| 977 | +#endif |
944 | 978 | //sky->setSunPosition( osg::Vec3(0,-1,0) );
|
945 | 979 | mSkyNode->attach( mOsgViewer );
|
946 | 980 | mRootNode->addChild( mSkyNode );
|
|
0 commit comments