|
各位,我在使用osg:ineWidth,发现有个问题,当将线宽设置为1.0,10.0,线的宽度确实变宽了,
但是将线宽设置为100.0后,实际显示的时候线宽未继续变大了。
下面是我测试代码和截图(分别是线宽,为1.0,10.0,100.0的结果)。
请问这是osg的bug吗?还是小弟使用错误了。大侠请指点。
- //测试,如何修改线的宽度
- osg::Drawable* createAxis2(const osg::Vec3& corner,const osg::Vec3& xdir,const osg::Vec3& ydir,const osg::Vec3& zdir)
- {
- // set up the Geometry.
- osg::Geometry* geom = new osg::Geometry;
- osg::Vec3Array* coords = new osg::Vec3Array(6);
- (*coords)[0] = corner;
- (*coords)[1] = corner+xdir;
- (*coords)[2] = corner;
- (*coords)[3] = corner+ydir;
- (*coords)[4] = corner;
- (*coords)[5] = corner+zdir;
- geom->setVertexArray(coords);
- osg::Vec4 x_color(0.0f,1.0f,1.0f,1.0f);
- osg::Vec4 y_color(0.0f,1.0f,1.0f,1.0f);
- osg::Vec4 z_color(1.0f,0.0f,0.0f,1.0f);
- osg::Vec4Array* color = new osg::Vec4Array(6);
- (*color)[0] = x_color;
- (*color)[1] = x_color;
- (*color)[2] = y_color;
- (*color)[3] = y_color;
- (*color)[4] = z_color;
- (*color)[5] = z_color;
- geom->setColorArray(color);
- geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
- geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));
- osg::StateSet* stateset = geom->getOrCreateStateSet();
- osg::LineWidth* linewidth = new osg::LineWidth();
- linewidth->setWidth(100.0f); //改变此值
- stateset->setAttributeAndModes(linewidth,osg::StateAttribute::ON);
- stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
- return geom;
- }
- osg::Node* createModel2()
- {
- // create the root node which will hold the model.
- osg::Group* root = new osg::Group();
- osg::Geode* axis = new osg::Geode();
- axis->addDrawable(createAxis2(osg::Vec3(0.0f,0.0f,0.0f),osg::Vec3(5.0f,0.0f,0.0f),osg::Vec3(0.0f,5.0f,0.0f),osg::Vec3(0.0f,0.0f,5.0f)));
- root->addChild(axis);
- return root;
- }
- int main(int, char**)
- {
- // construct the viewer
- osgViewer::Viewer viewer;
- // set the scene to render
- viewer.setSceneData(createModel2());
- viewer.addEventHandler(new osgViewer::WindowSizeHandler);
- // run the viewers frame loop
- return viewer.run();
- }
复制代码
|
|