osg::Texture2D 贴纹理
#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* createTextHUD()
{
osg::ref_ptr<osg::Geode> geode1 = new osg::Geode;
osg::ref_ptr<osgText::Text> text1 = new osgText::Text;
osg::ref_ptr<osg::Camera> camera1 = new osg::Camera; osg::ref_ptr<osg::Geometry> geometry1 = new osg::Geometry; camera1->setViewMatrix(osg::Matrix::identity());
camera1->setRenderOrder(osg::Camera::POST_RENDER);
camera1->setClearMask(GL_DEPTH_BUFFER_BIT); camera1->setAllowEventFocus(false);
camera1->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera1->setProjectionMatrixAsOrtho2D(-, , -, ); text1->setFont("Fonts/simhei.ttf");
text1->setCharacterSize();
text1->setText(L"OSG 中文字体");
text1->setPosition(osg::Vec3(0.0,0.0,0.0)); //压入顶点
osg::Vec3Array *vecArray = new osg::Vec3Array;
vecArray->push_back(osg::Vec3(0.0,0.0,0.0));
vecArray->push_back(osg::Vec3(200.0, 0.0, 0.0));
vecArray->push_back(osg::Vec3(200.0, 100.0, 0.0));
vecArray->push_back(osg::Vec3(0.0, 100.0, 0.0));
geometry1->setVertexArray(vecArray); //法线
osg::Vec3Array *vecNorm = new osg::Vec3Array;
vecNorm->push_back(osg::Vec3(0.0,0.0,1.0));
geometry1->setNormalArray(vecNorm);
geometry1->setNormalBinding(osg::Geometry::BIND_OVERALL); //设置纹理
osg::Vec2Array *vec2Coord = new osg::Vec2Array;
vec2Coord->push_back(osg::Vec2(0.0,0.0));
vec2Coord->push_back(osg::Vec2(1.0, 0.0));
vec2Coord->push_back(osg::Vec2(1.0, 1.0));
vec2Coord->push_back(osg::Vec2(0.0, 1.0));
geometry1->setTexCoordArray(,vec2Coord); osg::DrawArrays *drawArrays1 = new osg::DrawArrays(osg::PrimitiveSet::QUADS, , );
//geometry1->setPrimitiveSet(0,drawArrays1);
geometry1->addPrimitiveSet(drawArrays1); //贴纹理
osg::ref_ptr<osg::Image> image1 = osgDB::readImageFile("D:\\image_1\\20190325092002-save.jpg");
osg::Texture2D *texture2d1 = new osg::Texture2D;
texture2d1->setImage(image1);
geometry1->getOrCreateStateSet()->setTextureAttributeAndModes(, texture2d1, osg::StateAttribute::ON);
//关闭灯光
geometry1->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); geode1->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
geode1->addDrawable(geometry1);
geode1->addDrawable(text1); camera1->addChild(geode1.get());
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");
osg::ref_ptr<osg::Node> node2 = osgDB::readNodeFile("D:\\参考手册\\BIM\\osg\\build1.osgb"); group1->addChild(node2.get());
group1->addChild(createTextHUD()); viewer1->setSceneData(group1.get());
viewer1->setUpViewInWindow(,,,,); viewer1->run();
}


osg::Texture2D 贴纹理的更多相关文章
- osg gdal加载tif数据文件
osg加载.tif地形数据文件 #ifdef _WIN32 #include <Windows.h> #endif // _WIN32 #include <iostream> ...
- osg模型部分节点旋转
osg::ref_ptr<osg::Geode> CreateBox() { osg::ref_ptr<osg::Geode> geode = new osg::Geode; ...
- osg添加纹理示例
转自http://www.cnblogs.com/ylwn817/articles/1976851.html #include <osgDB/ReadFile>#include <o ...
- osg使用shader动态修改纹理坐标
#include <osg/Node> #include <osg/Geometry> #include <osg/Notify> #include <osg ...
- OSG学习:计算纹理坐标
在很多时候,直接指定纹理坐标是非常不方便的,如曲面纹理坐标,只有少数的曲面(如圆锥.圆柱等)可以在不产生扭曲的情况下映射到平面上,其他的曲面在映射到表面时都会产生一定程度的扭曲.一般而言,曲面表面的曲 ...
- OSG绘制金字塔geode+动态纹理坐标
osg::Node* createPyramidModel() { // create the root node which will hold the model. osg::Group* roo ...
- 基于osg的python三维程序开发(三)------几何形体及纹理
def createScene(): geode = osg.Geode() pointsGeom = osg.Geometry() vertices = osg.Vec3Array() vertic ...
- osg纯手工画球+贴纹理
手动计算球面顶点的坐标,纹理坐标,来画球并贴纹理 其中createSphereGeom()函数的的二个参数为18,意思是在经纬度上每10度设一个点,因为经度一共是180度,180/18=10,相当于横 ...
- OSG快速生成一个带有纹理的四边形Geometry
可以使用Geometry头文件中的 Geometry* createTexturedQuadGeometry osg::ref_ptr<osg::Texture2D> texture = ...
随机推荐
- 关于MQ的几件小事(二)如何保证消息队列的高可用
1.RabbitMQ的高可用 RabbitMQ基于主从模式实现高可用.RabbitMQ有三种模式:单机模式,普通集群模式,镜像集群模式. (1)单机模式: 单机模式就是demo级别的,生产中不会有人使 ...
- 重新编程Hexiwear Docking Station扩展坞
Hexiwear扩展坞(Docking Station)有一个很不错的功能:它板载了一个调试电路(OpenSDA). 这样我就不需要一个外部调试器来调试Hexiwear. 但是,重新编程扩展坞自身需要 ...
- VS Code Monokai Pro验证
最新的VS Code Monokai Pro激活方式 需要vscode,并且安装了monokai pro插件 进入目录 Mac OS cd -/.vscode/extensions/monokai.t ...
- maya 在 pymel 中运行 mel
maya 在 pymel 中运行 mel 前言 maya mel 自身定义了很多有用的方法,当我们用 pymel 开发的时候,不想重新写一遍 mel 已经有的功能,那么就可以在 pymel 中运行 m ...
- SVG的几个标签元素
defs svg允许我们定义以后需要重复使用的图形元素.建议把所有需要再次使用的元素定义在defs元素里面.这样做可以增加svg内容的易读性和可访问性.在defs元素定义的元素不会直接呈现.你可以在你 ...
- python 'NoneType' object has no attribute 'get'
获取 页面链接的时候报错 'NoneType' object has no attribute 'get' href = div.find("a").get("href& ...
- 网络编程 --- subprocess模块,struct模块,粘包,UDP协议,socket_server模块
目录 subprocess模块 struct模块 粘包 UDP协议 socket_server模块 subprocess模块 作用: 1.可以帮你通过代码执行操作系统的终端命令 2.并返回终端执行命令 ...
- BZOJ 1181: [CROATIAN2009] IZBROI选举(二分+dp)
题面 在一个地区的选举中,共有V个人参加了投票,每一票只可能投给N个政党中的一个.当地的议会共有M个席位.不妨将N个政党编号为1到N,并且设编号为i的政党最终的得票为Vi,则议会中的席位按如下规则分配 ...
- Java图形界面
图形界面 JFrame在swingbao JFrame jframe = new JFrame(); iframe.setVisible(true); //设置窗口显示 jframe.setLocat ...
- SQL数据库调优
1.使用With As做数据库递归,调优树形表结构 例如:设计表结构简化如:ID.ParentID.Name:这里的ParentID就是这个表本身的某个ID WITH cte AS ( UNION A ...