|
|
|
@ -385,8 +385,9 @@ void AlphaController::apply(osg::StateSet *stateset, osg::NodeVisitor *nv)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaterialColorController::MaterialColorController(const Nif::NiPosData *data)
|
|
|
|
|
MaterialColorController::MaterialColorController(const Nif::NiPosData *data, TargetColor color)
|
|
|
|
|
: mData(data->mKeyList, osg::Vec3f(1,1,1))
|
|
|
|
|
, mTargetColor(color)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -397,6 +398,7 @@ MaterialColorController::MaterialColorController()
|
|
|
|
|
MaterialColorController::MaterialColorController(const MaterialColorController ©, const osg::CopyOp ©op)
|
|
|
|
|
: StateSetUpdater(copy, copyop), Controller(copy)
|
|
|
|
|
, mData(copy.mData)
|
|
|
|
|
, mTargetColor(copy.mTargetColor)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -413,9 +415,37 @@ void MaterialColorController::apply(osg::StateSet *stateset, osg::NodeVisitor *n
|
|
|
|
|
{
|
|
|
|
|
osg::Vec3f value = mData.interpKey(getInputValue(nv));
|
|
|
|
|
osg::Material* mat = static_cast<osg::Material*>(stateset->getAttribute(osg::StateAttribute::MATERIAL));
|
|
|
|
|
osg::Vec4f diffuse = mat->getDiffuse(osg::Material::FRONT_AND_BACK);
|
|
|
|
|
diffuse.set(value.x(), value.y(), value.z(), diffuse.a());
|
|
|
|
|
mat->setDiffuse(osg::Material::FRONT_AND_BACK, diffuse);
|
|
|
|
|
switch (mTargetColor)
|
|
|
|
|
{
|
|
|
|
|
case Diffuse:
|
|
|
|
|
{
|
|
|
|
|
osg::Vec4f diffuse = mat->getDiffuse(osg::Material::FRONT_AND_BACK);
|
|
|
|
|
diffuse.set(value.x(), value.y(), value.z(), diffuse.a());
|
|
|
|
|
mat->setDiffuse(osg::Material::FRONT_AND_BACK, diffuse);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Specular:
|
|
|
|
|
{
|
|
|
|
|
osg::Vec4f specular = mat->getSpecular(osg::Material::FRONT_AND_BACK);
|
|
|
|
|
specular.set(value.x(), value.y(), value.z(), specular.a());
|
|
|
|
|
mat->setSpecular(osg::Material::FRONT_AND_BACK, specular);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Emissive:
|
|
|
|
|
{
|
|
|
|
|
osg::Vec4f emissive = mat->getEmission(osg::Material::FRONT_AND_BACK);
|
|
|
|
|
emissive.set(value.x(), value.y(), value.z(), emissive.a());
|
|
|
|
|
mat->setEmission(osg::Material::FRONT_AND_BACK, emissive);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Ambient:
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
osg::Vec4f ambient = mat->getAmbient(osg::Material::FRONT_AND_BACK);
|
|
|
|
|
ambient.set(value.x(), value.y(), value.z(), ambient.a());
|
|
|
|
|
mat->setAmbient(osg::Material::FRONT_AND_BACK, ambient);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|