|
本帖最后由 gis_wudi 于 2014-1-17 10:54 编辑
遇到个问题,用三角面绘制的时候,关闭了光照,但在旋转视角后,会莫名其妙的变色了,不知道是什么情况,望解答
正常显示
异常变色了
贴一部分代码
。。。
osg::ref_ptr<osg::Vec3Array> normals = new osg::Vec3Array();
normals->push_back(osg:uat(osg:I_2+dip,at)*dipVec);
normals->push_back(osg::Quat(osg::PI_2+dip,at)*dipVec);
normals->push_back(osg::Quat(osg::PI_2+dip,at)*dipVec);
normals->push_back(osg::Quat(osg::PI_2+dip,at)*dipVec);
normals->push_back(up);
normals->push_back(up);
osg::ref_ptr<osg::Vec2Array> texs = new osg::Vec2Array();
texs->push_back(osg::Vec2(0,0));
texs->push_back(osg::Vec2(hLen / bCTex,0));
float ratio = 1 - gEdgeDisFrombEdge / (gEdgeDisFrombEdge + ((*vertex)[2]-(*vertex)[0]).length());
texs->push_back(osg::Vec2(0,ratio));
texs->push_back(osg::Vec2(hLen / bCTex,ratio));
texs->push_back(osg::Vec2(0,1));
texs->push_back(osg::Vec2(hLen / bCTex,1));
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
geom->addPrimitiveSet( new osg:rawArrays(
osg::PrimitiveSet::TRIANGLE_STRIP,
0, vertex->size()));
geom->setVertexArray(vertex);
geom->setNormalArray(normals);
geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
geom->setTexCoordArray(0,texs);
geom->getOrCreateStateSet()->setTextureAttributeAndModes(0,bcTexture,osg::StateAttribute::ON);
//geom->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
baseGeo->addDrawable(geom);
}
prePos = pos * mat;
}
baseGeo->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); |
|