#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 背景图片设置的更多相关文章

  1. Android TextView背景颜色与背景图片设置

    Android TextView 背景颜色与背景图片设置,android textview 控件,android textview 背景, android textview 图片,android te ...

  2. JAVA GUI学习 - 窗体背景图片设置方法:重写paintComponent(Graphics g)方法

    public class BackgroundImage extends JFrame { public BackgroundImage() { this.setTitle("窗体背景图片设 ...

  3. css样式背景图片设置缩放

    一.背景颜色图片平铺 background-color 背景颜色 background-image 背景图片地址 background-repeat 是否平铺 默认是平铺 background-pos ...

  4. 【CSS】css网页背景图片设置

    刚学CSS,了解了下网页背景图设置,顺便记录下. 下面主要是实现背景图位置保持不变,即不随滚动条动而动的功能. body { background-image:url(images/bck.png); ...

  5. TextView字体和背景图片 设置透明度

    背景图片透明度设置  viewHolder.relative_layout.getBackground().setAlpha(225);     0  ---  225 ((TextView)tv). ...

  6. WPF Button的背景图片设置

    这个问题很简单,但是对于从winfrom转过来的来讲,在做事的时候就会被绕进去,言归正传,如何设置一个bUtton的背景图片?如何去掉让人烦的默认选中时的灰色背景?请看如下的描述.问题的来源和解决都在 ...

  7. QT:给Widget设置背景图片——设置Widget的调色板,调色板使用图片和背景色

    QT:给Widget设置背景图片 1 /*2 * set background image3 */4 QPixmap bgImages(":/images/bg.png");5 Q ...

  8. MFC 窗体背景图片设置

    很多人在做MFC 界面的时候想要给对话框加入背景图片,很多人都会想到在OnPaint()里面来加一段代码来实现,其实这样做并不怎么科学,因为它会导致窗口不断重绘,在很多项目中窗口会闪烁(比如带播放视频 ...

  9. ios UITableView背景图片设置

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPa ...

随机推荐

  1. linux网络编程之posix线程(二)

    继续接着上次的posix线程来学习: 回顾一下创建线程的函数: pthread_att_t属性变量是需要进行初始化才能够用的,一定初始化了属性变量,它就包含了线程的多种属性的值,那到底有哪些属性了,下 ...

  2. JDK源码那些事儿之PriorityBlockingQueue

    今天继续说一说阻塞队列的实现,今天的主角就是优先级阻塞队列PriorityBlockingQueue,从命名上看觉得应该是有序的,毕竟是优先级队列,那么实际上是什么情况,我们一起看下其内部实现,提前说 ...

  3. 2.4 vue配置(下)

  4. vue2 自定义过滤器

  5. go语言的内建变量类型

    string bool int int8  int16 int32 int64 uintptr   无符号int 类型  (u)int (u)int8 (u)int16 (u)int32 (u)int ...

  6. LOJ 103子串查找——用hash代替kmp算法

    题意 给出两个字符串 $s_1,s_2$,求 $s_2$ 在 $s_1$ 中出现的次数. 分析 预处理出两个字符串的哈希值,再逐位比较. 时间复杂度为 $O(n+m)$,和 $kmp$ 算法一样. 可 ...

  7. 开发第一个maven示例

    mavenDemo目录如下: 在webapp下新建index.jsp文件 浏览器访问:http://localhost:8080/mavenDemo/index.jsp

  8. post提交主订单数据(gateway)实现httpapi

    models.proto syntax = "proto3"; package services; import "google/protobuf/timestamp.p ...

  9. Java链接Redis时出现 “ERR Client sent AUTH, but no password is set”

    Java链接Redis时出现 “ERR Client sent AUTH, but no password is set” 异常的原因及解决办法. [错误提示] redis.clients.jedis ...

  10. 学到了林海峰,武沛齐讲的Day24-完 对象和实例

    学到这里估计就是坎了...日志都不想写了.. 对象和实例