|
以前解决了这个问题,但是现在忘了当初怎么解决的,希望大家指点。
绘制出来的矩形的形状如图:
我的代码如下:
osg::ref_ptr<osg::Geode> geode=new osg::Geode();
osg::ref_ptr<osg::Geometry> geom=new osg::Geometry();
osg::ref_ptr<osg::Vec3Array> v=new osg::Vec3Array();
v->push_back(osg::Vec3(0.0f,0.0f,0.0f));
v->push_back(osg::Vec3(1.0f,0.0f,0.0f));
v->push_back(osg::Vec3(1.0f,0.0f,1.0f));
v->push_back(osg::Vec3(0.0f,0.0f,1.0f));//设置矩形的4个点
geom->setVertexArray(v.get());
osg::ref_ptr<osg::Vec2Array> vt=new osg::Vec2Array();
vt->push_back(osg::Vec2(0.0f,0.0f));
vt->push_back(osg::Vec2(1.0f,0.0f));
vt->push_back(osg::Vec2(1.0f,1.0f));
vt->push_back(osg::Vec2(0.0f,1.0f));
geom->setTexCoordArray(0,vt.get());//设置文理坐标
osg::ref_ptr<osg::Vec3Array> nc=new osg::Vec3Array();
nc->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);//设置法线
geom->addPrimitiveSet(new osg:rawArrays(osg:rimitiveSet:UAD_STRIP,0,4));
geode->addDrawable(geom.get());
然后加到Group中然后显示。
请问各位大大,我这个代码到底是哪有问题呢?我看蛮多资料上都是这样画矩形的啊~~
|
|