|
本帖最后由 liuzhiyu123 于 2012-6-13 13:27 编辑
请教一个大家认为灰常简单的问题。
在osgManipulator中,TranslateAxisDragger的setupDefaultGeometry函数中,有这样的设置- // Create a line.
- osg::Geode* lineGeode = new osg::Geode;
- {
- osg::Geometry* geometry = new osg::Geometry();
-
- osg::Vec3Array* vertices = new osg::Vec3Array(2);
- (*vertices)[0] = osg::Vec3(0.0f,0.0f,0.0f);
- (*vertices)[1] = osg::Vec3(0.0f,0.0f,1.0f);
- geometry->setVertexArray(vertices);
- geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,2));
- lineGeode->addDrawable(geometry);
- }
- // Turn of lighting for line and set line width.
- {
- osg::LineWidth* linewidth = new osg::LineWidth();
- linewidth->setWidth(2.0f);
- lineGeode->getOrCreateStateSet()->setAttributeAndModes(linewidth, osg::StateAttribute::ON);
- lineGeode->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
- }//[color=Red]这里已经对这个geode节点关闭了光照[/color]
- 但是使用了这个函数
- void osgManipulator::setMaterialColor(const osg::Vec4& color, osg::Node& node)
- {
- osg::Material* mat = dynamic_cast<osg::Material*>(node.getOrCreateStateSet()->getAttribute(osg::StateAttribute::MATERIAL));
- if (! mat)
- {
- mat = new osg::Material;
- mat->setDataVariance(osg::Object::DYNAMIC);
- node.getOrCreateStateSet()->setAttribute(mat);
- }
- mat->setDiffuse(osg::Material::FRONT_AND_BACK, color);
- }
- [color=Red]为什么会起作用?
- 还有在那个拖拽轴起作用的时候,它的颜色是怎么改变的?(已经关闭光照)[/color]
复制代码 |
|