Thanx mery much Skylark, 

here is the correct code, the "Blue" color is update.


Code:

[color=green]//positions[/color]
osg::Vec3f v3f_start(33.0f, -23.0f, 10.0f);     [color=green]//init position ( 
start )[/color]
        osg::Vec3d v3f_end(33.0f, -23.0f, -5.0f);       [color=green]//init 
position ( end )[/color]
        
        [color=green]//create group[/color]
        osg::ref_ptr<osgUtil::IntersectorGroup> intersectorGroup = new 
osgUtil::IntersectorGroup();
        osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector = new 
osgUtil::LineSegmentIntersector(v3f_start, v3f_end);
        intersectorGroup->addIntersector( intersector.get() );
        osgUtil::IntersectionVisitor intersectVisitor( intersectorGroup.get(), 
new MyReadCallback );
        model->accept(intersectVisitor);        
        
        [color=green]//call first test[/color]  check_face(intersectorGroup);   
        
        
        [color=green]//update position[/color]
        osgUtil::IntersectorGroup::Intersectors& ints = 
intersectorGroup->getIntersectors();
        for(osgUtil::IntersectorGroup::Intersectors::iterator intersector_itr2 
= ints.begin();
                                        intersector_itr2 != ints.end();
                                        ++intersector_itr2)
        {
                osgUtil::LineSegmentIntersector* lsi = 
dynamic_cast<osgUtil::LineSegmentIntersector*>(intersector_itr2->get());
                if (lsi)
                {
                        v3f_start.set(33.0f, 23.0f, 10.0f);     
[color=green]//new position ( start )[/color]                   
v3f_end.set(33.0f, 23.0f, -5.0f);       [color=green]//new position ( end 
)[/color]
                        lsi->setStart( v3f_start );  
                        lsi->setEnd( v3f_end );
                }
        }
        
        [color=green]//reset and re-run (must be!)[/color]

[color=blue]intersectVisitor.reset();
        model->accept(intersectVisitor);[/color]

        [color=green]//call 2nd test[/color]
        check_face(intersectorGroup);




Function for test is here:


Code:
void check_face(osgUtil::IntersectorGroup *intersectorGroup)
{
        if ( intersectorGroup->containsIntersections() )
        {
                osgUtil::IntersectorGroup::Intersectors& intersectors = 
intersectorGroup->getIntersectors();
                for(osgUtil::IntersectorGroup::Intersectors::iterator 
intersector_itr = intersectors.begin();
                                        intersector_itr != intersectors.end();
                                        ++intersector_itr)
                {
                        osgUtil::LineSegmentIntersector* lsi = 
dynamic_cast<osgUtil::LineSegmentIntersector*>(intersector_itr->get());
                        if (lsi)
                        {
                                osgUtil::LineSegmentIntersector::Intersections& 
intersections = lsi->getIntersections();
                                
for(osgUtil::LineSegmentIntersector::Intersections::iterator itr = 
intersections.begin();
                                        itr != intersections.end();
                                        ++itr)
                                {
                                        const 
osgUtil::LineSegmentIntersector::Intersection& intersection = *itr;
                                        osg::Vec3f lv_pos;
                                        
                                        lv_pos = 
intersection.getWorldIntersectPoint(); 
                                }
                        }
                }
        }
}



------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=11996#11996





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to