OSG快速生成一个带有纹理的四边形Geometry

可以使用Geometry头文件中的

Geometry* createTexturedQuadGeometry

 

osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
osg::ref_ptr<osg::Image> image = osgDB::readImageFile( "D:/background1.png" );
texture->setImage( image.get() );

osg::ref_ptr<osg::Drawable> quad = osg::createTexturedQuadGeometry(osg::Vec3(), osg::Vec3(1.0f, 0.0f, 0.0f), osg::Vec3(0.0f, 1.0f, 0.0f) );
quad->getOrCreateStateSet()->setTextureAttributeAndModes( 0,texture.get());

osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable( quad.get() );

posted @ 2015-05-22 15:26  酷熊  阅读(1109)  评论(0编辑  收藏  举报