#ifdef _WIN32
#include <Windows.h>
#endif // _WIN32 #include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgViewer/CompositeViewer>
#include <osgDB/ReadFile>
#include <osg/Geode>
#include <osg/Node>
#include <osgGA/TrackballManipulator>
#include <osg/GraphicsContext>
#include <osg/ShapeDrawable>
#include <osg/Material>
#include <osg/Image>
#include <osg/Texture2D>
#include <osg/TexEnv>
#include <osg/TexGen>
#include <osg/MatrixTransform>
#include <osg/PositionAttitudeTransform>
#include <osg/AnimationPath>
#include <osg/Matrixd> #include <osgGA/GUIEventHandler>
#include <osgGA/CameraManipulator>
#include <osgGA/StandardManipulator>
#include <osgGA/OrbitManipulator>
#include <osgGA/TrackballManipulator>
#include <osgUtil/IntersectionVisitor>
#include <osgUtil/LineSegmentIntersector> //创建盒子
osg::ref_ptr<osg::Geode> createBox()
{
osg::ref_ptr<osg::Geode> geode1 = new osg::Geode;
geode1->addDrawable(new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.0,0.0,0.0),10.0,8.0,6.0)));
geode1->addDrawable(new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.0, 0.0, 0.0), 0.1, 0.1, )));
return geode1;
} int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer1 = new osgViewer::Viewer;
osg::ref_ptr<osg::Group> group1 = new osg::Group;
//osg::ref_ptr<osg::Node> node1 = osgDB::readNodeFile("D:\\参考手册\\BIM\\osg\\build1.OSGB");
//group1->addChild(node1.get()); osg::ref_ptr<osgUtil::LineSegmentIntersector> lineSegmentIntesector = new osgUtil::LineSegmentIntersector(osg::Vec3(,,),osg::Vec3(,,-));
osg::ref_ptr<osgUtil::IntersectionVisitor> intersectionVisitor1 = new osgUtil::IntersectionVisitor(lineSegmentIntesector); group1->addChild(createBox());
group1->accept(*intersectionVisitor1.get()); osgUtil::LineSegmentIntersector::Intersections intersections;
//输出交点
if (lineSegmentIntesector->containsIntersections())
{
intersections = lineSegmentIntesector->getIntersections();
osgUtil::LineSegmentIntersector::Intersections::iterator iter;
for (iter = intersections.begin(); iter != intersections.end(); ++iter)
{
std::cout << "x:"<<iter->getWorldIntersectPoint().x() << " y:" << iter->getWorldIntersectPoint().y() << " z:" << iter->getWorldIntersectPoint().z() << std::endl;
}
} viewer1->setSceneData(group1.get());
viewer1->setUpViewInWindow(, , , , ); return viewer1->run();
}

osg osgUtil::LineSegmentIntersector的更多相关文章

  1. osg实例介绍

    osg实例介绍 转自:http://blog.csdn.net/yungis/article/list/1 [原]osgmotionblur例子 该例子演示了运动模糊的效果.一下内容是转自网上的:原理 ...

  2. osg 路径 动画 效果

    osg 路径 动画 效果 转自:http://blog.csdn.net/zhuyingqingfen/article/details/8248157 #include <osg/Group&g ...

  3. osg项目经验1<MFC+OSG中模型点选效果>

    点选主要是重载osg的GUIEventHandler, class CPickHandler : public osgGA::GUIEventHandler{ //自定义回调函数名:CPickHand ...

  4. OSG选取点云坐标不准的解决办法

    一.默认的相机和所有模型求交的方式 1.1 传统的模型与屏幕点求交的方法如下: osgViewer::View* viewer = dynamic_cast<osgViewer::View*&g ...

  5. osg编译日志-release

    1>------ 已启动生成: 项目: ZERO_CHECK, 配置: Release x64 ------1> Checking Build System1> CMake does ...

  6. osg fbx模型点击节点,对应节点染色

    class CPickHandler :public osgGA::GUIEventHandler { public: CPickHandler(osgViewer::Viewer *viewer) ...

  7. osg 加载 fbx文件

    #ifdef _WIN32 #include <Windows.h> #endif // _WIN32 #include <osg/Group> #include <os ...

  8. osg 添加 fbx插件 osg中编译fbx

    使用osg加载fbx模型,需要自己编译fbx插件,编译流程与插件使用案例如下 代码地址:https://github.com/shelltdf/osgFBX CMake Error: The foll ...

  9. osg Shader 着色器

    #ifdef _WIN32 #include <Windows.h> #endif // _WIN32 #include <osg/Group> #include <os ...

随机推荐

  1. reGeorg+Proxifier使用

    reGeorg利用了socks5协议建立隧道,结合Proxifier可将目标内网代理出来. 项目地址: https://github.com/sensepost/reGeorg 该文件下支持php,a ...

  2. JVM系列一:虚拟机内存区域

    虚拟机栈 1.虚拟机栈维护一个线程中所有方法的栈帧,每个栈帧中保存着这个方法中用到的局部变量表,操作数栈,常量引用 2.可以用-Xss来设置每个线程中虚拟机栈的大小,在jdk1.4之前默认虚拟机栈大小 ...

  3. G1垃圾收集器堆内存划分与角色分派【纯理论】

    接着上一次[https://www.cnblogs.com/webor2006/p/11123522.html]G1学习继续开启理论之旅.. G1的设计规划是要替换掉CMS[理想化的] G1在某些方面 ...

  4. 文件读写(三)利用FileStream类操作字节数组byte[]、BinaryFormatter、内存流MemoryStream

    一.Stream类概述 在.NET Framework中,文件和流是有区别的.文件是存储在磁盘上的数据集,它具有名称和相应的路径.当打开一个文件并对其进行读/写时,该文件就称为流(stream).但是 ...

  5. http---返回网页(普通,多进程,多线程,协程方式实现)

    代码: import socket import re import multiprocessing import threading import gevent from gevent import ...

  6. Django REST framework+Vue 打造生鲜电商项目(笔记六)

    (部分代码来自https://www.cnblogs.com/derek1184405959/p/8836205.html) 九.个人中心功能开发 1.drf的api文档自动生成 (1) url #d ...

  7. 函数指针,使用qsort,进行结构体排序

    #include <stdio.h> #include <stdlib.h> #define STU_NAME_LEN 16 /*学生信息*/ typedef struct s ...

  8. QSlider 样式

    https://doc.qt.io/archives/qt-4.8/stylesheet-examples.html #if 0 m_sliderVoice->setStyleSheet(&qu ...

  9. input 限制输入数字和小数

    //input 限制输入数字和小数 <input type="text" name="demo" value="" onkeyup=& ...

  10. mutex,thread(c++11 windows linux三种方式)

    一 c++11  windows linux三种方式 //#include <stdio.h> //#include <stdlib.h> //#include <uni ...