|
发表于 2008-6-13 00:45:01
|
显示全部楼层
- class VertexExtractor : public osg::NodeVisitor
- {
- public:
- osg::ref_ptr<osg::Vec3Array> extracted_verts;
- VertexExtractor() : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
- {
- extracted_verts = new osg::Vec3Array;
- }
- void apply( osg::Geode& geode )
- {
-
- for( unsigned int i=0; i < geode.getNumDrawables(); ++i )
- {
- osg::Geometry* geom = dynamic_cast<osg::Geometry*>( geode.getDrawable(i) );
- if( !geom )
- continue;
- osg::Vec3Array* verts = dynamic_cast<osg::Vec3Array*>( geom->getVertexArray() );
- if( !verts )
- continue;
- extracted_verts->insert( extracted_verts->end(), verts->begin(), verts->end() );
- }
- }
- };
复制代码
上面的代码就可以得到顶点~~~~~改变之后重新绘制就可以了~~~~~
|
|