osgEarth 2.1.1
|
#include <string>
#include <osg/Notify>
#include <osg/Switch>
#include <osgGA/StateSetManipulator>
#include <osgGA/GUIEventHandler>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgEarth/Map>
#include <osgEarth/MapNode>
#include <osgEarthUtil/EarthManipulator>
#include <osgEarthUtil/Viewpoint>
#include <osgEarthUtil/AutoClipPlaneHandler>
#include <osgEarthUtil/Controls>
Go to the source code of this file.
Classes | |
class | anonymous_namespace{osgearth_manip.cpp}::SwitchHandler |
struct | anonymous_namespace{osgearth_manip.cpp}::FlyToViewpointHandler |
struct | anonymous_namespace{osgearth_manip.cpp}::LockAzimuthHandler |
Namespaces | |
namespace | anonymous_namespace{osgearth_manip.cpp} |
Functions | |
osg::Node * | anonymous_namespace{osgearth_manip.cpp}::createHelp (osgViewer::View *view) |
int | main (int argc, char **argv) |
Variables | |
static Viewpoint | anonymous_namespace{osgearth_manip.cpp}::VPs [] |
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 149 of file osgearth_manip.cpp.
{ osg::ArgumentParser arguments(&argc,argv); osg::DisplaySettings::instance()->setMinimumNumStencilBits( 8 ); // install the programmable manipulator. EarthManipulator* manip = new EarthManipulator(); osg::Node* earthNode = osgDB::readNodeFiles( arguments ); if (!earthNode) { OE_WARN << "Unable to load earth model." << std::endl; return -1; } osgViewer::Viewer viewer(arguments); osg::Group* root = new osg::Group(); root->addChild( earthNode ); root->addChild( createHelp(&viewer) ); osgEarth::MapNode* mapNode = osgEarth::MapNode::findMapNode( earthNode ); if ( mapNode ) { if ( mapNode ) manip->setNode( mapNode->getTerrainEngine() ); if ( mapNode->getMap()->isGeocentric() ) { manip->setHomeViewpoint( Viewpoint( osg::Vec3d( -90, 0, 0 ), 0.0, -90.0, 5e7 ) ); // add a handler that will automatically calculate good clipping planes viewer.addEventHandler( new AutoClipPlaneHandler() ); } } viewer.setSceneData( root ); viewer.setCameraManipulator( manip ); manip->getSettings()->bindMouse( EarthManipulator::ACTION_EARTH_DRAG, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON, osgGA::GUIEventAdapter::MODKEY_SHIFT ); manip->getSettings()->setArcViewpointTransitions( true ); viewer.addEventHandler(new FlyToViewpointHandler( manip )); viewer.addEventHandler(new LockAzimuthHandler('u', manip)); // add some stock OSG handlers: viewer.addEventHandler(new osgViewer::StatsHandler()); viewer.addEventHandler(new osgViewer::WindowSizeHandler()); viewer.addEventHandler(new osgViewer::ThreadingHandler()); viewer.addEventHandler(new osgViewer::LODScaleHandler()); viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet())); viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage())); //viewer.addEventHandler(new osgViewer::RecordCameraPathHandler()); return viewer.run(); }