#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. 【转】用 Consul 来做服务注册与服务发现

    原文:https://segmentfault.com/a/1190000018731395?utm_source=tag-newest ------------------------------- ...

  2. 《The one!》团队作业五:团队项目需求改进与系统设计

    项目 内容 作业所属课程 所属课程 作业要求 作业要求 团队名称 < The One !> 作业学习目标 (1)掌握面向对象需求分析方法:(2)学习软件系统总体结构和数据库逻辑结构设计,学 ...

  3. 安装Genymotion模拟器(第三方)

    优势: 启动速度更快 注册账户,下载可用的系统镜像,就可以使用.     官方网站: https://www.genymotion.com/account/login/ 选择的版本是带VirtualB ...

  4. 基于JS的高级脚本语言 Sara

    Sara-基于JS的高级脚本语言 欢迎使用Sara,Sara是一款基于JavaScript的全新的高级脚本语言! Sara不像我们工作室上一款编程语言作品-Ginit一样,他属于更高级的语言 Sara ...

  5. python - redis 的使用

    1.redis连接 redis提供两个类Redis和StrictRedis用于实现Redis的命令,StrictRedis用于实现大部分官方的命令,并使用官方的语法和命令,Redis是StrictRe ...

  6. BZOJ 3698: XWW的难题(有源汇上下界最大流)

    题面 XWW是个影响力很大的人,他有很多的追随者.这些追随者都想要加入XWW教成为XWW的教徒.但是这并不容易,需要通过XWW的考核. XWW给你出了这么一个难题:XWW给你一个N*N的正实数矩阵A, ...

  7. Jmeter之JDBC类型组件

    一.背景 在测试过程中,避免不了与数据库打交道,比如数据的校验.数据的准备或者重置操作,又或者对数据库进行增删改查,基于以上诉求,在Jmeter中是如何实现的呢.可使用JDBC类型组件来实现以上功能操 ...

  8. SQL:分区拾忆

    1.文件组与文件 数据库属性——可以先添加多个文件组(抽象分割) 单个文件组可以有多文件(物理上的分割),可以添加文件然后指定文件组 例如: 2.分区函数 语法: CREATE PARTITION F ...

  9. LibreOJ #6. Guess Number

    二次联通门 : LibreOJ #6. Guess Number /* LibreOJ #6. Guess Number 交互题初体验 用了二分判定 感觉不错 */ #include "in ...

  10. 7、transformation和action2

    一.transformation开发实战 1.map: 将集合中每个元素乘以2 使用map算子,将集合中的每个元素都乘以2 map算子,是对任何类型的RDD,都可以调用的,在Java中,map算子接收 ...