Fixed the rotation of normals

This commit is contained in:
Robert Osfield 2010-02-11 11:06:12 +00:00
parent eac767d494
commit 653449a6a2

View File

@ -210,6 +210,9 @@ void GLBeginEndAdapter::End()
const osg::Matrixd& matrix = _matrixStack.back();
if (_mode==APPLY_LOCAL_MATRICES_TO_VERTICES)
{
osg::Matrix inverse;
inverse.invert(matrix);
for(Vec3Array::iterator itr = _vertices->begin();
itr != _vertices->end();
++itr)
@ -223,13 +226,13 @@ void GLBeginEndAdapter::End()
itr != _normals->end();
++itr)
{
*itr = osg::Matrixd::transform3x3(matrix, *itr);
*itr = osg::Matrixd::transform3x3(inverse, *itr);
(*itr).normalize();
}
}
else
{
_overallNormal = osg::Matrixd::transform3x3(matrix, _overallNormal);
_overallNormal = osg::Matrixd::transform3x3(inverse, _overallNormal);
_overallNormal.normalize();
}
}