- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgViewer/ViewerEventHandlers.cpp
r12924 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 78 78 osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa); 79 79 if (!view) return false; 80 80 81 81 osgViewer::ViewerBase* viewer = view->getViewerBase(); 82 82 … … 161 161 osg::GraphicsContext::WindowingSystemInterface *wsi = osg::GraphicsContext::getWindowingSystemInterface(); 162 162 163 if (wsi == NULL) 163 if (wsi == NULL) 164 164 { 165 165 OSG_NOTICE << "Error, no WindowSystemInterface available, cannot toggle window fullscreen." << std::endl; … … 207 207 osg::GraphicsContext::WindowingSystemInterface *wsi = osg::GraphicsContext::getWindowingSystemInterface(); 208 208 209 if (wsi == NULL) 209 if (wsi == NULL) 210 210 { 211 211 OSG_NOTICE << "Error, no WindowSystemInterface available, cannot toggle window fullscreen." << std::endl; … … 317 317 osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa); 318 318 if (!view) return false; 319 319 320 320 osgViewer::ViewerBase* viewerBase = view->getViewerBase(); 321 321 osgViewer::Viewer* viewer = dynamic_cast<Viewer*>(viewerBase); … … 357 357 OSG_NOTICE<<"Threading model 'SingleThreaded' selected."<<std::endl; 358 358 break; 359 #if 1 359 #if 1 360 360 case(osgViewer::ViewerBase::AutomaticSelection): 361 361 viewerBase->setThreadingModel(osgViewer::ViewerBase::SingleThreaded); 362 362 OSG_NOTICE<<"Threading model 'SingleThreaded' selected."<<std::endl; 363 #else 363 #else 364 364 case(osgViewer::ViewerBase::AutomaticSelection): 365 365 viewerBase->setThreadingModel(viewer->suggestBestThreadingModel()); … … 448 448 { 449 449 const osg::Matrixd& m = view->getCamera()->getInverseViewMatrix(); 450 double animationPathTime = osg::Timer::instance()->delta_s(_animStartTime, time); 450 double animationPathTime = osg::Timer::instance()->delta_s(_animStartTime, time); 451 451 _animPath->insert(animationPathTime, osg::AnimationPath::ControlPoint(m.getTrans(), m.getRotate())); 452 452 _delta = 0.0f; … … 460 460 } 461 461 else _delta += delta; 462 462 463 463 return true; 464 464 } … … 479 479 _animStartTime = osg::Timer::instance()->tick(); 480 480 _animPath = new osg::AnimationPath(); 481 481 482 482 if (!_filename.empty()) 483 483 { … … 490 490 } 491 491 ss << "."<<osgDB::getFileExtension(_filename); 492 492 493 493 OSG_NOTICE << "Recording camera path to file " << ss.str() << std::endl; 494 494 _fout.open( ss.str().c_str() ); … … 548 548 { 549 549 if (_animPath.valid() && !_animPath->empty()) 550 { 550 { 551 551 _animPathManipulator = new osgGA::AnimationPathManipulator(_animPath.get()); 552 552 _animPathManipulator->home(ea,aa); … … 563 563 } 564 564 } 565 565 566 566 // The user has requested to STOP playback. 567 567 else … … 574 574 575 575 return true; 576 } 576 } 577 577 578 578 break; … … 637 637 usage.addKeyboardMouseBinding(ostr.str(),"Increase LODScale."); 638 638 } 639 639 640 640 { 641 641 std::ostringstream ostr; … … 654 654 osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa); 655 655 if (!view) return false; 656 656 657 657 osgViewer::ViewerBase* viewer = view->getViewerBase(); 658 658 … … 661 661 return false; 662 662 } 663 663 664 664 if (ea.getHandled()) return false; 665 665 … … 730 730 } 731 731 732 bool InteractiveImageHandler::computeIntersections(osgViewer::View* view, float x,float y, const osg::NodePath& nodePath, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask) const 732 bool InteractiveImageHandler::computeIntersections(osgViewer::View* view, float x,float y, const osg::NodePath& nodePath, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask) const 733 733 { 734 734 float local_x, local_y = 0.0; … … 819 819 osg::Vec2 tc(0.5f,0.5f); 820 820 821 // use the nearest intersection 821 // use the nearest intersection 822 822 const osgUtil::LineSegmentIntersector::Intersection& intersection = *(intersections.begin()); 823 823 osg::Drawable* drawable = intersection.drawable.get(); … … 844 844 if (texcoords_Vec2Array) 845 845 { 846 // we have tex coord array so now we can compute the final tex coord at the point of intersection. 846 // we have tex coord array so now we can compute the final tex coord at the point of intersection. 847 847 osg::Vec2 tc1 = (*texcoords_Vec2Array)[i1]; 848 848 osg::Vec2 tc2 = (*texcoords_Vec2Array)[i2]; … … 894 894 { 895 895 if (ea.getHandled()) return false; 896 896 897 897 if (!_image) return false; 898 898 … … 918 918 int x,y; 919 919 bool sendKeyEvent = mousePosition(view, nv, ea, x, y); 920 920 921 921 if (sendKeyEvent) 922 922 { 923 923 return _image->sendKeyEvent(ea.getKey(), ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN); 924 } 924 } 925 925 break; 926 926 } … … 960 960 } 961 961 962 // Make sure the texture does not rescale the image because 962 // Make sure the texture does not rescale the image because 963 963 // it thinks it should still be the previous size... 964 964 if (_texture.valid())
