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)); 来指定要利用这些数据生成一个怎么样的形状. ...
随机推荐
- BUUCTF复现记录2
[CISCN2019 华北赛区 Day1 Web1]Dropbox 打开题目,一个登录界面,SQL? sqlmap跑一下,没有注入,那么注册一下 登录之后,发现只有一个上传页面,源码里面也没有什么 那 ...
- python BeautifulSoup4解析网页
html = """ <html><head><title>The Dormouse's story</title>< ...
- linux网络编程之posix线程(一)
今天继续学习posix IPC相关的东东,消息队列和共享内存已经学习过,接下来学习线程相关的知识,下面开始: [注意]:创建失败这时会返回错误码,而通常函数创建失败都会返回-1,然后错误码会保存在er ...
- @EnableCircuitBreaker熔断超时机制
客户端请求服务端的时候总是报超时,默认熔断机制是1S
- celery timeout的拦截
0X01 场景 celery任务超时报错,想查看是传入哪一类数据运行时导致的超时(哪一个插件),但是该报错难以拦截. [2019-06-30 17:23:21,070: ERROR/MainProce ...
- myeclipse2018大括号之前会自动加空格
- QT5 文件读写操作
QFile Class 1.read读文件 加载文件对象 QFile file("文件地址"); 打开加载的文件file.open(打开方式); 操作文件 关闭打开的文件file ...
- TensorFlow(七):tensorboard网络执行
# MNIST数据集 手写数字 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # ...
- 在qml中使用model给委托对象MapPolylIne的path属性赋值。
遇到两个崩溃的问题. 1.A线程中给赋值了变量 listA, 线程B中使用函数Add(QList<GeoPath> &list),由于在其函数中调用了list.at(index), ...
- 数据结构实验之图论四:迷宫探索【dfs 求路径】
分析:起点已知,开个数组来存放路径,注意 vis 数组要初始化!另外,不能忘记了题目还要求回去的路径,只要在 dfs 之后加上就可以了. #include <bits/stdc++.h> ...