Ignore:
Timestamp:
Mar 24, 2012, 10:00:11 AM (12 years ago)
Author:
Torben Dannhauer
Message:

The intersection works and the selector highlighter is set and displayed correctly.
Next steps:

  • use a variable to control whether distortion setup is active or not. temporarily track the Ctrl Key to enably(push or disable(release) the edit mode.
  • Hide the highlighter and disable the intersection/drag tracking on diabled edit mode.
  • catch up dragging values and translate them in the correct coordinate frame.
  • apply dragging values:
  • a) either on the texture coordinate while the grid is constant,
  • b) or apply them on the grid node coordinates while the texture coordinates are constant (check/compare solutions!)



File:
1 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/extViewer.cpp

    r339 r340  
    148148                geom->setTexCoordArray(1,texcoords1);
    149149
    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
    151163        //for ( unsigned int row=0; row<rows-1; row++ ) // each strip consists of two affected vertex rows, so we need only row-1 strips.
    152164        //{
    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 );   
    154166        //      for ( unsigned int col=0; col<columns; col++ )
    155167        //      {
     
    159171        //      geom->addPrimitiveSet( de.get() );
    160172        //}
    161 
    162         // Triangle grid
    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.
    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         }
    173173
    174174        return geom.release();
     
    340340                geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
    341341                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 );
    343343                osg::ref_ptr<osg::Group> root = new osg::Group;
    344344                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() );
    347349                camera->addChild(root);
    348350                // Avoid that the highlighter is culled away
Note: See TracChangeset for help on using the changeset viewer.