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 ...
随机推荐
- Eclipse修改项目jdk版本
修改项目jdk版本(@Override的解决方法) (1)Eclipse的Window-Preferences->Java->Compiler(2)Eclipse的Project-> ...
- React组件的定义、渲染和传值总结
一.组件的定义 1.使用JavaScript函数定义 Welcome.js import React from 'react'; function Welcome() { return ( <d ...
- 集成百度编辑器 ueditor 后端配置项没有正常加载,上传插件不能正常使用!
项目要用到编辑器,于是集成了ueditor,集成ok,但一直显示 ‘’后端配置项没有正常加载,上传插件不能正常使用!‘’ 各种查: 网上说的无非就是那么集中情况 1. 因为百度官方的问题,php/co ...
- h5格式化微信 nickname 保留第一个字,其余用*显示
截取微信nickname中需要注意的是,表情符号和特殊字符,如果你不用正则过滤掉的话,使用slice(0,1)直接截取第一个字符串是不行的,因为表情符号占用两个字节,截取一半,ios会报错,andro ...
- Solr添加paoding分词器
1.Solr3.6.2 并可运行 paoding-analysis3.0.jar 下载 2.1 解压{$Solr-Path}/example/webapp 下的solr.war文件,解压到当前文件夹 ...
- Spring第二次案例和AOP
Spring加上AOP com.mapper.entity.UserInfo package com.Spring.entity; public class UserInfo { private In ...
- [AGC028B]Removing Blocks 概率与期望
考虑算每一个位置在所有情况的期望值乘以全排列似乎就是答案. 那么对于 $i$,如果要由 $j$ 来贡献的话就要满足 $j$ 在 $i....j-1$ 之前先拿. 而在拿 $j$ 时,先于 $i...j ...
- ElasticSearch数据导入By Postman
样例数据 为了更好的使用和理解ES,没有点样例数据还是不好模拟的.这里提供了一份官网上的数据,accounts.json.如果需要的话,也可以去这个网址玩玩,它可以帮助你自定义写随机的JSON数据. ...
- 爬虫(六):Selenium库使用
一:Selenium简介 selenium 是一套完整的web应用程序测试系统,包含了测试的录制(selenium IDE),编写及运行(Selenium Remote Control)和测试的并行处 ...
- linux系列(八):cp命令
1.命令格式: cp [选项]... [-T] 源 目的 2.命令功能: 将源文件复制至目标文件,或将多个源文件复制至目标目录. 3.命令参数: -a:此参数的效果和同时指定"-dpR&qu ...