生成Geometry
生活随笔
收集整理的這篇文章主要介紹了
生成Geometry
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
// 由一組點集生成一張三角面片網(wǎng)格Geometryosg::Geometry* createTRIANGLESGeometry(MyMesh &mesh){osg::ref_ptr< osg::Geometry > triGeom = new osg::Geometry();// 頂點坐標(biāo)數(shù)組int vertexNum=mesh.vertex.size();osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array();triGeom->setVertexArray(vertices);// 顏色數(shù)組osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array;colors->push_back(osg::Vec4(0.0f,1.0f,0.0f,1.0f));triGeom->setColorArray(colors);triGeom->setColorBinding(osg::Geometry::BIND_OVERALL);// 法向量數(shù)組int normalNum=mesh.normal.size();osg::ref_ptr<osg::Vec3Array> normals = new osg::Vec3Array();triGeom->setNormalArray(normals);triGeom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);// 一個頂點對應(yīng)一個法向量
triGeom->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES,mesh.triangleNum*3,// 索引個數(shù)(unsigned short*)&mesh.index.at( 0 )));return triGeom.release();}
?
轉(zhuǎn)載于:https://www.cnblogs.com/coolbear/p/4587754.html
總結(jié)
以上是生活随笔為你收集整理的生成Geometry的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 找1的个数
- 下一篇: 《人件集 人性化的软件开发》阅读笔记01