| | 76 | // class to handle events with a pick |
| | 77 | class TerrainHandler : public osgGA::GUIEventHandler { |
| | 78 | public: |
| | 79 | |
| | 80 | TerrainHandler(osgTerrain::Terrain* terrain): |
| | 81 | _terrain(terrain) {} |
| | 82 | |
| | 83 | bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa) |
| | 84 | { |
| | 85 | switch(ea.getEventType()) |
| | 86 | { |
| | 87 | case(osgGA::GUIEventAdapter::KEYDOWN): |
| | 88 | { |
| | 89 | if (ea.getKey()=='r') |
| | 90 | { |
| | 91 | _terrain->setSampleRatio(_terrain->getSampleRatio()*0.5); |
| | 92 | osg::notify(osg::NOTICE)<<"Sample ratio "<<_terrain->getSampleRatio()<<std::endl; |
| | 93 | return true; |
| | 94 | } |
| | 95 | else if (ea.getKey()=='R') |
| | 96 | { |
| | 97 | _terrain->setSampleRatio(_terrain->getSampleRatio()/0.5); |
| | 98 | osg::notify(osg::NOTICE)<<"Sample ratio "<<_terrain->getSampleRatio()<<std::endl; |
| | 99 | return true; |
| | 100 | } |
| | 101 | else if (ea.getKey()=='v') |
| | 102 | { |
| | 103 | _terrain->setVerticalScale(_terrain->getVerticalScale()*1.25); |
| | 104 | osg::notify(osg::NOTICE)<<"Vertical scale "<<_terrain->getVerticalScale()<<std::endl; |
| | 105 | return true; |
| | 106 | } |
| | 107 | else if (ea.getKey()=='V') |
| | 108 | { |
| | 109 | _terrain->setVerticalScale(_terrain->getVerticalScale()/1.25); |
| | 110 | osg::notify(osg::NOTICE)<<"Vertical scale "<<_terrain->getVerticalScale()<<std::endl; |
| | 111 | return true; |
| | 112 | } |
| | 113 | |
| | 114 | return false; |
| | 115 | } |
| | 116 | default: |
| | 117 | return false; |
| | 118 | } |
| | 119 | } |
| | 120 | |
| | 121 | protected: |
| | 122 | |
| | 123 | ~TerrainHandler() {} |
| | 124 | |
| | 125 | osg::ref_ptr<osgTerrain::Terrain> _terrain; |
| | 126 | }; |
| | 127 | |