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();
相關文章
相關標籤/搜索