Changeset 309 for experimental/distortionNG/main.cpp
- Timestamp:
- Aug 2, 2011, 11:38:09 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/main.cpp
r308 r309 17 17 */ 18 18 19 #include "distortionNG.h" 20 19 21 #include <osg/ArgumentParser> 22 #include <osg/PolygonOffset> 23 20 24 #include <osgDB/ReadFile> 21 25 … … 93 97 if (!rootnode) 94 98 { 95 osg::notify(osg::WARN)<<"Warning: no valid data loaded, please specify a database on the command line."<<std::endl; 96 return 1; 99 rootnode = osgDB::readNodeFile("cow.osgt"); 100 if(!rootnode) 101 { 102 osg::notify(osg::WARN)<<"Warning: no valid data loaded, please specify a database on the command line."<<std::endl; 103 return 1; 104 } 97 105 } 98 106 107 osg::ref_ptr<osg::Geode> geode = new osg::Geode; 108 geode->addDrawable( distortionNG::createMesh(16, 9) ); 109 geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); 110 geode->getOrCreateStateSet()->setAttributeAndModes( new osg::PolygonOffset(1.0f, 1.0f) ); 99 111 100 // add a viewport to the viewer and attach the scene graph. 101 viewer.setSceneData( rootnode ); 112 osg::ref_ptr<distortionHandler> selector = new distortionHandler( viewer.getCamera() ); 102 113 114 osg::ref_ptr<osg::Group> root = new osg::Group; 115 root->addChild( geode.get() ); 116 root->addChild( selector->createVertexHighlighter() ); 103 117 104 // run the viewers main loop 105 return viewer.run();118 viewer.addEventHandler( selector.get() ); 119 viewer.setSceneData( root.get() ); 106 120 121 // Avoid that the highlighter is culled away 122 osg::CullSettings::CullingMode mode = viewer.getCamera()->getCullingMode(); 123 viewer.getCamera()->setCullingMode( mode & (~osg::CullSettings::SMALL_FEATURE_CULLING) ); 124 125 // run the viewers main loop 126 return viewer.run(); 107 127 }
Note: See TracChangeset
for help on using the changeset viewer.