Changeset 329 for experimental/distortionNG/distortionNG.cpp
- Timestamp:
- Mar 3, 2012, 1:22:05 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/distortionNG.cpp
r313 r329 27 27 _highlighter->setUseDisplayList( false ); 28 28 _highlighter->setUseVertexBufferObjects( true ); 29 _highlighter->setVertexArray( new osg::Vec3Array(1) ); 29 _highlighter->setVertexArray( new osg::Vec3Array(1) ); // The highlighter vertex is updated by computeSelectedVertex(..) 30 30 _highlighter->setColorArray( colors.get() ); 31 31 _highlighter->setColorBinding( osg::Geometry::BIND_OVERALL ); … … 54 54 osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(), ea.getY()); 55 55 osgUtil::IntersectionVisitor iv( intersector.get() ); 56 viewer->getCamera()->accept( iv ); 56 //viewer->getCamera()->accept( iv ); 57 _camera->accept( iv ); 57 58 58 59 if ( intersector->containsIntersections() ) … … 93 94 if ( !vertices || !selVertices ) 94 95 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; 95 99 96 100 osg::Vec3 point = result.getWorldIntersectPoint(); 97 101 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; 99 103 const std::vector<unsigned int>& selIndices = result.indexList; 100 104 { 101 105 double maxRatio = 0.0; 102 106 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 104 108 { 105 109 if(result.ratioList[i] > maxRatio) … … 108 112 closestVertexIndex = result.indexList[i]; 109 113 } 114 OSG_NOTIFY(osg::ALWAYS)<<"maxRatio="<<maxRatio<<std::endl; 115 OSG_NOTIFY(osg::ALWAYS)<<"closestVertexIndex="<<closestVertexIndex<<std::endl; 110 116 } 117 OSG_NOTIFY(osg::ALWAYS)<<"nearest vertex: X="<<(*vertices)[closestVertexIndex].x()<<" Y="<<(*vertices)[closestVertexIndex].y()<<" Z="<<(*vertices)[closestVertexIndex].z()<<std::endl; 111 118 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; 113 122 } 114 115 123 selVertices->dirty(); 116 124 _highlighter->dirtyBound();
Note: See TracChangeset
for help on using the changeset viewer.