osg添加纹理示例
转自http://www.cnblogs.com/ylwn817/articles/1976851.html
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osg/Node>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Group>
#include <osg/Texture2D>
#include <osg/TexGen>
#include <osg/TexEnv>
void main()
{
osgViewer::Viewer viewer;
osg::ref_ptr<osg::Group> root=new osg::Group();
osg::ref_ptr<osg::Node> node=osgDB::readNodeFile("cow.osg");
osg::ref_ptr<osg::Image> image=osgDB::readImageFile("Images\\Primitives.gif");
if (image.get())
{
osg::ref_ptr<osg::Texture2D> texture=new osg::Texture2D();
texture->setImage(image.get());
//设置自动生成纹理坐标
osg::ref_ptr<osg::TexGen> texgen=new osg::TexGen();
texgen->setMode(osg::TexGen::SPHERE_MAP);
//设置纹理环境,模式为BLEND
osg::ref_ptr<osg::TexEnv> texenv=new osg::TexEnv;
texenv->setMode(osg::TexEnv::Mode::ADD);
texenv->setColor(osg::Vec4(0.6,0.6,0.6,0.0));
//启动单元一自动生成纹理坐标,并使用纹理
osg::ref_ptr<osg::StateSet> state=new osg::StateSet;
state->setTextureAttributeAndModes(1,texture.get(),osg::StateAttribute::ON);
state->setTextureAttributeAndModes(1,texgen.get(),osg::StateAttribute::ON);
state->setTextureAttribute(1,texenv.get());
node->setStateSet(state.get());
}
root->addChild(node.get());
viewer.setSceneData(root.get());
viewer.realize();
viewer.run();
}
osg添加纹理示例的更多相关文章
- OSG中的示例程序简介
OSG中的示例程序简介 转自:http://www.cnblogs.com/indif/archive/2011/05/13/2045136.html 1.example_osganimate一)演示 ...
- OSG中的示例程序简介(转)
OSG中的示例程序简介 1.example_osganimate一)演示了路径动画的使用 (AnimationPath.AnimationPathCallback),路径动画回调可以作用在Camera ...
- Oracle 添加 scott 示例用户
学习SQL有一段时间了,但是也忘记的差不多了,今天有赶紧复习复习,然后发现一个问题,为啥之前看的视频教程,马士兵用的Oracle有scott用户和那些表格,而我的没有?难道是Oracle取消了?然后百 ...
- cocos2d-x 添加纹理自动回收机制
转自:http://www.cnblogs.com/lancidie/archive/2013/04/13/3019375.html 1.不是一个完整的模块,所以不提供完整代码,只提供思路和核心代码. ...
- osg蝴蝶纹理
#include <osgViewer/Viewer> #include <osgDB/WriteFile> #include <osg/StateSet> #in ...
- cocos2dx JS 图片精灵添加纹理缓存
添加精灵图片缓存 : cc.spriteFrameCache.addSpriteFrames("res/pic.plist"); 从缓存中获取 : var frame = cc.s ...
- pc端 添加购物车示例
添加到购物车列表及相关商品推荐. <!DOCTYPE html> <html lang="en"> <head> <meta charse ...
- OSG添加回调更新
class CB : public osg::NodeCallback { virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) ...
- Linux系统调用接口添加简单示例
1. Linux体系结构 Linux系统的地址空间分为用户空间和内核空间,通过系统调用和硬件中断能够完成从用户空间到内核空间的转移. 2. 系统调用接口 ① 一般情况下,用户进程不能访问内核空间.Li ...
随机推荐
- memcache memcached 区别
.目前大多数php环境里使用的都是不带d的memcache版本,这个版本出的比较早,是一个原生版本,完全在php框架内开发的.与之对应的带d的memcached是建立在libmemcached的基础上 ...
- 大整数算法[10] Comba乘法(实现)
★ 引子 上一篇文章讲了 Comba 乘法的原理,这次来讲讲如何实现.为了方便移植和充分发挥不同平台下的性能,暂时用了三种不同的实现方式: 1.单双精度变量都有的情况. 2.只有单精度变量的情况. 3 ...
- C语言编程的进制问题问题
在我们的编译器,我用的是ADS 开发平台,现在RTC模块编程时,2410作为上位机,如下代码: n = rBCDDATE;if(n==1) time->day =0x31 ; 波斯历的日期与 ...
- HBase笔记--自定义filter
自定义filter需要继承的类:FilterBase 类里面的方法调用顺序 方法名 作用 1 boolean filterRowKey(Cell cell) 根据row key过滤row.如果需要 ...
- vm安装不上vmtools
vm的一些仿真机的配置项 isolation.tools.getPtrLocation.disable = “TRUE”isolation.tools.setPtrLocation.disable = ...
- C#的Reflection总结
什么是反射 在.NET中的反射也可以实现从对象的外部来了解对象(或程序集)内部结构的功能,哪怕你不知道这个对象(或程序集)是个什么东西,另外.NET中的反射还可以运态创建出对象并执行它其中的方法. 反 ...
- 2016.08.13/2/index/_d_Lucene54_0.dvm: Too many open files
er[file_system_exception: /elk/elasticsearch/data/es_cluster/nodes/0/indices/logstash-zjzc-frontend- ...
- buffer busy wait
什么是buffer busy wait? A session that reads or modifies a buffer in the SGA must first acquire the cac ...
- 在JavaScript函数式编程里使用Map和Reduce方法
所有人都谈论道workflows支持ECMAScript6里出现的令人吃惊的新特性,因此我们很容易忘掉ECMAScript5带给我们一些很棒的工具方法来支持在JavaScript里进行函数编程,这些工 ...
- jquery next nextAll nextUntil siblings的区别
next:紧挨着$('')的一个元素 nextAll:在$('')以后的所有的同辈元素 nextUntil:until有直到...之前的意思,所以他表示$('')以后的所有的同辈元素,不过要在next ...