Changeset 356 for experimental/distortionNG
- Timestamp:
- Apr 21, 2012, 11:11:37 PM (13 years ago)
- Location:
- experimental/distortionNG
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/DistortionManipulator.cpp
r355 r356 37 37 38 38 createVertexHighlighter(); 39 createHUD(); 39 40 40 41 _camera = 0; … … 48 49 void DistortionManipulator::getUsage(osg::ApplicationUsage& usage) const 49 50 { 50 usage.addKeyboardMouseBinding("Keypad 7","Show distortion mesh / intensity map / none."); 51 usage.addKeyboardMouseBinding("Keypad 8","Save distortion set."); // via plugin 51 usage.addKeyboardMouseBinding("Keypad 0","Show/Hide distortion HUD."); 52 usage.addKeyboardMouseBinding("Keypad 1","Reset distortion."); 53 usage.addKeyboardMouseBinding("Keypad 2","Reset intensity blending."); 52 54 usage.addKeyboardMouseBinding("Keypad 4","Toggles Setup Mode between DISABLED, MANUAL & DELEGATED."); 53 55 usage.addKeyboardMouseBinding("Keypad 5","MANUAL Mode: Toggle between blending & distortion setup."); 54 55 usage.addKeyboardMouseBinding("Keypad 1","Reset distortion.");56 usage.addKeyboardMouseBinding("Keypad 2","Reset intensity blending.");56 usage.addKeyboardMouseBinding("Keypad 6","MANUAL Mode: Toggle if distortion drags affect mesh or rtt texture coordinates."); // Defaults to Mesh 57 usage.addKeyboardMouseBinding("Keypad 7","Show distortion mesh / intensity map / none."); 58 usage.addKeyboardMouseBinding("Keypad 8","Save distortion set."); // via plugin 57 59 } 58 60 … … 84 86 { 85 87 OSG_ALWAYS<<"mouse click!"<<std::endl; 86 if ( activeSetupMode == MANUAL && ea.getModKeyMask()&osgGA::GUIEventAdapter::MODKEY_CTRL&& ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON )88 if ( activeSetupMode == MANUAL /*&& ea.getModKeyMask()&osgGA::GUIEventAdapter::MODKEY_CTRL*/ && ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON ) 87 89 { 88 90 osgViewer::View* viewer = dynamic_cast<osgViewer::View*>(&aa); … … 107 109 case(osgGA::GUIEventAdapter::KEYDOWN): 108 110 { 111 if (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Insert) // KP 0: Show/Hide HUD // definition: child #0 = mesh, #1 = highlighter, #2 HUD 112 { 113 bool oldValue = _distortionSet->getDistortionInternals()->getValue(2); 114 _distortionSet->getDistortionInternals()->setValue(2, !oldValue); 115 return(true); 116 } 109 117 if (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_End) // KP 1: reset distortion 110 118 { … … 124 132 { 125 133 activeSetupMode = MANUAL; 126 OSG_ ALWAYS<<"SetupMode MANUAL activated"<<std::endl;127 _distortionSet->getDistortionInternals()->setValue(1, true); // per definition #0 = mesh, #1 = highlighter134 OSG_NOTICE<<"SetupMode MANUAL activated"<<std::endl; 135 _distortionSet->getDistortionInternals()->setValue(1, true); // definition: child #0 = mesh, #1 = highlighter, #2 HUD 128 136 break; 129 137 } … … 131 139 { 132 140 activeSetupMode = DELEGATED; 133 _distortionSet->getDistortionInternals()->setValue(1, false); // per definition #0 = mesh, #1 = highlighter134 OSG_ ALWAYS<<"SetupMode DELEGATED activated"<<std::endl;141 _distortionSet->getDistortionInternals()->setValue(1, false); // definition: child #0 = mesh, #1 = highlighter, #2 HUD 142 OSG_NOTICE<<"SetupMode DELEGATED activated"<<std::endl; 135 143 break; 136 144 } … … 138 146 { 139 147 activeSetupMode = DISABLED; 140 _distortionSet->getDistortionInternals()->setValue(1, false); // per definition #0 = mesh, #1 = highlighter141 OSG_ ALWAYS<<"SetupMode DISABLED activated"<<std::endl;148 _distortionSet->getDistortionInternals()->setValue(1, false); // definition: child #0 = mesh, #1 = highlighter, #2 HUD 149 OSG_NOTICE<<"SetupMode DISABLED activated"<<std::endl; 142 150 break; 143 151 } 144 152 } 145 153 updateHUD(); 146 154 return(true); 147 155 } … … 150 158 151 159 activeManualSetupMode = (activeManualSetupMode==DISTORTION?BLENDING:DISTORTION); 152 OSG_ALWAYS<<"KEY_KP_5 : activeManualSetupMode is now "<<activeManualSetupMode<<std::endl;160 updateHUD(); 153 161 return(true); 154 162 } … … 156 164 { 157 165 activeDistortionMode = (activeDistortionMode==MESH?TEXCOORDINATES:MESH); 158 OSG_ALWAYS<<"KEY_KP_6 : activeDistortionMode is now "<<activeDistortionMode<<std::endl;166 updateHUD(); 159 167 return(true); 160 168 } … … 186 194 } 187 195 188 189 OSG_ALWAYS<<"KEY_KP_7 : activeVisualizationMode is now "<<activeVisualizationMode<<std::endl<<std::endl; 196 updateHUD(); 190 197 return(true); 191 198 } … … 196 203 } 197 204 198 199 205 return false; // Event ignored 200 206 } … … 202 208 case(osgGA::GUIEventAdapter::FRAME): 203 209 { 204 //OSG_ALWAYS<<"FRAME!"<<std::endl; 210 if ( activeSetupMode == DELEGATED) 211 { 212 OSG_ALWAYS<<"Todo: Calling delegated class!"<<std::endl; 213 } 205 214 break; 206 215 } … … 297 306 geode->setCullingActive(false); // disable the culling for the selector, otherwise the selector is culled away on the edge. 298 307 299 _distortionSet->getDistortionInternals()->addChild(geode, false); 308 _distortionSet->getDistortionInternals()->addChild(geode, false); // = child #1 :definition: child #0 = mesh, #1 = highlighter, #2 HUD 309 } 310 311 void DistortionManipulator::createHUD() 312 { 313 osg::ref_ptr<osg::Geode> geode = new osg::Geode; 314 315 osg::StateSet* stateSet = geode->getOrCreateStateSet(); 316 stateSet->setRenderBinDetails( 99, "RenderBin"); 317 // disable depth test to ensure that it is always drawn. 318 stateSet->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF); 319 stateSet->setMode(GL_LIGHTING,osg::StateAttribute::OFF); 320 321 // Add Text: 322 osg::Vec3 position(20.0f,120.0f,0.0f); 323 osg::Vec3 delta(0.0f,-25.0f,0.0f); 324 std::string timesFont("fonts/arial.ttf"); 325 { 326 osg::ref_ptr<osgText::Text> textHeader = new osgText::Text; 327 textHeader->setText("Distortion Setup:"); 328 textHeader->setFont(timesFont); 329 textHeader->setPosition(position); 330 textHeader->setCharacterSize(21); 331 textHeader->setDataVariance(osg::Object::STATIC); 332 geode->addDrawable( textHeader ); 333 334 position += delta; 335 336 hudSetupMode = new osgText::Text; 337 hudSetupMode->setFont(timesFont); 338 hudSetupMode->setPosition(position); 339 hudSetupMode->setCharacterSize(21); 340 hudSetupMode->setDataVariance(osg::Object::DYNAMIC); 341 geode->addDrawable( hudSetupMode ); 342 343 position += delta; 344 345 hudDistortionMode = new osgText::Text; 346 hudDistortionMode->setFont(timesFont); 347 hudDistortionMode->setPosition(position); 348 hudDistortionMode->setCharacterSize(21); 349 hudDistortionMode->setDataVariance(osg::Object::DYNAMIC); 350 geode->addDrawable( hudDistortionMode ); 351 352 position += delta; 353 354 hudManualSetupMode = new osgText::Text; 355 hudManualSetupMode->setFont(timesFont); 356 hudManualSetupMode->setPosition(position); 357 hudManualSetupMode->setCharacterSize(21); 358 hudManualSetupMode->setDataVariance(osg::Object::DYNAMIC); 359 geode->addDrawable( hudManualSetupMode ); 360 361 position += delta; 362 363 hudVisualizationMode = new osgText::Text; 364 hudVisualizationMode->setFont(timesFont); 365 hudVisualizationMode->setPosition(position); 366 hudVisualizationMode->setCharacterSize(21); 367 hudVisualizationMode->setDataVariance(osg::Object::DYNAMIC); 368 geode->addDrawable( hudVisualizationMode ); 369 } 370 371 updateHUD(); 372 _distortionSet->getDistortionInternals()->addChild(geode, false); // = child #2 :definition: child #0 = mesh, #1 = highlighter, #2 HUD 373 } 374 375 void DistortionManipulator::updateHUD() 376 { 377 switch(activeSetupMode) 378 { 379 case DISABLED : hudSetupMode->setText("Setup Mode : DISABLED"); break; 380 case MANUAL : hudSetupMode->setText("Setup Mode : MANUAL"); break; 381 case DELEGATED : hudSetupMode->setText("Setup Mode : DELEGATED"); break; 382 default: hudSetupMode->setText(""); 383 }; 384 switch(activeDistortionMode) 385 { 386 case MESH : hudDistortionMode->setText("Distortion Mode : MESH"); break; 387 case TEXCOORDINATES : hudDistortionMode->setText("Distortion Mode : TEXCOORDINATES"); break; 388 default: hudDistortionMode->setText(""); 389 }; 390 switch(activeManualSetupMode) 391 { 392 case DISTORTION : hudManualSetupMode->setText("Manual Setup Mode : DISTORTION"); break; 393 case BLENDING : hudManualSetupMode->setText("Manual Setup Mode : BLENDING"); break; 394 default: hudManualSetupMode->setText(""); 395 }; 396 switch(activeVisualizationMode) 397 { 398 case DISTORTION_MESH : hudVisualizationMode->setText("Visualization Mode : DISTORTION_MESH"); break; 399 case INTENSITY_MAP : hudVisualizationMode->setText("Visualization Mode : INTENSITY_MAP"); break; 400 case NONE : hudVisualizationMode->setText("Visualization Mode : NONE"); break; 401 default: hudVisualizationMode->setText(""); 402 }; 300 403 } 301 404 -
experimental/distortionNG/DistortionManipulator.h
r353 r356 26 26 #include <osgUtil/IntersectionVisitor> 27 27 #include <osgUtil/LineSegmentIntersector> 28 #include <osgText/Text> 28 29 29 30 #include "DistortionSet.h" … … 74 75 void computeSelectedVertex( osgUtil::LineSegmentIntersector::Intersection& result ); 75 76 void createVertexHighlighter(); 77 void createHUD(); 78 void updateHUD(); 76 79 77 80 SetupMode activeSetupMode; … … 87 90 osg::Geometry* _distortionMesh; 88 91 const osg::Vec4 _highlightColor; 92 93 // HUD 94 osg::ref_ptr<osgText::Text> hudSetupMode; 95 osg::ref_ptr<osgText::Text> hudDistortionMode; 96 osg::ref_ptr<osgText::Text> hudManualSetupMode; 97 osg::ref_ptr<osgText::Text> hudVisualizationMode; 89 98 }; 90 99 -
experimental/distortionNG/main.cpp
r353 r356 18 18 19 19 #include "extViewer.h" 20 #include "distortionNG.h"21 20 22 21 #include <osg/ArgumentParser> … … 175 174 * distortionManipulator abgeleitet von osgGA::GUIEventHandler 176 175 * Grundfunktionen: 177 * [ done] - Key to Show Distortion Mesh / Intensity Map / none176 * [.] - Key to Show Distortion Mesh / Intensity Map / none 178 177 * - Key to Save distortion Container - via plugin 179 * [ done] - Key to toggle MANUAL mode between blending und distortion setup178 * [.] - Key to toggle MANUAL mode between blending und distortion setup 180 179 * [done] - Key to toggle distortion setup: 181 180 * DISABLED distortion/blending modifications are forbidden (ggfs. beim Verlassen von DISABLED ggf. auf singleThreaded wechseln und beim aktivieren von DISABLED wieder auf das alte threadingmodel. Alternativ die data variance des meshes/Blendmap beeinflussen) … … 185 184 * - Key to reset Distortion. 186 185 * [done] - Key to reset Blending. 186 * [done] - Key to Show/Hide distortion HUD 187 187 * 188 188 * Die Funktion handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ): 189 * 190 * MANUAL : auf mouse selection und drags horchen und auf Distortion Anwenden. bei keys die obigen funktionen realisieren191 * DELEGATED : beim typ FRAME die Distortion zur Veränderung stellen indem der Pointer an die bearbeitende Funktion übergeben wird:189 * [done] DISABLED: ignorieren 190 * [.] MANUAL : auf mouse selection und drags horchen und auf Distortion Anwenden. bei keys die obigen funktionen realisieren 191 * [.] DELEGATED : beim typ FRAME die Distortion zur Veränderung stellen indem der Pointer an die bearbeitende Funktion übergeben wird: 192 192 * subsclassed function aufrufen bzw foreignClass->delegateDistortionSetup(distContainer& container) 193 193 *
Note: See TracChangeset
for help on using the changeset viewer.