|
楼主 |
发表于 2014-7-28 14:37:14
|
显示全部楼层
本帖最后由 guangzhang 于 2014-7-28 14:47 编辑
但是设置为GL_POINTS无法绘制出单个顶点,至少要两个点,而且不能在同一位置,你可以试试
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
osg::ref_ptr<osg::Group> root = new osg::Group;
// 创建单个点
osg::Vec3Array* pCoords = new osg::Vec3Array; // 顶点数组
pCoords->push_back(osg::Vec3(1.0,1.0,1.0));
pCoords->push_back(osg::Vec3(0.0,1.0,1.0));
osg::Vec4Array* pColors = new osg::Vec4Array; // 颜色数组
pColors->push_back(osg::Vec4(1.0,1.0,1.0,1.0));
pColors->push_back(osg::Vec4(1.0,1.0,1.0,1.0));
osg::ref_ptr<osg::Geometry> pGeometry = new osg::Geometry;
pGeometry->setVertexArray(pCoords);
pGeometry->setColorArray(pColors);
pGeometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX); // 颜色绑定
pGeometry->addPrimitiveSet(new osg:rawArrays(osg:rimitiveSet::POINTS,0,pCoords->size()));
pGeometry->getOrCreateStateSet()->setAttribute(new osg::Point(5.0));
osg::ref_ptr<osg::Geode> pGeode = new osg::Geode;
pGeode->addDrawable(pGeometry.get());
root->addChild(pGeode.get());
osgUtil::Optimizer optimizer;
optimizer.optimize(root.get());
viewer->setSceneData(root.get());
viewer->realize();
viewer->run();
|
|