Skip to content

Commit

Permalink
Using MapNodeHelper in osgearth_terrainprofile to setup the GL3Realiz…
Browse files Browse the repository at this point in the history
…eCallback.
  • Loading branch information
jasonbeverage committed Jun 12, 2020
1 parent f5ecce0 commit 22a426b
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <osgEarth/TerrainProfile>
#include <osgEarth/GeoMath>
#include <osgEarth/Registry>
#include <osgEarth/ExampleResources>
#include <osgEarth/FileUtils>
#include <osgEarth/GLUtils>
#include <osgEarth/Feature>
Expand Down Expand Up @@ -245,9 +246,8 @@ class TerrainProfileGraph : public osg::Group
class DrawProfileEventHandler : public osgGA::GUIEventHandler
{
public:
DrawProfileEventHandler(osgEarth::MapNode* mapNode, osg::Group* root, TerrainProfileCalculator* profileCalculator):
DrawProfileEventHandler(osgEarth::MapNode* mapNode, TerrainProfileCalculator* profileCalculator):
_mapNode( mapNode ),
_root( root ),
_startValid( false ),
_profileCalculator( profileCalculator )
{
Expand All @@ -273,7 +273,7 @@ class DrawProfileEventHandler : public osgGA::GUIEventHandler
_start = mapPoint.vec3d();
if (_featureNode.valid())
{
_root->removeChild( _featureNode.get() );
_mapNode->removeChild( _featureNode.get() );
_featureNode = 0;
}
}
Expand All @@ -296,7 +296,7 @@ class DrawProfileEventHandler : public osgGA::GUIEventHandler

if (_featureNode.valid())
{
_root->removeChild( _featureNode.get() );
_mapNode->removeChild( _featureNode.get() );
_featureNode = 0;
}

Expand All @@ -323,15 +323,11 @@ class DrawProfileEventHandler : public osgGA::GUIEventHandler
feature->style() = style;
_featureNode = new FeatureNode( feature );
_featureNode->setMapNode(_mapNode);
_root->addChild( _featureNode.get() );
_mapNode->addChild( _featureNode.get() );

}




osgEarth::MapNode* _mapNode;
osg::Group* _root;
TerrainProfileCalculator* _profileCalculator;
osg::ref_ptr< FeatureNode > _featureNode;
bool _startValid;
Expand All @@ -351,7 +347,8 @@ main(int argc, char** argv)
osgViewer::Viewer viewer(arguments);

// load the .earth file from the command line.
osg::ref_ptr<osg::Node> earthNode = osgDB::readNodeFiles( arguments );
MapNodeHelper helper;
osg::ref_ptr<osg::Node> earthNode = helper.load(arguments, &viewer);
if (!earthNode.valid())
{
OE_NOTICE << "Unable to load earth model" << std::endl;
Expand All @@ -367,6 +364,8 @@ main(int argc, char** argv)
return 1;
}

mapNode->open();

osgEarth::Util::EarthManipulator* manip = new EarthManipulator();
viewer.setCameraManipulator( manip );

Expand All @@ -393,7 +392,7 @@ main(int argc, char** argv)

viewer.getCamera()->addCullCallback( new AutoClipPlaneCullCallback(mapNode));

viewer.addEventHandler( new DrawProfileEventHandler( mapNode, mapNode, calculator.get() ) );
viewer.addEventHandler( new DrawProfileEventHandler( mapNode, calculator.get() ) );

viewer.setSceneData( root );

Expand Down

0 comments on commit 22a426b

Please sign in to comment.