diff --git a/components/nifosg/controller.cpp b/components/nifosg/controller.cpp index e66713c17..bb698ed63 100644 --- a/components/nifosg/controller.cpp +++ b/components/nifosg/controller.cpp @@ -387,6 +387,13 @@ MaterialColorController::MaterialColorController(const MaterialColorController & { } +void MaterialColorController::setDefaults(osg::StateSet *stateset) +{ + // need to create a deep copy of StateAttributes we will modify + osg::Material* mat = static_cast(stateset->getAttribute(osg::StateAttribute::MATERIAL)); + stateset->setAttribute(osg::clone(mat, osg::CopyOp::DEEP_COPY_ALL), osg::StateAttribute::ON); +} + void MaterialColorController::apply(osg::StateSet *stateset, osg::NodeVisitor *nv) { if (hasInput()) diff --git a/components/nifosg/controller.hpp b/components/nifosg/controller.hpp index 500a5cc17..58870317e 100644 --- a/components/nifosg/controller.hpp +++ b/components/nifosg/controller.hpp @@ -208,6 +208,8 @@ namespace NifOsg META_Object(NifOsg, MaterialColorController) + virtual void setDefaults(osg::StateSet* stateset); + virtual void apply(osg::StateSet* stateset, osg::NodeVisitor* nv); };