|
- void DrawPoint( osg::ref_ptr<osg::Vec3Array> ptArray, double radius, osg::ref_ptr<osg::Vec4Array> color )
- {
- osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
- osg::ref_ptr <osg::Point> pointSize = new osg::Point;
- pointSize->setSize(radius);
- geom->getOrCreateStateSet()->setAttributeAndModes(pointSize.get (),osg::StateAttribute::ON);
- geom->setVertexArray( ptArray.get() );
- geom->setColorArray( color.get() );
- geom->setColorBinding( osg::Geometry::BIND_OVERALL );
- //定义法线
- osg::ref_ptr<osg::Vec3Array> n = new osg::Vec3Array;
- geom->setNormalArray( n.get() );
- geom->setNormalBinding( osg::Geometry::BIND_OVERALL );
- n->push_back( osg::Vec3( 0.0f, 0.0f, 1.0f ) );
- //设置顶点关联方式
- geom->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::POINTS, 0, ptArray->size() ) );
- osg::ref_ptr<osg::Geode> geode = new osg::Geode;
- geode->addDrawable( geom.get() );
- mRoot->addChild( geode.get() );
- }
复制代码
画出来的点显示的时候有个问题,那就是相机移动的时候点的大小并不随着视野的远近变化,是不是点的显示只和屏幕上的像素大小有关?多谢版主大大给点指点!
画的线也有类似的现象。 |
|