Changeset 349 for experimental
- Timestamp:
- Apr 21, 2012, 1:33:14 PM (13 years ago)
- Location:
- experimental/distortionNG
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/DistortionManipulator.cpp
r348 r349 31 31 activeManualSetupMode = DISTORTION; 32 32 activeVisualizationMode = NONE; 33 34 _distortionSet = NULL; 33 35 } 34 36 … … 50 52 bool DistortionManipulator::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* obj, osg::NodeVisitor* nv) 51 53 { 52 osgViewer::View* viewer = dynamic_cast<osgViewer::View*>(&aa); 53 if ( viewer ) 54 { 55 //osg::notify(osg::ALWAYS)<<"viewer!"<<std::endl; 56 } 54 //osgViewer::View* viewer = dynamic_cast<osgViewer::View*>(&aa); 55 //if ( viewer && !_distortionSet.isValid()) 56 //{ 57 // OSG_ALWAYS<<"Fetching valid DistortionSet!"<<std::endl; 58 // _distortionSet = viewer->getDistortionSet(); 59 //} 57 60 58 61 switch(ea.getEventType()) … … 61 64 case(osgGA::GUIEventAdapter::DRAG): 62 65 { 63 osg::notify(osg::ALWAYS)<<"DRAG!"<<std::endl;66 OSG_ALWAYS<<"DRAG!"<<std::endl; 64 67 break; 65 68 } … … 68 71 if(ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON) 69 72 { 70 osg::notify(osg::ALWAYS)<<"mouse click left!"<<std::endl;73 OSG_ALWAYS<<"mouse click left!"<<std::endl; 71 74 } 72 75 break; … … 94 97 } 95 98 96 osg::notify(osg::ALWAYS)<<"KEY_KP_4 : Setup Mode now "<<activeSetupMode<<std::endl;99 OSG_ALWAYS<<"KEY_KP_4 : Setup Mode now "<<activeSetupMode<<std::endl; 97 100 return(true); 98 101 } … … 101 104 102 105 activeManualSetupMode = (activeManualSetupMode==DISTORTION?BLENDING:DISTORTION); 103 osg::notify(osg::ALWAYS)<<"KEY_KP_5 : activeManualSetupMode is now "<<activeManualSetupMode<<std::endl;106 OSG_ALWAYS<<"KEY_KP_5 : activeManualSetupMode is now "<<activeManualSetupMode<<std::endl; 104 107 return(true); 105 108 } … … 107 110 { 108 111 activeDistortionMode = (activeDistortionMode==MESH?TEXCOORDINATES:MESH); 109 osg::notify(osg::ALWAYS)<<"KEY_KP_6 : activeDistortionMode is now "<<activeDistortionMode<<std::endl;112 OSG_ALWAYS<<"KEY_KP_6 : activeDistortionMode is now "<<activeDistortionMode<<std::endl; 110 113 return(true); 111 114 } … … 114 117 switch(activeVisualizationMode) 115 118 { 116 case DISTORTION_MESH : activeVisualizationMode = INTENSITY_MAP; break; 117 case INTENSITY_MAP : activeVisualizationMode = NONE; break; 118 case NONE : activeVisualizationMode = DISTORTION_MESH; break; 119 case DISTORTION_MESH : 120 { 121 activeVisualizationMode = INTENSITY_MAP; 122 showDistortionMesh(true); 123 showIntensityMap(false); 124 break; 125 } 126 case INTENSITY_MAP : 127 { 128 activeVisualizationMode = NONE; 129 showDistortionMesh(false); 130 showIntensityMap(true); 131 break; 132 } 133 case NONE : 134 { 135 activeVisualizationMode = DISTORTION_MESH; 136 showDistortionMesh(false); 137 showIntensityMap(false); 138 break; 139 } 119 140 } 120 osg::notify(osg::ALWAYS)<<"KEY_KP_7 : activeVisualizationMode is now "<<activeVisualizationMode<<std::endl; 141 142 143 OSG_ALWAYS<<"KEY_KP_7 : activeVisualizationMode is now "<<activeVisualizationMode<<std::endl; 121 144 return(true); 122 145 } 123 146 if (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Up) // KP 8: Save distortion set via plugin 124 147 { 125 osg::notify(osg::ALWAYS)<<"KEY_KP_8 : todo: Save DistortionContainer"<<std::endl;148 OSG_ALWAYS<<"KEY_KP_8 : todo: Save DistortionContainer"<<std::endl; 126 149 return(true); 127 150 } … … 133 156 case(osgGA::GUIEventAdapter::FRAME): 134 157 { 135 // osg::notify(osg::ALWAYS)<<"FRAME!"<<std::endl;158 //OSG_ALWAYS<<"FRAME!"<<std::endl; 136 159 break; 137 160 } 138 161 case (osgGA::GUIEventAdapter::RESIZE): // todo: adapt distortion mesh to new screen size 139 162 { 140 osg::notify(osg::ALWAYS)<<"RESIZE!"<<std::endl;163 OSG_ALWAYS<<"RESIZE!"<<std::endl; 141 164 break; 142 165 } … … 150 173 void DistortionManipulator::resetIntensityMap() 151 174 { 152 osg::notify(osg::ALWAYS)<<"ToDo: resetIntensityMap()"<<std::endl; 175 if(!_distortionSet.valid()) 176 return; 177 178 osg::ref_ptr<osg::Image> image = _distortionSet->getIntensityMap(); 179 180 OSG_ALWAYS<<"Reseting IntensityMap Blending."<<std::endl; 181 182 if (!image->isDataContiguous()) 183 { 184 OSG_WARN<<"Warning: DistortionManipulator does not support working with non contiguous imagery as blendmaps!"<<std::endl; 185 return; 186 } 187 188 // Fill intensity map with 255 189 unsigned char* dataPtr = image->data(); 190 for(unsigned int i=0;i<image->getTotalSizeInBytes();i++) 191 { 192 *dataPtr++ = 255; 193 } 194 image->dirty(); 153 195 } 154 196 155 197 void DistortionManipulator::resetDistortion() 156 198 { 157 osg::notify(osg::ALWAYS)<<"ToDo: resetDistortion()"<<std::endl; 158 } 199 if(!_distortionSet.valid()) 200 return; 201 202 OSG_ALWAYS<<"ToDo: resetDistortion()"<<std::endl; 203 } 204 205 void DistortionManipulator::showDistortionMesh(bool show) 206 { 207 OSG_ALWAYS<<"ToDo: showDistortionMesh(bool) is now "<<show<<std::endl; 208 209 // Todo: Stateset muss das von der MeshGeode sein. 210 211 /* osg::PolygonMode* polyModeObj = dynamic_cast<osg::PolygonMode*>(_stateset->getAttribute(osg::StateAttribute::POLYGONMODE)); 212 if (!polyModeObj) 213 { 214 polyModeObj = new osg::PolygonMode; 215 _stateset->setAttribute(polyModeObj); 216 } 217 218 if(show) 219 polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE); 220 else 221 polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::FILL);*/ 222 } 223 224 void DistortionManipulator::showIntensityMap(bool show) 225 { 226 OSG_ALWAYS<<"ToDo: showIntensityMap(bool) is now "<<show<<std::endl; 227 } -
experimental/distortionNG/DistortionManipulator.h
r348 r349 20 20 #define OSGGA_DISTORTION_MANIPULATOR 1 21 21 22 #include<osgGA/GUIEventHandler> 22 #include <osgGA/GUIEventHandler> 23 #include<osg/Referenced> 24 #include "DistortionSet.h" 23 25 24 26 … … 54 56 virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv); 55 57 58 void setDistortionSet(DistortionSet* ds) {_distortionSet = ds;} 59 56 60 private: 57 61 void resetIntensityMap(); 58 62 void resetDistortion(); 63 void showDistortionMesh(bool show); 64 void showIntensityMap(bool show); 59 65 60 66 SetupMode activeSetupMode; … … 62 68 ManualSetupMode activeManualSetupMode; 63 69 VisualizationMode activeVisualizationMode; 70 71 osg::ref_ptr<DistortionSet> _distortionSet; 64 72 }; 65 73 -
experimental/distortionNG/DistortionSet.h
r345 r349 52 52 53 53 void setIntensityMap(osg::Image* intensityMap) { _intensityMap = intensityMap; } 54 const osg::Image* getIntensityMap() const { return _intensityMap; } 54 const osg::Image* getIntensityMap() const { return _intensityMap; } // for serializers 55 osg::Image* getIntensityMap() { return _intensityMap; } // for manipulating the intensity map 55 56 56 57 void setTexUnitScene(unsigned int texUnitScene) { _texUnitScene = texUnitScene; } -
experimental/distortionNG/extViewer.cpp
r346 r349 347 347 camera->setCullingMode( mode & (~osg::CullSettings::SMALL_FEATURE_CULLING) ); 348 348 349 // Create DistortionSet 350 _distortionSet = new osgViewer::DistortionSet(); 351 _distortionSet->setIntensityMap( intensityMap ); 352 353 349 354 // Add the distortionHandler 350 addEventHandler(new osgViewer::DistortionManipulator); 355 osgViewer::DistortionManipulator* distManip = new osgViewer::DistortionManipulator(); 356 distManip->setDistortionSet(_distortionSet); 357 addEventHandler(distManip); 351 358 352 359 -
experimental/distortionNG/extViewer.h
r346 r349 19 19 */ 20 20 21 #include <osgViewer/Viewer> 22 #include<osg/Referenced> 23 #include "DistortionSet.h" 21 24 22 #include<osgViewer/Viewer>23 25 24 26 class extViewer : public osgViewer::Viewer … … 37 39 38 40 void setUpIntensityMapBlending(osg::StateSet* stateset, osg::Image* intensityMap, unsigned int screenNum=0, int rttSceneTextureUnit=0, int intensityMapTextureUnit=1); 41 42 osgViewer::DistortionSet* getDistortionSet() {return _distortionSet;} 43 void setDistortionSet(osgViewer::DistortionSet* ds) {_distortionSet = ds;} 44 45 private: 46 osg::ref_ptr<osgViewer::DistortionSet> _distortionSet; 39 47 }; -
experimental/distortionNG/main.cpp
r348 r349 174 174 * [done] - Key to control if mouse drags affects mesh coordinates or rttScene texture coordinates. Default: Mesh coordinates. 175 175 * - Key to reset Distortion. 176 * 176 * [done] - Key to reset Blending. 177 177 * 178 178 * Die Funktion handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ):
Note: See TracChangeset
for help on using the changeset viewer.