osggeometry修改更新顶点

osg::Geometry *geometry = geode->getDrawable(0)->asGeometry();
geometry->setDataVariance(osg::Object::DYNAMIC);
// 顶点数据 osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(geometry->getVertexArray()); // 法向量 osg::Vec3Array* normals = dynamic_cast<osg::Vec3Array*>(geometry->getNormalArray()); // 颜色 osg::Vec4Array* color = dynamic_cast<osg::Vec4Array*>(geometry->getColorArray()); (*color)[0] = newColor; // 更新显示列表 geometry->dirtyDisplayList();
如果使用VBO来更新几何对象,需要使用Vec3Array::dirty()来将修改结果通知给VBO对象,这里使用
vertices->dirty();
 
原文地址:https://www.cnblogs.com/coolbear/p/10730721.html