Changeset 340 for experimental/distortionNG/extViewer.cpp
- Timestamp:
- Mar 24, 2012, 10:00:11 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/extViewer.cpp
r339 r340 148 148 geom->setTexCoordArray(1,texcoords1); 149 149 150 //// Quads grid 150 // Quads grid 151 for ( unsigned int row=0; row<rows-1; row++ ) // each strip consists of two affected vertex rows, so we need only row-1 strips. 152 { 153 osg::ref_ptr<osg::DrawElementsUInt> de = new osg::DrawElementsUInt(GL_QUAD_STRIP, columns*2); // columns*2 = number of involved vertices for this strip. 154 for ( unsigned int col=0; col<columns; col++ ) 155 { 156 (*de)[col*2 + 0] = row*columns + col; 157 (*de)[col*2 + 1] = (row+1)*columns + col; 158 } 159 geom->addPrimitiveSet( de.get() ); 160 } 161 162 //// Triangle grid 151 163 //for ( unsigned int row=0; row<rows-1; row++ ) // each strip consists of two affected vertex rows, so we need only row-1 strips. 152 164 //{ 153 // osg::ref_ptr<osg::DrawElementsUInt> de = new osg::DrawElementsUInt( GL_QUAD_STRIP, columns*2); // columns*2 = number of involved vertices for this strip.165 // osg::ref_ptr<osg::DrawElementsUInt> de = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLE_STRIP, columns * 2 ); 154 166 // for ( unsigned int col=0; col<columns; col++ ) 155 167 // { … … 159 171 // geom->addPrimitiveSet( de.get() ); 160 172 //} 161 162 // Triangle grid163 for ( unsigned int row=0; row<rows-1; row++ ) // each strip consists of two affected vertex rows, so we need only row-1 strips.164 {165 osg::ref_ptr<osg::DrawElementsUInt> de = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLE_STRIP, columns * 2 );166 for ( unsigned int col=0; col<columns; col++ )167 {168 (*de)[col*2 + 0] = row*columns + col;169 (*de)[col*2 + 1] = (row+1)*columns + col;170 }171 geom->addPrimitiveSet( de.get() );172 }173 173 174 174 return geom.release(); … … 340 340 geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); 341 341 geode->getOrCreateStateSet()->setAttributeAndModes( new osg::PolygonOffset(1.0f, 1.0f) ); 342 osg::ref_ptr<distortionHandler> selector = new distortionHandler( camera, distortionMesh );342 osg::ref_ptr<distortionHandler> selectorHandler = new distortionHandler( camera, distortionMesh ); 343 343 osg::ref_ptr<osg::Group> root = new osg::Group; 344 344 root->addChild(geode); 345 root->addChild(selector->createVertexHighlighter()); 346 addEventHandler( selector.get() ); 345 osg::Geode* selectorHighlighter = selectorHandler->createVertexHighlighter(); 346 selectorHighlighter->setCullingActive(false); // disable the culling for the selector, otherwise the selector is culled away on the edge. 347 root->addChild(selectorHighlighter); 348 addEventHandler( selectorHandler.get() ); 347 349 camera->addChild(root); 348 350 // Avoid that the highlighter is culled away
Note: See TracChangeset
for help on using the changeset viewer.