|
void createTexture2D(osg::StateSet& ss,osg::Image* image)
{
osg::StateAttribute * sa = ss.getTextureAttribute(0, osg::StateAttribute::TEXTURE);
osg::ref_ptr<osg::Texture2D> texture=new osg::Texture2D;
texture->setImage(image);
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture:INEAR);
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
texture->setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_BORDER);
texture->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_BORDER);
ss.setTextureAttributeAndModes(0,texture.get());
//ss.removeTextureAttribute(0,texture.get());
}
int main()
{
osg::ref_ptr<osg::ImageSequence> imageSquence=new osg::ImageSequence;
imageSquence->addImageFile("images/w1.png");
imageSquence->addImageFile("images/w2.png");
imageSquence->addImageFile("images/w3.png");
imageSquence->addImageFile("images/w4.png");
osg::ref_ptr<osg::Geode> geode=new osg::Geode;
geode->addDrawable(osg::createTexturedQuadGeometry(osg::Vec3(0.0,0.0,0.0),osg::Vec3(1.0,0.0,0.0),osg::Vec3(0.0,0.0,1.0),1.0,1.0));
createTexture2D(*(geode->getOrCreateStateSet()),imageSquence.get());
imageSquence->setLength(5.0);
imageSquence->setTimeMultiplier(4);
imageSquence->play();
osgViewer::Viewer viewer;
viewer.setSceneData(geode.get());
return viewer.run();
}
大神请问下,测试代码贴图展示正确,但是贴图到管线上,图片就变形了,请问各位,管线的纹理怎么实现贴图动画? |
|