Changeset 310
- Timestamp:
- Aug 3, 2011, 1:49:17 PM (13 years ago)
- Location:
- experimental/distortionNG
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/distortionNG.cpp
r309 r310 87 87 osg::ref_ptr<osg::Geode> geode = new osg::Geode; 88 88 geode->addDrawable( _highlighter.get() ); 89 geode->getOrCreateStateSet()->setAttributeAndModes( new osg::Point( 10.0f) );89 geode->getOrCreateStateSet()->setAttributeAndModes( new osg::Point(8.0f) ); 90 90 geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); 91 91 … … 95 95 bool distortionHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ) 96 96 { 97 if ( ea.getEventType()!=osgGA::GUIEventAdapter::RELEASE || 98 ea.getButton()!=osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON || 99 !(ea.getModKeyMask()&osgGA::GUIEventAdapter::MODKEY_CTRL) ) 100 return false; 101 102 osgViewer::View* viewer = dynamic_cast<osgViewer::View*>(&aa); 103 if ( viewer ) 104 { 105 osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(), ea.getY()); 106 osgUtil::IntersectionVisitor iv( intersector.get() ); 107 viewer->getCamera()->accept( iv ); 108 109 if ( intersector->containsIntersections() ) 110 { 111 osgUtil::LineSegmentIntersector::Intersection& result = *(intersector->getIntersections().begin()); 112 computeSelectedVertex( result ); 113 } 114 } 115 return false; 97 // Only pressing CTRL activates distortion editing 98 if ( !(ea.getModKeyMask()&osgGA::GUIEventAdapter::MODKEY_CTRL) ) 99 return false; // False means not handled. 100 101 102 if ( ea.getEventType() == osgGA::GUIEventAdapter::PUSH && ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON ) 103 { 104 osgViewer::View* viewer = dynamic_cast<osgViewer::View*>(&aa); 105 if ( viewer ) 106 { 107 osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(), ea.getY()); 108 osgUtil::IntersectionVisitor iv( intersector.get() ); 109 viewer->getCamera()->accept( iv ); 110 111 if ( intersector->containsIntersections() ) 112 { 113 osgUtil::LineSegmentIntersector::Intersection& result = *(intersector->getIntersections().begin()); 114 computeSelectedVertex( result ); 115 } 116 } 117 } 118 119 if ( ea.getEventType() == osgGA::GUIEventAdapter::DRAG ) 120 { 121 osg::notify(osg::ALWAYS)<<std::endl<<"ea.getGraphicsContext()="<<ea.getGraphicsContext()<<std::endl; 122 osg::notify(osg::ALWAYS)<<"ea.getXnormalized()="<<ea.getXnormalized()<<std::endl; 123 osg::notify(osg::ALWAYS)<<"ea.getYnormalized()="<<ea.getYnormalized()<<std::endl; 124 osg::notify(osg::ALWAYS)<<"ea.getX()="<<ea.getX()<<std::endl; 125 osg::notify(osg::ALWAYS)<<"ea.getXin()="<<ea.getXmin()<<std::endl; 126 osg::notify(osg::ALWAYS)<<"ea.getXmax()="<<ea.getXmax()<<std::endl; 127 osg::notify(osg::ALWAYS)<<"ea.getY()="<<ea.getY()<<std::endl; 128 osg::notify(osg::ALWAYS)<<"ea.getYin()="<<ea.getYmin()<<std::endl; 129 osg::notify(osg::ALWAYS)<<"ea.getYmax()="<<ea.getYmax()<<std::endl; 130 131 return true; // true means event handeld: not forwarded to the camera manipulator; 132 } 133 134 135 return false; // False means not handled. 116 136 } 117 137 -
experimental/distortionNG/distortionNG.h
r309 r310 17 17 public: 18 18 distortionHandler( osg::Camera* camera ) 19 : _highlighter(0), _camera(camera), _highlightColor( osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f) ) {}19 : _highlighter(0), _camera(camera), _highlightColor( osg::Vec4(1.0f, 1.0f, 0.0f, 1.0f) ) {} 20 20 21 21 void computeSelectedVertex( osgUtil::LineSegmentIntersector::Intersection& result ); -
experimental/distortionNG/distortionNG.vcproj
r309 r310 182 182 </File> 183 183 <File 184 RelativePath=".\extViewer.cpp" 185 > 186 </File> 187 <File 184 188 RelativePath=".\main.cpp" 185 189 > … … 195 199 > 196 200 </File> 201 <File 202 RelativePath=".\extViewer.h" 203 > 204 </File> 197 205 </Filter> 198 206 <Filter -
experimental/distortionNG/main.cpp
r309 r310 17 17 */ 18 18 19 #include "extViewer.h" 19 20 #include "distortionNG.h" 20 21
Note: See TracChangeset
for help on using the changeset viewer.