]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/SGMaterialAnimation.cxx
Compile even if OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION is not set.
[simgear.git] / simgear / scene / model / SGMaterialAnimation.cxx
index d726a59c5a6a4a0abb628f9e21a0b4596c8af7b4..61181aeb22c2ba70464dbd11808316a16c91d6e4 100644 (file)
@@ -29,6 +29,7 @@
 #include <simgear/scene/model/model.hxx>
 
 using namespace std;
+using namespace simgear;
 
 namespace {
 /**
@@ -485,6 +486,8 @@ SGMaterialAnimation::createAnimationGroup(osg::Group& parent)
     mat->setDataVariance(osg::Object::DYNAMIC);
     unsigned defaultColorModeMask = 0;
     mat->setUpdateCallback(0); // Just to make sure.
+    // XXX This should probably go away, as ac3d models always have a
+    // DIFFUSE color mode.
     switch (mat->getColorMode()) {
     case osg::Material::OFF:
       defaultColorModeMask = 0;
@@ -576,3 +579,32 @@ SGMaterialAnimation::install(osg::Node& node)
     }
     defaultAmbientDiffuse = defaultsVisitor.ambientDiffuse;
 }
+
+const char* colorNames[] =
+{
+    "ambient",
+    "diffuse",
+    "specular",
+    "emission"
+};
+
+// Build an effect which mimics the material color mode in a
+// shader. The OpenGL material values will be overridden by the
+// material animation's material.
+//
+// This is a hack to get the effect to respect the values set in the
+// material, set up by the animation, which overrides the values in
+// the effect's material attributes. Things will be different when
+// material animations are implemented purely by manipulating effects.
+
+SGPropertyNode_ptr
+SGMaterialAnimation::makeEffectProperties(const SGPropertyNode* animProp)
+{
+    SGPropertyNode_ptr eRoot = new SGPropertyNode;
+    SGPropertyNode* inherit = makeNode(eRoot, "inherits-from");
+    if (animProp->hasChild("diffuse") || animProp->hasChild("transparency"))
+        inherit->setStringValue("Effects/material-off");
+    else
+        inherit->setStringValue("Effects/material-diffuse");
+    return eRoot;
+}