Implement lightmode/vertmode of NiVertexColorProperty

pull/280/head
scrawl 7 years ago
parent 4fba157d3b
commit 5d2fe5e887

@ -1674,6 +1674,8 @@ namespace NifOsg
bool hasMatCtrl = false; bool hasMatCtrl = false;
int lightmode = 1;
for (std::vector<const Nif::Property*>::const_reverse_iterator it = properties.rbegin(); it != properties.rend(); ++it) for (std::vector<const Nif::Property*>::const_reverse_iterator it = properties.rbegin(); it != properties.rend(); ++it)
{ {
const Nif::Property* property = *it; const Nif::Property* property = *it;
@ -1706,19 +1708,25 @@ namespace NifOsg
case Nif::RC_NiVertexColorProperty: case Nif::RC_NiVertexColorProperty:
{ {
const Nif::NiVertexColorProperty* vertprop = static_cast<const Nif::NiVertexColorProperty*>(property); const Nif::NiVertexColorProperty* vertprop = static_cast<const Nif::NiVertexColorProperty*>(property);
if (!hasVertexColors) lightmode = vertprop->data.lightmode;
break;
switch (vertprop->flags) if (hasVertexColors)
{ {
case 0: switch (vertprop->data.vertmode)
mat->setColorMode(osg::Material::OFF); {
break; case 0:
case 1: mat->setColorMode(osg::Material::OFF);
mat->setColorMode(osg::Material::EMISSION); break;
break; case 1:
case 2: mat->setColorMode(osg::Material::EMISSION);
mat->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE); break;
break; case 2:
if (lightmode != 0)
mat->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
else
mat->setColorMode(osg::Material::OFF);
break;
}
} }
break; break;
} }
@ -1772,6 +1780,14 @@ namespace NifOsg
mat->setColorMode(osg::Material::AMBIENT); mat->setColorMode(osg::Material::AMBIENT);
} }
if (lightmode == 0)
{
osg::Vec4f diffuse = mat->getDiffuse(osg::Material::FRONT_AND_BACK);
diffuse = osg::Vec4f(0,0,0,diffuse.a());
mat->setDiffuse(osg::Material::FRONT_AND_BACK, diffuse);
mat->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4f());
}
if (!hasMatCtrl && mat->getColorMode() == osg::Material::OFF if (!hasMatCtrl && mat->getColorMode() == osg::Material::OFF
&& mat->getEmission(osg::Material::FRONT_AND_BACK) == osg::Vec4f(0,0,0,1) && mat->getEmission(osg::Material::FRONT_AND_BACK) == osg::Vec4f(0,0,0,1)
&& mat->getDiffuse(osg::Material::FRONT_AND_BACK) == osg::Vec4f(1,1,1,1) && mat->getDiffuse(osg::Material::FRONT_AND_BACK) == osg::Vec4f(1,1,1,1)

Loading…
Cancel
Save