Changeset 340 for experimental


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!)



Location:
experimental/distortionNG
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/distortionNG.cpp

    r339 r340  
    5252                if ( viewer )
    5353                {
    54                         osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(), ea.getY());
     54                        osg::notify(osg::ALWAYS)<<std::endl<<"Intersection:"<<std::endl<<"ea.getX()="<<ea.getX()<<std::endl;
     55                        osg::notify(osg::ALWAYS)<<"ea.getY()="<<ea.getY()<<std::endl;
     56                        osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::PROJECTION, ea.getX(), ea.getY());
    5557                        osgUtil::IntersectionVisitor iv( intersector.get() );
    5658                        //viewer->getCamera()->accept( iv );
     
    6769        if ( ea.getEventType() == osgGA::GUIEventAdapter::DRAG  )
    6870        {
    69         osg::notify(osg::ALWAYS)<<std::endl<<"ea.getGraphicsContext()="<<ea.getGraphicsContext()<<std::endl;
     71                osg::notify(osg::ALWAYS)<<std::endl<<"Drag:"<<std::endl<<"ea.getGraphicsContext()="<<ea.getGraphicsContext()<<std::endl;
    7072        osg::notify(osg::ALWAYS)<<"ea.getXnormalized()="<<ea.getXnormalized()<<std::endl;
    7173        osg::notify(osg::ALWAYS)<<"ea.getYnormalized()="<<ea.getYnormalized()<<std::endl;
     
    112114                                closestVertexIndex = result.indexList[i];
    113115                        }
    114                 //      OSG_NOTIFY(osg::ALWAYS)<<"maxRatio="<<maxRatio<<std::endl;
    115                 //      OSG_NOTIFY(osg::ALWAYS)<<"closestVertexIndex="<<closestVertexIndex<<std::endl;
     116                        OSG_NOTIFY(osg::ALWAYS)<<"maxRatio="<<maxRatio<<std::endl;
     117                        OSG_NOTIFY(osg::ALWAYS)<<"closestVertexIndex="<<closestVertexIndex<<std::endl;
    116118                }
    117119                OSG_NOTIFY(osg::ALWAYS)<<"nearest vertex: X="<<(*vertices)[closestVertexIndex].x()<<" Y="<<(*vertices)[closestVertexIndex].y()<<" Z="<<(*vertices)[closestVertexIndex].z()<<std::endl;
  • 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
  • experimental/distortionNG/main.cpp

    r331 r340  
    140140/*
    141141ToDo:
     142
     143The intersection works and the selector highlighter is set and displayed correctly.
     144Next steps:
     145 * 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.
     146 * Hide the highlighter and disable the intersection/drag tracking on diabled edit mode.
     147 * catch up dragging values and translate them in the correct coordinate frame.
     148 * apply dragging values:
     149 *      a) either on the texture coordinate while the grid is constant,
     150 *  b) or apply them on the grid node coordinates while the texture coordinates are constant (check/compare solutions!)
    142151 *
    143  * distortionHandler::handle startet Intersections. Da jedoch das distortion Mesh keine Geometry der Scene mehr ist, gibt es keine Intersection
    144  *  -> es muss die intersektion umgestellt werden, um das Distortion Mesh zu intersecten.
    145  * Es muss geprüft werdne, ob bei dne Mausverschiebungen die texturecoordinaten verschoben, oder das Distortion Mesh verschoben wird.
    146 
    147 
    148 
    149 
     152 
    150153
    151154*/
Note: See TracChangeset for help on using the changeset viewer.