Implement lightmode/vertmode of NiVertexColorProperty

0.6.1
scrawl 7 years ago
parent 4fba157d3b
commit 5d2fe5e887

@ -1674,6 +1674,8 @@ namespace NifOsg
bool hasMatCtrl = false;
int lightmode = 1;
for (std::vector<const Nif::Property*>::const_reverse_iterator it = properties.rbegin(); it != properties.rend(); ++it)
{
const Nif::Property* property = *it;
@ -1706,9 +1708,11 @@ namespace NifOsg
case Nif::RC_NiVertexColorProperty:
{
const Nif::NiVertexColorProperty* vertprop = static_cast<const Nif::NiVertexColorProperty*>(property);
if (!hasVertexColors)
break;
switch (vertprop->flags)
lightmode = vertprop->data.lightmode;
if (hasVertexColors)
{
switch (vertprop->data.vertmode)
{
case 0:
mat->setColorMode(osg::Material::OFF);
@ -1717,9 +1721,13 @@ namespace NifOsg
mat->setColorMode(osg::Material::EMISSION);
break;
case 2:
if (lightmode != 0)
mat->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
else
mat->setColorMode(osg::Material::OFF);
break;
}
}
break;
}
case Nif::RC_NiAlphaProperty:
@ -1772,6 +1780,14 @@ namespace NifOsg
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
&& 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)

Loading…
Cancel
Save