Changeset 370
- Timestamp:
- Jun 1, 2012, 6:11:26 PM (13 years ago)
- Location:
- experimental/distortionNG
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/DistortionManipulator.cpp
r367 r370 51 51 sh->setName("shaderIntensityMapVis"); 52 52 ds->setShaderIntensityMapVis( sh ); 53 54 //LF Get Screen Resolution for Cursor Position Scaling 55 osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface(); 56 if (!wsi) { osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl; } 57 wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), _screenPixWidth, _screenPixHeight); 58 59 53 60 } 54 61 … … 71 78 bool DistortionManipulator::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* obj, osg::NodeVisitor* nv) 72 79 { 80 81 73 82 switch(ea.getEventType()) 74 83 { … … 87 96 OSG_ALWAYS<<"ea.getYin()="<<ea.getYmin()<<std::endl; 88 97 OSG_ALWAYS<<"ea.getYmax()="<<ea.getYmax()<<std::endl; 89 90 98 99 //LF get X,Y normalized to lowerleftcorner (0,0) / upperrightcorner (1,1) 100 OSG_ALWAYS<<"getXnormalizedLF()="<<(ea.getXnormalized()+1.0)/2.0<<std::endl; 101 OSG_ALWAYS<<"getYnormalizedLF()="<<(ea.getYnormalized()+1.0)/2.0<<std::endl; 102 103 //LF get X,Y in pixels (lowerleftcorner (0,0) / upperrightcorner (screenwidth,screenheigth) 104 OSG_ALWAYS<<std::endl<<"Screen Resolution: "<<_screenPixWidth<<" x "<<_screenPixHeight<<std::endl; 105 OSG_ALWAYS<<"getXPixelspaceLF()="<<(int)((float)_screenPixWidth*(ea.getXnormalized()+1.0)/2.0)<<std::endl; 106 OSG_ALWAYS<<"getYPixelspaceLF()="<<(int)((float)_screenPixHeight*(ea.getYnormalized()+1.0)/2.0)<<std::endl; 91 107 92 108 if(activeDistortionMode == MESH) … … 120 136 if ( intersector->containsIntersections() ) 121 137 { 122 osgUtil::LineSegmentIntersector::Intersection& result = *(intersector->getIntersections().begin()); 123 computeSelectedVertex( result ); 138 //osgUtil::LineSegmentIntersector::Intersection& result = *(intersector->getIntersections().begin()); 139 osgUtil::LineSegmentIntersector::Intersection *result; 140 result=&intersector->getFirstIntersection(); 141 computeSelectedVertex( *result ); 142 //computeSelectedVertex( result ); 124 143 } 125 144 } … … 222 241 OSG_ALWAYS<<"KEY_KP_8 : todo: Save DistortionContainer"<<std::endl; 223 242 224 225 226 // Configure Compression and instantiate read/write-options 227 bool asAscii_ = true; 228 bool compressionEnabled = false; 229 230 std::string readOptionString = ""; 231 std::string writeOptionString = ""; 232 if(asAscii_) 233 { 234 readOptionString = "Ascii"; 235 writeOptionString = "Ascii"; 236 } 237 if (compressionEnabled) 238 writeOptionString+=" Compressor=zlib"; 239 240 osg::ref_ptr<osgDB::Options> readOptions = new osgDB::Options( readOptionString.c_str() ); 241 osg::ref_ptr<osgDB::Options> writeOptions = new osgDB::Options( writeOptionString.c_str() ); 242 243 //// Get ReaderWriter 244 //osg::ref_ptr<osgDB::ReaderWriter> rw = osgDB::Registry::instance()->getReaderWriterForExtension("osgb"); 245 246 //// Writing node to stream 247 //std::stringstream myOstream; 248 //if ( rw ) 249 //{ 250 // osgDB::ReaderWriter::WriteResult wr = rw->writeObject( *_distortionSet, myOstream, writeOptions ); 251 // if (wr.success() ) 252 // { 253 // OSG_ALWAYS<<"write node success"<<std::endl; 254 // } 255 // else 256 // { 257 // OSG_ALWAYS<<"write node failed"<<std::endl; 258 // } 259 //} 260 261 if( osgDB::writeObjectFile(*_distortionSet, "test.osgt", writeOptions) ) 262 { 263 OSG_ALWAYS<<"write node success"<<std::endl; 264 } 265 else 266 { 267 OSG_ALWAYS<<"write node failed"<<std::endl; 268 } 269 270 271 272 273 274 275 276 277 278 279 280 281 243 osgDB::writeObjectFile( *_distortionSet, "distortionset.dist" ); 282 244 return(true); 283 245 } … … 411 373 stateSet->setMode(GL_LIGHTING,osg::StateAttribute::OFF); 412 374 375 // Modify StateSet to protect it against state changes by the stateset Manipulator 376 osg::PolygonMode* polyModeObj = new osg::PolygonMode; 377 stateSet->setAttribute(polyModeObj, osg::StateAttribute::PROTECTED|osg::StateAttribute::ON); 378 413 379 // Add Text: 414 380 osg::Vec3 position(20.0f,120.0f,0.0f); … … 462 428 463 429 updateHUD(); 464 _distortionSet->getDistortionInternals()->addChild(geode, false); // = child #2 :definition: child #0 = mesh, #1 = highlighter, #2 HUD430 _distortionSet->getDistortionInternals()->addChild(geode, false); // = child #2. The definition is: child #0 = mesh, #1 = highlighter, #2 HUD 465 431 } 466 432 -
experimental/distortionNG/DistortionManipulator.h
r356 r370 90 90 osg::Geometry* _distortionMesh; 91 91 const osg::Vec4 _highlightColor; 92 93 //LF Screen Resolution 94 unsigned int _screenPixWidth, _screenPixHeight; 95 92 96 93 97 // HUD -
experimental/distortionNG/extViewer.cpp
r362 r370 276 276 stateset->setTextureAttributeAndModes(_distortionSet->getTexUnitScene(), sceneTexture,osg::StateAttribute::ON); 277 277 stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF); 278 // Modify StateSet to protectit agai unst state changes by the stateset Manipulator278 // Modify StateSet to protectit against state changes by the stateset Manipulator 279 279 osg::PolygonMode* polyModeObj = new osg::PolygonMode; 280 280 stateset->setAttribute(polyModeObj, osg::StateAttribute::PROTECTED|osg::StateAttribute::ON); -
experimental/distortionNG/main.cpp
r369 r370 58 58 // ---- test plugin read / write 59 59 60 //osgDB::writeObjectFile( *_distortionSet, " testcont.dist" );60 //osgDB::writeObjectFile( *_distortionSet, "distortionset.dist" ); 61 61 _distortionSet = NULL; 62 _distortionSet = dynamic_cast<osgViewer::DistortionSet*>( osgDB::readObjectFile( " testcont.dist" ) );62 _distortionSet = dynamic_cast<osgViewer::DistortionSet*>( osgDB::readObjectFile( "distortionset.dist" ) ); 63 63 64 64 … … 164 164 * Ensures the Coordinates are normalized before saving the container. 165 165 * Load: 166 * * use serializerto load container166 * [done] * use ReaderWriterOSG2 to load container 167 167 * * invoke osgViewer::setUpViewForManualDistortion(distSet, screenNum, projectorMatrix) to set up distortion 168 168 * Save: 169 169 * * check if container is normalized. if not, copy and normalize container 170 * * use serializerto save container170 * [done] * use ReaderWriterOSG2 to save container 171 171 * 172 172 *
Note: See TracChangeset
for help on using the changeset viewer.