From d445995432b0700069d3a60d60a0811e179e7881 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 6 Oct 2006 13:04:48 +0000 Subject: [PATCH] From Brede Johansen, "Here's a patch discussed in the thread "OpenFlight Loader Discarding Material" on the osg-user mailing list." --- src/osgPlugins/OpenFlight/GeometryRecords.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/osgPlugins/OpenFlight/GeometryRecords.cpp b/src/osgPlugins/OpenFlight/GeometryRecords.cpp index ec6a82665..b9363d661 100644 --- a/src/osgPlugins/OpenFlight/GeometryRecords.cpp +++ b/src/osgPlugins/OpenFlight/GeometryRecords.cpp @@ -303,8 +303,10 @@ protected: stateset->setMode(GL_LIGHTING, isLit() ? osg::StateAttribute::ON : osg::StateAttribute::OFF); // Material - if (isLit()) + if (isLit() || materialIndex>=0) { + // MaterialPool will return a "default" material if no material is defined for materialIndex. + // http://www.multigen-paradigm.com/ubb/Forum1/HTML/000228.html osg::Vec4 col = _primaryColor; col.a() = 1.0f - getTransparency(); osg::Material* material = document.getOrCreateMaterialPool()->getOrCreateMaterial(materialIndex,col); @@ -858,8 +860,10 @@ protected: stateset->setMode(GL_LIGHTING, isLit() ? osg::StateAttribute::ON : osg::StateAttribute::OFF); // Material - if (isLit()) + if (isLit() || materialIndex>=0) { + // MaterialPool will return a "default" material if no material is defined for materialIndex. + // http://www.multigen-paradigm.com/ubb/Forum1/HTML/000228.html osg::Vec4 col = _primaryColor; col.a() = 1.0f - getTransparency(); osg::Material* material = document.getOrCreateMaterialPool()->getOrCreateMaterial(materialIndex,col);