|
发表于 2013-5-23 19:57:00
|
显示全部楼层
本帖最后由 VR_user_happy 于 2013-5-23 20:03 编辑
自动生成,系统怎么知道你个贴图应该怎么绑定到对应的那个顶点?
参看:
osg::Geometry* pShapeGeometry = new osg::Geometry();
贴图顶点数组:
osg::Vec3Array* myShapeVertices = new osg::Vec3Array;
myShapeVertices->push_back(...
重点1:
创建顶点贴图数组(需要贴图的上面的几何体的相对应)
要一一对应(贴图几何体有几个顶点,就要设定几个对应的贴图坐标)
//vectices map coorders for 2D
osg::Vec2Array* texcoords = new osg::Vec2Array(4);
(*texcoords)[0].set(0.0f,1.0f);
(*texcoords)[1].set(1.0f,1.0f);
(*texcoords)[2].set(1.0f,0.0f);
(*texcoords)[3].set(0.0f,0.0f);
pShapeGeometry->setVertexArray(myShapeVertices);
重点2:
几何体绑定贴图坐标:
pShapeGeometry->setTexCoordArray(0,texcoords);
这种创建有贴图的几何体,教程和网上有很多例子参看! |
|