指定用户几何体的纹理坐标
创建纹理属性对象并保存纹理图形数据
为StateSet设置纹理属性和模式
一 纹理坐标
osg::ref_ptr<osg::Vec2Array> tc = new osg::Vec2Array;
geom->setTexCoordArray( 0, tc.get() );
tc->push_back( osg::Vec2( 0.f, 0.f ) );
tc->push_back( osg::Vec2( 1.f, 0.f ) );
tc->push_back( osg::Vec2( 1.f, 1.f ) );
tc->push_back( osg::Vec2( 0.f, 1.f ) );
geom->setTexCoordArray( 0, tc.get() ); 第一个0就是texture
二 纹理是一种StateAttribute
Texture 是一种StateAttribute
三 用image 生成纹理
texture->setImage(osg::Image)
image去加载图像文件
texture去指向图片
//state
osg::StateSet* state = node->getOrCreateStateSet;
//image
osg::ref_ptr<osg::Image> image = new osg::Image;
image->setFileName("sun.tif");
//texture
osg::ref_ptr<osg::Texturn2D> texture = new osg::Texturn2D;
texture->setImage(image);
//装入属性
state->setTextureAttribute( 0, texture.get() );
四 setTextureAttribute
state->setTextureAttribute( 0, texture.get() );
第一个0是对应的材质