osgEarth 2.1.1
|
#include <osg/Notify>
#include <osg/Shape>
#include <osg/ShapeDrawable>
#include <osg/Geode>
#include <osg/AutoTransform>
#include <osg/MatrixTransform>
#include <osgText/Text>
#include <osgGA/StateSetManipulator>
#include <osgGA/GUIEventHandler>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgUtil/LineSegmentIntersector>
#include <osgEarth/MapNode>
#include <osgEarth/FindNode>
#include <osgEarth/ElevationQuery>
#include <osgEarthUtil/EarthManipulator>
#include <osgEarthUtil/ObjectLocator>
#include <osg/Depth>
#include <sstream>
#include <iomanip>
Go to the source code of this file.
Classes | |
struct | QueryElevationHandler |
Functions | |
static osg::Node * | createFlag () |
int | main (int argc, char **argv) |
Variables | |
static osg::Node * | s_flagNode |
static osgText::Text * | s_flagText |
static osg::Node* createFlag | ( | ) | [static] |
Definition at line 48 of file osgearth_elevation.cpp.
{ osg::Geode* g = new osg::Geode(); osgText::Text* text = new osgText::Text(); text->setCharacterSizeMode( osgText::Text::SCREEN_COORDS ); text->setCharacterSize( 24.f ); text->setFont( osgText::readFontFile("arial.ttf") ); text->setBackdropType( osgText::Text::OUTLINE ); text->setText( "00000000000000" ); text->setAutoRotateToScreen( true ); text->setPosition( osg::Vec3d( 0, 0, 0 ) ); text->setDataVariance( osg::Object::DYNAMIC ); g->addDrawable( text ); g->getOrCreateStateSet()->setMode( GL_LIGHTING, 0 ); g->getStateSet()->setAttribute( new osg::Depth(osg::Depth::ALWAYS), 1 ); g->getStateSet()->setRenderBinDetails( 99, "RenderBin" ); g->setDataVariance( osg::Object::DYNAMIC ); g->setCullingActive( false ); g->setNodeMask( 0 ); s_flagText = text; s_flagNode = g; return g; }
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 157 of file osgearth_elevation.cpp.
{ osg::ArgumentParser arguments(&argc,argv); osgViewer::Viewer viewer(arguments); osgEarth::MapNode* mapNode = NULL; osg::Node* loadedNode = osgDB::readNodeFiles( arguments ); if (loadedNode) { mapNode = findTopMostNodeOfType<osgEarth::MapNode>( loadedNode ); } if ( !mapNode ) { OE_WARN << "Unable to load earth file." << std::endl; return -1; } osg::Group* root = new osg::Group(); // The MapNode will render the Map object in the scene graph. mapNode->setNodeMask( 0x01 ); root->addChild( mapNode ); // A flag so we can see where we clicked ObjectLocatorNode* flag = new ObjectLocatorNode( mapNode->getMap() ); flag->addChild( createFlag() ); flag->setNodeMask( 0x02 ); root->addChild( flag ); viewer.setSceneData( root ); // An event handler that will respond to mouse clicks: viewer.addEventHandler( new QueryElevationHandler( mapNode->getMap(), flag->getLocator() ) ); // add some stock OSG handlers: viewer.addEventHandler(new osgViewer::StatsHandler()); viewer.addEventHandler(new osgViewer::WindowSizeHandler()); viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet())); // install the programmable manipulator. if ( mapNode->getMap()->isGeocentric() ) viewer.setCameraManipulator( new osgEarth::Util::EarthManipulator() ); return viewer.run(); }
osg::Node* s_flagNode [static] |
Definition at line 44 of file osgearth_elevation.cpp.
osgText::Text* s_flagText [static] |
Definition at line 45 of file osgearth_elevation.cpp.