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.     }  
  • 相关阅读:
    2.0 C++远征:隐藏
    1.0 C++远征:为什么继承
    15.0 C++远征:常指针和常引用
    14.0 C++远征:常对象成员和常成员函数
    13.0 C++远征:this指针
    12.0 C++远征:对象成员指针
    Sql语句
    斐波那契 递归 求某一个数
    WebAPI 和 WebService的区别
    获取用户IP
  • 原文地址:https://www.cnblogs.com/coolbear/p/3012015.html
Copyright © 2011-2022 走看看