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 ...
随机推荐
- C# .NET 使用第三方类库DotNetZip解压/压缩Zip rar文件
DotNetZip on CodePlex: http://dotnetzip.codeplex.com/ 详细的可以看源代码……总之感觉比SharpZipLib好用.而且DotNetZip支持VB, ...
- 使用js 在IE和火狐firfox 里动态增加select 的option
使用js 在IE和火狐firfox 里动态增加select 的option <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transition ...
- php的setcookie()函数详解
一.浏览器COOKIE原理: 浏览器在访问某个域名时会先读取本地的COOKIE文件(CHROME浏览器在C:\Users\Administrator\AppData\Local\Google\Chro ...
- IOS编程教程(八):在你的应用程序添加启动画面
IOS编程教程(八):在你的应用程序添加启动画面 虽然你可能认为你需要编写闪屏的代码,苹果已经可以非常轻松地把它做在Xcode中.不需要任何编码.你只需要做的是设置一些配置. 什么是闪屏 对于那些 ...
- 深入理解querySelector(All)
querySelector和querySelectorAll同属于Selectors API Level 1规范,该规范早在2006年就已经开始发展,并在2007年10月形成querySe ...
- Entity Framework with MySQL 学习笔记一(验证标签)
直接上代码 [Table("single_table")] public class SingleTable { [Key] public Int32 id { get; set; ...
- ural 1084 Goat in the Garden
#include <cstdio> #include <cstring> #include <cmath> #include <algorithm> u ...
- RUBY的类封装,继承,多态简单演示
class Person def initialize(name,age=18) @name=name @age=age @motherland="China" end def t ...
- Intel hex 文件格式解密
Intel hex 文件常用来保存单片机或其他处理器的目标程序代码.它保存物理程序存储区中的目标代码映象.一般的编程器都支持这种格式. Intel hex 文件全部由可打印的ASCII字符组成(可以用 ...
- HDOJ 1393 Weird Clock(明白题意就简单了)
Problem Description A weird clock marked from 0 to 59 has only a minute hand. It won't move until a ...