| | 184 | // class to handle events with a pick |
| | 185 | class TerrainHandler : public osgGA::GUIEventHandler { |
| | 186 | public: |
| | 187 | |
| | 188 | TerrainHandler(osgTerrain::Terrain* terrain): |
| | 189 | _terrain(terrain) {} |
| | 190 | |
| | 191 | bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa) |
| | 192 | { |
| | 193 | switch(ea.getEventType()) |
| | 194 | { |
| | 195 | case(osgGA::GUIEventAdapter::KEYDOWN): |
| | 196 | { |
| | 197 | if (ea.getKey()=='r') |
| | 198 | { |
| | 199 | _terrain->setSampleRatio(_terrain->getSampleRatio()*0.5); |
| | 200 | osg::notify(osg::NOTICE)<<"Sample ratio "<<_terrain->getSampleRatio()<<std::endl; |
| | 201 | return true; |
| | 202 | } |
| | 203 | else if (ea.getKey()=='R') |
| | 204 | { |
| | 205 | _terrain->setSampleRatio(_terrain->getSampleRatio()/0.5); |
| | 206 | osg::notify(osg::NOTICE)<<"Sample ratio "<<_terrain->getSampleRatio()<<std::endl; |
| | 207 | return true; |
| | 208 | } |
| | 209 | else if (ea.getKey()=='v') |
| | 210 | { |
| | 211 | _terrain->setVerticalScale(_terrain->getVerticalScale()*1.25); |
| | 212 | osg::notify(osg::NOTICE)<<"Vertical scale "<<_terrain->getVerticalScale()<<std::endl; |
| | 213 | return true; |
| | 214 | } |
| | 215 | else if (ea.getKey()=='V') |
| | 216 | { |
| | 217 | _terrain->setVerticalScale(_terrain->getVerticalScale()/1.25); |
| | 218 | osg::notify(osg::NOTICE)<<"Vertical scale "<<_terrain->getVerticalScale()<<std::endl; |
| | 219 | return true; |
| | 220 | } |
| | 221 | |
| | 222 | return false; |
| | 223 | } |
| | 224 | default: |
| | 225 | return false; |
| | 226 | } |
| | 227 | } |
| | 228 | |
| | 229 | protected: |
| | 230 | |
| | 231 | ~TerrainHandler() {} |
| | 232 | |
| | 233 | osg::ref_ptr<osgTerrain::Terrain> _terrain; |
| | 234 | }; |
| | 235 | |