|
创建一个geometry对象(想画成正方形),指定四个顶点,addprimitiveset,加入纹理坐标,运行都正常,但是加入法向量后就一直卡在 doing add...那里了,不知到为什么 设定法向量会出现这样的问题?
代码:
osg::Geode * geoNode = new osg::Geode();
osg::Geometry * geometryNode = new osg::Geometry();
geoNode->addDrawable(geometryNode);
//构造几何体
//顶点数组
osg::Vec3Array * vertecArray = new osg::Vec3Array();
vertecArray->push_back(osg::Vec3(OriginX,OriginY,OriginZ));
vertecArray->push_back(osg::Vec3(OriginX+wideth,OriginY,OriginZ));
vertecArray->push_back(osg::Vec3(OriginX+wideth,OriginY,OriginZ+height));
vertecArray->push_back(osg::Vec3(OriginX,OriginY,OriginZ+height));
//指定顶点数组
geometryNode->setVertexArray(vertecArray);
//加入图形基元
geometryNode->addPrimitiveSet(new osg:rawArrays(osg:rimitiveSet:UADS,0,4));
//纹理坐标
osg::Vec2Array * tex = new osg::Vec2Array();
tex->push_back(osg::Vec2(1,0));
tex->push_back(osg::Vec2(0,0));
tex->push_back(osg::Vec2(0,1));
tex->push_back(osg::Vec2(1,1));
geometryNode->setTexCoordArray(0,tex);
//设定法向量
osg::Vec3Array * normal = new osg::Vec3Array();
normal->push_back(osg::Vec3(0,-1,0));
geometryNode->setNormalArray(normal);
geometryNode->setNormalBinding(osg::Geometry::BIND_OVERALL);
不加红色代码就会正常显示一个正方形,加上后就卡在 DOING ADD 那里了。
有没有人知道为什么呢? 谢谢啦!
|
|