模型大小变化后模型显示异常
代码如下:setlocale(LC_ALL, "chs");
osg::Node* node = osgDB::readNodeFile(strPath);
setlocale(LC_ALL, "C");
if (node != NULL)
{
osg::MatrixTransform* matTrans = new osg::MatrixTransform;
matTrans->addChild(node);
matTrans->setName(node->getName());
matTrans->setMatrix(osg::Matrix::scale(100, 100, 100) * osg::Matrix::rotate(1.5, osg::Z_AXIS) *
osg::Matrix::translate(osg::Vec3(1000, 1000, -10000)));
_pRoot->removeChildren(0, _pRoot->getNumChildren());
_pRoot->addChild(matTrans);
}
如果不设置osg::Matrix::scale则模型显示正常,如果变化大小场景中许多模型显示异常,可能颜色不对,可能纹理不对。灯光设置也不起作用,求大神们耐心指导下,谢谢。
matTrans->getOrCreateStateSet()->setMode(GL_RESCALE_NORMAL, osg::StateAttribute::ON);
matTrans->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
好吧!自己解决了,脑壳短路了。
页:
[1]