|
本帖最后由 Bean 于 2015-9-26 11:31 编辑
如题,怎样绘制一点,只绘制一个点还有设置其属性
这是我代码,大家看看有问题吗
- osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array();
- osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
- // osg::ref_ptr <osg::Point> point = new osg::Point(10.0);
- // LineSize ->setWidth (4.0) ;
- v->push_back(v1);
- //geom->getOrCreateStateSet()->setAttributeAndModes(LineSize.get (),osg::StateAttribute::ON);
- osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
- osg::ref_ptr<osg::Point> point = new osg::Point;
- point->setSize(25.0f);
- stateset->setAttribute(point);
- geom->setStateSet(stateset);
- geom->setVertexArray( v.get() );
- osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array;
- geom->setColorArray( c.get() );
- geom->setColorBinding(osg::Geometry::BIND_OVERALL);
- c->push_back(osg::Vec4( 1.0f, 0.0f, 0.0f, 0.3f ));
- 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.1,0.1,0.9));
- //设置顶点关联方式
- geom->addPrimitiveSet(
- new osg::DrawArrays( osg::PrimitiveSet::POINTS,0,v->size() ) );
- //几何组结点
- osg::ref_ptr<osg::Geode> geode = new osg::Geode;
- geode->addDrawable( geom.get() );
- geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF);
- geode->setName("Point");
- RootNode->addChild(geode);
复制代码 |
|