Skip to content

Commit 3507bd8

Browse files
committedMar 13, 2016
globe: adapt to osgearth 2.7
(cherry picked from commit 342a754)
1 parent 7c1131b commit 3507bd8

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed
 

‎src/plugins/globe/globe_plugin.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@
5757
#include <osgEarth/Map>
5858
#include <osgEarth/MapNode>
5959
#include <osgEarth/TileSource>
60+
#if OSGEARTH_MIN_VERSION_REQUIRED(2,7,0)
61+
#include <osgEarthUtil/Sky>
62+
#else
6063
#include <osgEarthUtil/SkyNode>
64+
#endif
6165
#include <osgEarthUtil/AutoClipPlaneHandler>
6266
#include <osgEarthDrivers/gdal/GDALOptions>
6367
#include <osgEarthDrivers/tms/TMSOptions>
@@ -394,9 +398,18 @@ void GlobePlugin::run()
394398
}
395399

396400
// 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
397409
manip->setHomeViewpoint(
398410
osgEarth::Util::Viewpoint( osg::Vec3d( -90, 0, 0 ), 0.0, -90.0, 2e7 ),
399411
1.0 );
412+
#endif
400413

401414
setupControls();
402415

@@ -454,12 +467,14 @@ void GlobePlugin::setupMap()
454467
//nodeOptions.proxySettings() =
455468
//nodeOptions.enableLighting() = false;
456469

470+
#if OSGEARTH_VERSION_LESS_THAN( 2, 7, 0 )
457471
//LoadingPolicy loadingPolicy( LoadingPolicy::MODE_SEQUENTIAL );
458472
TerrainOptions terrainOptions;
459473
//terrainOptions.loadingPolicy() = loadingPolicy;
460474
terrainOptions.compositingTechnique() = TerrainOptions::COMPOSITING_MULTITEXTURE_FFP;
461475
//terrainOptions.lodFallOff() = 6.0;
462476
nodeOptions.setTerrainOptions( terrainOptions );
477+
#endif
463478

464479
// The MapNode will render the Map object in the scene graph.
465480
mMapNode = new osgEarth::MapNode( map, nodeOptions );
@@ -605,7 +620,15 @@ void GlobePlugin::syncExtent()
605620

606621
OE_NOTICE << "map extent: " << height << " camera distance: " << distance << std::endl;
607622

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
608630
osgEarth::Util::Viewpoint viewpoint( osg::Vec3d( extent.center().x(), extent.center().y(), 0.0 ), 0.0, -90.0, distance );
631+
#endif
609632
manip->setViewpoint( viewpoint, 4.0 );
610633
}
611634

@@ -930,17 +953,28 @@ void GlobePlugin::setSkyParameters( bool enabled, const QDateTime& dateTime, boo
930953
{
931954
// Create if not yet done
932955
if ( !mSkyNode.get() )
956+
#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 7, 0 )
957+
mSkyNode = SkyNode::create( mMapNode );
958+
#else
933959
mSkyNode = new SkyNode( mMapNode->getMap() );
960+
#endif
934961

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 )
936963
mSkyNode->setAutoAmbience( autoAmbience );
937964
#else
938965
Q_UNUSED( autoAmbience );
939966
#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
940973
mSkyNode->setDateTime( dateTime.date().year()
941974
, dateTime.date().month()
942975
, dateTime.date().day()
943976
, dateTime.time().hour() + dateTime.time().minute() / 60.0 );
977+
#endif
944978
//sky->setSunPosition( osg::Vec3(0,-1,0) );
945979
mSkyNode->attach( mOsgViewer );
946980
mRootNode->addChild( mSkyNode );

0 commit comments

Comments
 (0)
Please sign in to comment.