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 ...
随机推荐
- 生产环境搭建MySQL复制的教程(转)
[导读] 网络上有很多关于MySQL复制搭建的步骤和范例,以及手册上有一章完整的篇幅,讲述MySQL复制的原理.搭建步骤.优化等,但依然存在很多刚开始学习MySQL知识或者刚进入DBA行业的朋友咨询, ...
- uva 10036 Problem C: Divisibility
题意:能否在一个整数序列的每相邻的两项之间添加一个加减号,使得最终结果能被一个给定整数K<=100整除. dp[i][j]表示第i个数取余k为j的布尔值. #include <cstdio ...
- ASP.NET MVC – 关于Action返回结果类型的事儿(上)
原文:ASP.NET MVC – 关于Action返回结果类型的事儿(上) 本文转自:博客园-文超的技术博客 一. ASP.NET MVC 1.0 Result 几何? Action的 ...
- SPOJ 0962 Intergalactic Map
题目大意:在一个无向图中,一个人要从A点赶往B点,之后再赶往C点,且要求中途不能多次经过同一个点.问是否存在这样的路线.(3 <= N <= 30011, 1 <= M <= ...
- 【转】listView中,checkBox的显示和隐藏
原文网址:http://www.cnblogs.com/vicma/p/3460500.html 在listView中,每个item都有一个ChexBox,当显示的时候在listView外面设置一个按 ...
- 2015.9.11模拟赛 codevs 4160【会玩的】
题目描述 Description hzwer真的很会玩啊…他有一个n*m的方格,每次可以给方格添加一整行或一整列,但是不能删除.现在他想要让总格子数超过k个,但是又想让总格子数尽可能小.请找出这时的n ...
- [LeetCode] 230. Kth Smallest Element in a BST 解题思路
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Not ...
- CF-599B - Spongebob and Joke
B. Spongebob and Joke time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Maven Installation
OS:Ubuntu 14.04 Extract the distribution archive, i.e. apache-maven-3.2.2-bin.tar.gz to the director ...
- enable ide
http://pve.proxmox.com/wiki/Migration_of_servers_to_Proxmox_VE The vmware system consists of two dis ...