#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. webuploader只选择单张图片

    webuploader只选择单张图片 一.总结 一句话总结: 在WebUploader.create中配置一下pick即可 pick: { id: '#filePicker', multiple:fa ...

  2. 设计模式之命令模式-JS

    理解命令模式 假设有一个快餐店,而我是该餐厅的点餐服务员,那么我一天的工作应该是这样的:当某位客人点餐或者打来订餐电话后,我会把他的需求都写在清单上,然后交给厨房,客人不用关心是哪些厨师帮他炒菜.我们 ...

  3. mailto标签来调用邮箱客户端

    最近项目需要使用mailto标签来调用客户端,并且把邮件模板填到客户端. mailto 的用法: a标签直接调用: <a href="mailto:example@qq.com?cc= ...

  4. 优化你的HTTPS(下),你需要这么做

    本篇文章是接着上篇文章来说,这篇介绍三种方法分别是多路复用 ,请求优先级,服务器推送. 多路复用 请求优先级 服务器推送 多路复用 在HTTP1.1中,浏览器客户端在同一时间,针对同一域名下的请求有一 ...

  5. 2019年java技术大盘点

    福州SEO:2019年互联网企业在Java开发中有哪些主流.热门的IT技术呢,下面让我们来看一下. 微服务技术 微服务架构主要有:Spring Cloud. Dubbo. Dubbox等,以 Dubb ...

  6. 为 32 位单片机设计的脚本语言 Berry

    Berry是一款一款为32位单片机设计的脚本语言.Berry解释器使用C89标准实现,该语言可以在RAM或ROM很小的设备上运行. 尽管Berry的体积很小,但是它也支持class以及闭包等功能,使得 ...

  7. HTML 009 CSS

    HTML 样式- CSS CSS (Cascading Style Sheets) 用于渲染HTML元素标签的样式.     Look! Styles and colors Manipulate Te ...

  8. 22 | MySQL有哪些“饮鸩止渴”提高性能的方法?

    不知道你在实际运维过程中有没有碰到这样的情景:业务高峰期,生产环境的MySQL压力太大,没法正常响应,需要短期内.临时性地提升一些性能. 我以前做业务护航的时候,就偶尔会碰上这种场景.用户的开发负责人 ...

  9. Laravel 6.0 Schedule Preventing Task Overlaps 测试

    1 目的 1.1 测试 Laravel 6.0 任务执行机制 2 意义 2.1 在日常开发中,有的任务比较复杂,在两次任务的调度周期间隔中无法完成. 2.2 为了防止重复任务的持续生成和反复调用,对服 ...

  10. [Luogu] 运输问题 -- 00

    https://www.luogu.org/problemnew/show/4015 #include <bits/stdc++.h> #define gc getchar() using ...