]> git.mxchange.org Git - simgear.git/commitdiff
Melchior FRANZ:
authorehofman <ehofman>
Mon, 23 May 2005 16:35:00 +0000 (16:35 +0000)
committerehofman <ehofman>
Mon, 23 May 2005 16:35:00 +0000 (16:35 +0000)
Currently, the material animation sets glColorMaterial(GL_AMBIENT_AND_DIFFUSE)
for all material properties. This breaks emission-only (e.g. cockpit lighting
for the p51d) or specular-only animation. ==> set glColorMaterial only where
it is really required.

simgear/scene/model/animation.cxx

index 92d1bda5a65d0235407c34f8082c5f284a409cfa..cf18f9b6dbe70648df5c52a457153a4b5b956ea7 100644 (file)
@@ -1296,16 +1296,21 @@ void SGMaterialAnimation::setMaterialBranch(ssgBranch *b)
         return;
 
     ssgSimpleState *s = (ssgSimpleState *)((ssgLeaf *)b)->getState();
-    s->disable(GL_COLOR_MATERIAL);
-    s->setColourMaterial(GL_AMBIENT_AND_DIFFUSE);
 
     if (_update & DIFFUSE) {
         float *v = _diff.rgba();
         SGfloat alpha = s->getMaterial(GL_DIFFUSE)[3];
+        s->setColourMaterial(GL_DIFFUSE);
+        s->enable(GL_COLOR_MATERIAL);
         s->setMaterial(GL_DIFFUSE, v[0], v[1], v[2], alpha);
+        s->disable(GL_COLOR_MATERIAL);
     }
-    if (_update & AMBIENT)
+    if (_update & AMBIENT) {
+        s->setColourMaterial(GL_AMBIENT);
+        s->enable(GL_COLOR_MATERIAL);
         s->setMaterial(GL_AMBIENT, _amb.rgba());
+        s->disable(GL_COLOR_MATERIAL);
+    }
     if (_update & EMISSION)
         s->setMaterial(GL_EMISSION, _emis.rgba());
     if (_update & SPECULAR)
@@ -1324,9 +1329,12 @@ void SGMaterialAnimation::setMaterialBranch(ssgBranch *b)
         SGfloat alpha = s->getMaterial(GL_DIFFUSE)[3];
         ssgTexture *tex = s->getTexture();
         if ((tex && tex->hasAlpha()) || alpha < 0.999) {
+            s->setColourMaterial(GL_DIFFUSE);
+            s->enable(GL_COLOR_MATERIAL);
             s->enable(GL_BLEND);
             s->enable(GL_ALPHA_TEST);
             s->setTranslucent();
+            s->disable(GL_COLOR_MATERIAL);
         } else {
             s->disable(GL_BLEND);
             s->disable(GL_ALPHA_TEST);