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.     }  
  • 相关阅读:
    python的配置
    SSI服务端包含技术
    IDEA使用过程中常见小问题
    IDEA配置maven,jdk,编码
    不使用SwitchHosts修改C:WindowsSystem32driversetchosts文件
    webstorm打开一个门户工程流程
    安装nginx流程
    webstorm配置node.js
    Linux的inode与block
    使用vsftpd 搭建ftp服务
  • 原文地址:https://www.cnblogs.com/coolbear/p/3012015.html
Copyright © 2011-2022 走看看