osg HUD 前景色
#ifdef _WIN32
#include <Windows.h>
#endif // _WIN32
#include<iostream> #include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgViewer/CompositeViewer> #include <osgDB/ReadFile> #include <osg/Geode>
#include <osg/Node>
#include <osg/Geometry>
#include <osg/GraphicsContext>
#include <osg/ShapeDrawable>
#include <osg/Material>
#include <osg/Image>
#include <osg/Texture2D>
#include <osg/TexEnv>
#include <osg/TexGen>
#include <osg/NodeVisitor>
#include <osg/MatrixTransform>
#include <osg/PositionAttitudeTransform>
#include <osg/AnimationPath>
#include <osg/Matrixd>
#include <osg/PagedLOD>
#include <osg/Camera>
#include <osgText/Text> #include <osgGA/TrackballManipulator>
#include <osgGA/GUIEventHandler>
#include <osgGA/CameraManipulator>
#include <osgGA/StandardManipulator>
#include <osgGA/OrbitManipulator>
#include <osgGA/TrackballManipulator> #include <osgUtil/IntersectionVisitor>
#include <osgUtil/LineSegmentIntersector> osg::Camera* createFrontground(std::string strImg)
{
osg::ref_ptr<osg::Geode> geode1 = new osg::Geode;
osg::ref_ptr<osg::Geometry> geometry1 = new osg::Geometry;
osg::ref_ptr<osg::Camera> camera1 = new osg::Camera; camera1->setAllowEventFocus(false);
camera1->setProjectionMatrixAsOrtho2D(, , , );
camera1->setViewport(, , , ); camera1->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera1->setRenderOrder(osg::Camera::POST_RENDER);
camera1->setClearMask(GL_DEPTH_BUFFER_BIT);
//camera1->setClearColor(osg::Vec4());
camera1->setViewMatrix(osg::Matrix::identity()); //压入顶点
osg::ref_ptr<osg::Vec3Array> vertex = new osg::Vec3Array;
vertex->push_back(osg::Vec3(0.0, 0.0, 0.0));
vertex->push_back(osg::Vec3(960.0, 0.0, 0.0));
vertex->push_back(osg::Vec3(960.0, 600.0, 0.0));
vertex->push_back(osg::Vec3(0.0, 600.0, 0.0));
geometry1->setVertexArray(vertex); //压入法线
osg::ref_ptr<osg::Vec3Array> norml = new osg::Vec3Array;
norml->push_back(osg::Vec3(0.0, 0.0, 1.0));
geometry1->setNormalArray(norml);
geometry1->setNormalBinding(osg::Geometry::BIND_OVERALL); //纹理坐标
osg::ref_ptr<osg::Vec2Array> coord = new osg::Vec2Array;
coord->push_back(osg::Vec2(0.0, 0.0));
coord->push_back(osg::Vec2(1.0, 0.0));
coord->push_back(osg::Vec2(1.0, 1.0));
coord->push_back(osg::Vec2(0.0, 1.0));
geometry1->setTexCoordArray(, coord);
geometry1->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, , )); osg::ref_ptr<osg::Image> img1 = osgDB::readImageFile(strImg);
if (!img1.valid())
{
std::cout << "" << std::endl;
} osg::ref_ptr<osg::Texture2D> texture2d = new osg::Texture2D;
texture2d->setImage(, img1);
geometry1->getOrCreateStateSet()->setTextureAttributeAndModes(, texture2d, osg::StateAttribute::ON);
geometry1->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON); camera1->addChild(geode1);
geode1->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
geode1->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
geode1->addDrawable(geometry1); return camera1.release();
} 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\\build20190628.osgb"); //group1->addChild(createBackground("D:\\参考手册\\images\\104.jpg"));
group1->addChild(createFrontground("D:\\参考手册\\images\\106.png"));
group1->addChild(node1.get()); //viewer1->getCamera()->setClearMask(GL_DEPTH_BUFFER_BIT);
viewer1->setSceneData(group1.get());
viewer1->setUpViewInWindow(, , , , ); return viewer1->run();
}
osg HUD 前景色的更多相关文章
- osg HUD 背景图片设置
#ifdef _WIN32 #include <Windows.h> #endif // _WIN32 #include<iostream> #include <osgV ...
- OSG中的HUD
OSG中的HUD 所谓HUD节点,说白了就是无论三维场景中的内容怎么改变,它都能在屏幕上固定位置显示的节点. 实现要点: 关闭光照,不受场景光照影响,所有内容以同一亮度显示 关闭深度测试 调整渲染顺序 ...
- OSG的HUD抬头文字显示
原文:http://blog.csdn.net/tmljs1988/article/details/7562926 可以运行 1. HUD流程图: 完整源代码如下: /*OSG中的HUD, ...
- [OSG]OpenSceneGraph FAQ 以及OSG资源
1.地球背面的一个点,计算它在屏幕上的坐标,能得到吗? 不是被挡住了吗? 答:计算一个空间点的屏幕坐标,使用osgAPEx::GetScreenPosition函数.当空间点处于相机视空间内(不管它是 ...
- osg实例介绍
osg实例介绍 转自:http://blog.csdn.net/yungis/article/list/1 [原]osgmotionblur例子 该例子演示了运动模糊的效果.一下内容是转自网上的:原理 ...
- OSG开发概览
1 OSG基础知识 Ø OSG是Open Scene Graphic 的缩写,OSG于1997年诞生于以为滑翔机爱好者之手,Don burns 为了对滑翔机的飞行进行模拟,对openGL的库进行了封 ...
- iOS之UI--指示器HUD的创建和设置
指示器的创建和设置 渐变动画 描述: 使用label就能制作指示器,原理:就是让label以动画的形式慢慢显示和消失 最好是半透明的 指示器有时候也被称为:HUD,遮盖,蒙版 思路步骤: 1.先在st ...
- OSG开发概览(转载)
OSG开发概览 1 OSG基础知识 Ø OSG是Open Scene Graphic 的缩写,OSG于1997年诞生于以为滑翔机爱好者之手,Don burns 为了对滑翔机的飞行进行模拟,对open ...
- OSG开源教程(转)
例:geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4)); 来指定要利用这些数据生成一个怎么样的形状. ...
随机推荐
- Dotnet站点多个路由对应同一个Action的总结
需求:有些浏览器会屏蔽带有Ad字样的路径,此时需要创建多个路由指向同一个Action. 例如:原来 : http://lalalalalala.org:1506/api/advert/common ...
- linux网络编程之posix信号量与互斥锁
继上次学习了posix线程之后,这次来讨论一下posix信号量与互斥锁相关的知识: 跟posix消息队列,共享内存的打开,关闭,删除操作一样,不过,上面的函数是对有名信号量进行操作,通过man帮助可以 ...
- MyBatis3-topic04,05 -接口式编程
笔记要点 /**接口式编程: * 1. 原生: Dao 接口-->Dao接口的实现类 * mybatis: Mapper --> 有一个与之对应的 XXMapper.xml * 2. Sq ...
- P1880 [NOI1995]石子合并[环形DP]
题目来源:洛谷 题目描述 在一个圆形操场的四周摆放N堆石子,现要将石子有次序地合并成一堆.规定每次只能选相邻的2堆合并成新的一堆,并将新的一堆的石子数,记为该次合并的得分. 试设计出1个算法,计算出将 ...
- python - super 寻找继承关系
""" super 是根据当前类对象的 mro 的继承顺序进行函数的调用的 """ class Base(object): def fn(s ...
- Jmeter之JSON Extractor
SON Extractor的作用: 对于处理json格式的response,使用SON Extractor来提取数据是更方便的. SON Extractor语法: 同时提取多个数据: Names o ...
- LeetCode 282. Expression Add Operators
原题链接在这里:https://leetcode.com/problems/expression-add-operators/ 题目: Given a string that contains onl ...
- HTML 003 元素
HTML 元素 HTML 文档由 HTML 元素定义. HTML 元素 开始标签 * 元素内容 结束标签 * <p> 这是一个段落 </p> <a href=" ...
- sql server 的触发器的demo例子
-- ============================================= -- Author: <Author,,Name> -- Create date: < ...
- Vin2008 X64安装.Net Framework1.1
http://www.iis.net/learn/install/installing-iis-7/how-to-install-aspnet-11-with-iis-on-vista-and- ...