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* createBackground(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::PRE_RENDER);
camera1->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_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); camera1->addChild(geode1);
geode1->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
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(node1.get()); viewer1->getCamera()->setClearMask(GL_DEPTH_BUFFER_BIT);
viewer1->setSceneData(group1.get());
viewer1->setUpViewInWindow(, , , , ); return viewer1->run();
}
osg HUD 背景图片设置的更多相关文章
- Android TextView背景颜色与背景图片设置
Android TextView 背景颜色与背景图片设置,android textview 控件,android textview 背景, android textview 图片,android te ...
- JAVA GUI学习 - 窗体背景图片设置方法:重写paintComponent(Graphics g)方法
public class BackgroundImage extends JFrame { public BackgroundImage() { this.setTitle("窗体背景图片设 ...
- css样式背景图片设置缩放
一.背景颜色图片平铺 background-color 背景颜色 background-image 背景图片地址 background-repeat 是否平铺 默认是平铺 background-pos ...
- 【CSS】css网页背景图片设置
刚学CSS,了解了下网页背景图设置,顺便记录下. 下面主要是实现背景图位置保持不变,即不随滚动条动而动的功能. body { background-image:url(images/bck.png); ...
- TextView字体和背景图片 设置透明度
背景图片透明度设置 viewHolder.relative_layout.getBackground().setAlpha(225); 0 --- 225 ((TextView)tv). ...
- WPF Button的背景图片设置
这个问题很简单,但是对于从winfrom转过来的来讲,在做事的时候就会被绕进去,言归正传,如何设置一个bUtton的背景图片?如何去掉让人烦的默认选中时的灰色背景?请看如下的描述.问题的来源和解决都在 ...
- QT:给Widget设置背景图片——设置Widget的调色板,调色板使用图片和背景色
QT:给Widget设置背景图片 1 /*2 * set background image3 */4 QPixmap bgImages(":/images/bg.png");5 Q ...
- MFC 窗体背景图片设置
很多人在做MFC 界面的时候想要给对话框加入背景图片,很多人都会想到在OnPaint()里面来加一段代码来实现,其实这样做并不怎么科学,因为它会导致窗口不断重绘,在很多项目中窗口会闪烁(比如带播放视频 ...
- ios UITableView背景图片设置
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPa ...
随机推荐
- 【python】使用openpyxl解析json并写入excel(xlsx)
目标: 将json文本解析并存储到excel中 使用python包 openpyx import simplejsonmport codecsimport openpyxl import os # d ...
- 瞎扯KMP
瞎扯\(KMP\) 众所周知,\(KMP\)是一种玄学的字符串模式匹配算法. 什么是字符串模式匹配? 通俗的讲,就是统计一个字符串(通常很长)中某个子串(即一段连续的字符)出现的次数或位置.一般来说, ...
- jQuery toast 淡入淡出提示
#toast{ position: fixed; top: 44%;left:50%;transform: translateX(-50%); min-width: 80px; max-width: ...
- js对iframe内外(父子)页面进行操作
dom对象推荐阅读 怎么对iframe进行操作,1.在iframe里面控制iframe外面的js代码.2.在父框架对子iframe进行操作. 获取iframe里的内容 主要的两个API就是conten ...
- STM32 HAL库 UART 串口读写功能笔记
https://www.cnblogs.com/Mysterious/p/4804188.html STM32L0 HAL库 UART 串口读写功能 串口发送功能: uint8_t TxData[10 ...
- python - redis 的使用
1.redis连接 redis提供两个类Redis和StrictRedis用于实现Redis的命令,StrictRedis用于实现大部分官方的命令,并使用官方的语法和命令,Redis是StrictRe ...
- react图片预览插件尝试
npm install react-zmage -S https://blog.csdn.net/Wcharles666/article/details/90262525 启动报错 直接执行 npm ...
- 2019 ICPC Asia Yinchuan Regional
目录 Contest Info Solutions A. Girls Band Party B. So Easy D. Easy Problem E. XOR Tree F. Function! G. ...
- Myeclipse10 安装 破解 激活(含安装包,激活软件 免费)
参考博客: https://www.cnblogs.com/gzhnan/articles/9536275.html 注意 安装完成之后一定不要点 Launch Myeclipse 下载地址: htt ...
- Fluent 时间步长【转载】
转载自:http://blog.sina.com.cn/s/blog_4ada3be301011rjp.html 用FLUENT计算非稳态问题,是不是在计算时必须保证在每个时间步timestep里都要 ...