Skip to content
Permalink
Browse files

globe: adapt to osgearth 2.7

  • Loading branch information
jef-n committed Mar 8, 2016
1 parent 7f17903 commit 63275585de4d22e7ae0252c6719d524d4da62f58
Showing with 32 additions and 5 deletions.
  1. +32 −5 src/plugins/globe/globe_plugin.cpp
@@ -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>
@@ -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();

@@ -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 );
@@ -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 );
}

@@ -930,17 +953,21 @@ 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
mSkyNode->setDateTime( dateTime.date().year()
, dateTime.date().month()
, dateTime.date().day()
, dateTime.time().hour() + dateTime.time().minute() / 60.0 );
mSkyNode->setDateTime( DateTime( dateTime.date().year()
, dateTime.date().month()
, dateTime.date().day()
, dateTime.time().hour() + dateTime.time().minute() / 60.0 ) );
//sky->setSunPosition( osg::Vec3(0,-1,0) );
mSkyNode->attach( mOsgViewer );
mRootNode->addChild( mSkyNode );

0 comments on commit 6327558

Please sign in to comment.
You can’t perform that action at this time.