From db50f954829f6dc1917c27c543de380aa427a4b2 Mon Sep 17 00:00:00 2001 From: ehofman Date: Mon, 23 May 2005 16:35:00 +0000 Subject: [PATCH] Melchior FRANZ: 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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/simgear/scene/model/animation.cxx b/simgear/scene/model/animation.cxx index 92d1bda5..cf18f9b6 100644 --- a/simgear/scene/model/animation.cxx +++ b/simgear/scene/model/animation.cxx @@ -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); -- 2.39.5