Ignore:
Timestamp:
Mar 3, 2012, 1:22:05 AM (12 years ago)
Author:
Torben Dannhauer
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/distortionNG.cpp

    r313 r329  
    2727        _highlighter->setUseDisplayList( false );
    2828        _highlighter->setUseVertexBufferObjects( true );
    29         _highlighter->setVertexArray( new osg::Vec3Array(1) );
     29        _highlighter->setVertexArray( new osg::Vec3Array(1) );  // The highlighter vertex is updated by computeSelectedVertex(..)
    3030        _highlighter->setColorArray( colors.get() );
    3131        _highlighter->setColorBinding( osg::Geometry::BIND_OVERALL );
     
    5454                        osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(), ea.getY());
    5555                        osgUtil::IntersectionVisitor iv( intersector.get() );
    56                         viewer->getCamera()->accept( iv );
     56                        //viewer->getCamera()->accept( iv );
     57                        _camera->accept( iv );
    5758               
    5859                        if ( intersector->containsIntersections() )
     
    9394        if ( !vertices || !selVertices )
    9495                return;
     96       
     97        OSG_NOTIFY(osg::ALWAYS)<<"size of vertices="<<vertices->size()<<std::endl;
     98        OSG_NOTIFY(osg::ALWAYS)<<"size of selVertices="<<selVertices->size()<<std::endl;
    9599
    96100        osg::Vec3 point = result.getWorldIntersectPoint();
    97101        osg::Matrix matrix = osg::computeLocalToWorld( result.nodePath );       // To compute the intersection vertices in world coordinates not in model coordinates
    98         //std::cout << "Intersection-indices: Size=" << result.indexList.size() << std::endl;
     102        OSG_NOTIFY(osg::ALWAYS) << "Intersection-indices: Size=" << result.indexList.size() << std::endl;
    99103        const std::vector<unsigned int>& selIndices = result.indexList;
    100104        {
    101105                double maxRatio = 0.0;
    102106                int closestVertexIndex = 0;
    103                 for ( unsigned int i=0; i<3 && i<result.ratioList.size(); i++ ) //iterate through rations and search for max
     107                for ( unsigned int i=0; i<3 && i<result.ratioList.size(); i++ ) //iterate through rations and search for maxRation=nearestVertex
    104108                {
    105109                        if(result.ratioList[i] > maxRatio)
     
    108112                                closestVertexIndex = result.indexList[i];
    109113                        }
     114                        OSG_NOTIFY(osg::ALWAYS)<<"maxRatio="<<maxRatio<<std::endl;
     115                        OSG_NOTIFY(osg::ALWAYS)<<"closestVertexIndex="<<closestVertexIndex<<std::endl;
    110116                }
     117                OSG_NOTIFY(osg::ALWAYS)<<"nearest vertex: X="<<(*vertices)[closestVertexIndex].x()<<" Y="<<(*vertices)[closestVertexIndex].y()<<" Z="<<(*vertices)[closestVertexIndex].z()<<std::endl;
    111118                osg::Vec3 vertex = (*vertices)[closestVertexIndex] * matrix;
    112                 selVertices->front() = vertex;
     119
     120                selVertices->front() = vertex;         
     121                OSG_NOTIFY(osg::ALWAYS)<<"selected vertice: X="<<vertex.x()<<" Y="<<vertex.y()<<" Z="<<vertex.z()<<std::endl;
    113122        }
    114 
    115123        selVertices->dirty();
    116124        _highlighter->dirtyBound();
Note: See TracChangeset for help on using the changeset viewer.