Skip to content

Commit

Permalink
globe: adapt to osgearth 2.7
Browse files Browse the repository at this point in the history
(cherry picked from commit 342a754)
  • Loading branch information
jef-n committed Mar 13, 2016
1 parent 7c1131b commit 3507bd8
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/plugins/globe/globe_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@
#include <osgEarth/Map>
#include <osgEarth/MapNode>
#include <osgEarth/TileSource>
#if OSGEARTH_MIN_VERSION_REQUIRED(2,7,0)
#include <osgEarthUtil/Sky>
#else
#include <osgEarthUtil/SkyNode>
#endif
#include <osgEarthUtil/AutoClipPlaneHandler>
#include <osgEarthDrivers/gdal/GDALOptions>
#include <osgEarthDrivers/tms/TMSOptions>
Expand Down Expand Up @@ -394,9 +398,18 @@ void GlobePlugin::run()
}

// Set a home viewpoint
#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 7, 0 )
osgEarth::Util::Viewpoint vp;
vp.focalPoint()->vec3d() = osg::Vec3d( -90, 0, 0 );
vp.heading() = 0.0;
vp.pitch() = -90.0;
vp.range() = 2e7;
manip->setHomeViewpoint( vp, 1.0 );
#else
manip->setHomeViewpoint(
osgEarth::Util::Viewpoint( osg::Vec3d( -90, 0, 0 ), 0.0, -90.0, 2e7 ),
1.0 );
#endif

setupControls();

Expand Down Expand Up @@ -454,12 +467,14 @@ void GlobePlugin::setupMap()
//nodeOptions.proxySettings() =
//nodeOptions.enableLighting() = false;

#if OSGEARTH_VERSION_LESS_THAN( 2, 7, 0 )
//LoadingPolicy loadingPolicy( LoadingPolicy::MODE_SEQUENTIAL );
TerrainOptions terrainOptions;
//terrainOptions.loadingPolicy() = loadingPolicy;
terrainOptions.compositingTechnique() = TerrainOptions::COMPOSITING_MULTITEXTURE_FFP;
//terrainOptions.lodFallOff() = 6.0;
nodeOptions.setTerrainOptions( terrainOptions );
#endif

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

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

#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 7, 0 )
osgEarth::Util::Viewpoint viewpoint;
viewpoint.focalPoint()->vec3d() = osg::Vec3d( extent.center().x(), extent.center().y(), 0.0 );
viewpoint.heading() = 0.0;
viewpoint.pitch() = -90.0;
viewpoint.range() = distance;
#else
osgEarth::Util::Viewpoint viewpoint( osg::Vec3d( extent.center().x(), extent.center().y(), 0.0 ), 0.0, -90.0, distance );
#endif
manip->setViewpoint( viewpoint, 4.0 );
}

Expand Down Expand Up @@ -930,17 +953,28 @@ void GlobePlugin::setSkyParameters( bool enabled, const QDateTime& dateTime, boo
{
// Create if not yet done
if ( !mSkyNode.get() )
#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 7, 0 )
mSkyNode = SkyNode::create( mMapNode );
#else
mSkyNode = new SkyNode( mMapNode->getMap() );
#endif

#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 4, 0 )
#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 4, 0 ) && OSGEARTH_VERSION_LESS_THAN( 2, 7, 0 )
mSkyNode->setAutoAmbience( autoAmbience );
#else
Q_UNUSED( autoAmbience );
#endif
#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 7, 0 )
mSkyNode->setDateTime( DateTime( dateTime.date().year()
, dateTime.date().month()
, dateTime.date().day()
, dateTime.time().hour() + dateTime.time().minute() / 60.0 ) );
#else
mSkyNode->setDateTime( dateTime.date().year()
, dateTime.date().month()
, dateTime.date().day()
, dateTime.time().hour() + dateTime.time().minute() / 60.0 );
#endif
//sky->setSunPosition( osg::Vec3(0,-1,0) );
mSkyNode->attach( mOsgViewer );
mRootNode->addChild( mSkyNode );
Expand Down

0 comments on commit 3507bd8

Please sign in to comment.