zoukankan      html  css  js  c++  java
  • osg线段和模型求交点

    1. osg::Vec3 p_start(-100,0,0);  
    2.     osg::Vec3 p_end(100,0,0);  
    3.     osgUtil::LineSegmentIntersector::Intersections _intersections;  
    4.     osg::ref_ptr< osgUtil::LineSegmentIntersector > _lineSegmentIntersector = new osgUtil::LineSegmentIntersector(p_start,p_end);  
    5.     osgUtil::IntersectionVisitor _iv(_lineSegmentIntersector.get());  
    6.     cow->accept(_iv);  
    7.     _intersections=_lineSegmentIntersector->getIntersections();  
    8.     int _intersectionNumber=_intersections.size();          
    9.     if (_intersectionNumber!=0)  
    10.     {           
    11.         osgUtil::LineSegmentIntersector::Intersections::iterator hitr = _intersections.begin();  
    12.         osg::Vec3 vec3_p1 =hitr->getWorldIntersectPoint()*mt_cow->getMatrix();//这样得到的交点就是绝对的世界坐标了。  
    13.         mt_axes->setMatrix(osg::Matrix::translate(vec3_p1));//把坐标系原点移动到交点,可以测试现在的坐标系原点是不是刚好和牛相交!  
    14.         hitr++;  
    15.         osg::Vec3 vec3_p2 =hitr->getWorldIntersectPoint()*mt_cow->getMatrix();  
    16.     }  
  • 相关阅读:
    信件分析实战(五)——数据可视化
    信件分析实战(四)——数据分析以及部分可视化
    剑指offer15题
    剑指offer14题
    剑指offer11题
    剑指offer第9题
    剑指offer第8题--动态规划最简单讲解
    剑指offer第7题
    剑指offer第6题
    剑指offer第5题
  • 原文地址:https://www.cnblogs.com/coolbear/p/3012015.html
Copyright © 2011-2022 走看看