From 3aab31f1988e6eeadffa2bf1b2873803bfd2856e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 23 Dec 2011 17:40:31 +0000 Subject: [PATCH] From Paul Martz and David Glenn, "From David Glenn and Paul Martz. This change adds support for the NO_COLOR bit in the Vertex records' flags field. If NO_COLOR is set, and PACKED_COLOR is not set, the code will now properly default to using the face color at those vertices. See the osg-users thread "Open Flight characteristic not reflected in the current OSG" for more info." and "In consultation with David Glenn, it appears we needed to change a second file to correct how OpenFlight handles transparency when vertices have NO_COLOR. " --- src/osgPlugins/OpenFlight/GeometryRecords.cpp | 5 +++- src/osgPlugins/OpenFlight/VertexRecords.cpp | 28 ++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/osgPlugins/OpenFlight/GeometryRecords.cpp b/src/osgPlugins/OpenFlight/GeometryRecords.cpp index bb48a1e5e..85daddb2b 100644 --- a/src/osgPlugins/OpenFlight/GeometryRecords.cpp +++ b/src/osgPlugins/OpenFlight/GeometryRecords.cpp @@ -254,7 +254,10 @@ public: { // Use face color if vertex color is -1 in a gouraud polygon. // http://www.multigen-paradigm.com/ubb/Forum1/HTML/000967.html - colors->push_back(_primaryColor); + // Incorporate Face transparency per osg-users thread "Open Flight + // characteristic not reflected in the current OSG" (Sept/Oct 2011) + colors->push_back(osg::Vec4(_primaryColor.r(), _primaryColor.g(), + _primaryColor.b(), ( 1.0 - getTransparency() ) )); } } diff --git a/src/osgPlugins/OpenFlight/VertexRecords.cpp b/src/osgPlugins/OpenFlight/VertexRecords.cpp index a6de5eeff..988624640 100644 --- a/src/osgPlugins/OpenFlight/VertexRecords.cpp +++ b/src/osgPlugins/OpenFlight/VertexRecords.cpp @@ -68,8 +68,13 @@ class VertexC : public Record // color if (flags & PACKED_COLOR) vertex.setColor(packedColor); // Packed color - else if (colorIndex >= 0) + else if( ( (flags & NO_COLOR) == 0 ) && + ( colorIndex >= 0 ) ) + { + // Only use the color index if the NO_COLOR bit is _not_ set + // and the index isn't negative. vertex.setColor(getColorFromPool(colorIndex, document.getColorPool())); // Color from pool + } if (_parent.valid()) _parent->addVertex(vertex); @@ -108,8 +113,13 @@ class VertexCN : public Record // color if (flags & PACKED_COLOR) vertex.setColor(packedColor); // Packed color - else if (colorIndex >= 0) + else if( ( (flags & NO_COLOR) == 0 ) && + ( colorIndex >= 0 ) ) + { + // Only use the color index if the NO_COLOR bit is _not_ set + // and the index isn't negative. vertex.setColor(getColorFromPool(colorIndex, document.getColorPool())); // Color from pool + } if (_parent.valid()) _parent->addVertex(vertex); @@ -148,8 +158,13 @@ class VertexCT : public Record // color if (flags & PACKED_COLOR) vertex.setColor(packedColor); // Packed color - else if (colorIndex >= 0) + else if( ( (flags & NO_COLOR) == 0 ) && + ( colorIndex >= 0 ) ) + { + // Only use the color index if the NO_COLOR bit is _not_ set + // and the index isn't negative. vertex.setColor(getColorFromPool(colorIndex, document.getColorPool())); // Color from pool + } if (_parent.valid()) _parent->addVertex(vertex); @@ -206,8 +221,13 @@ class VertexCNT : public Record // color if (flags & PACKED_COLOR) vertex.setColor(packedColor); // Packed color - else if (colorIndex >= 0) + else if( ( (flags & NO_COLOR) == 0 ) && + ( colorIndex >= 0 ) ) + { + // Only use the color index if the NO_COLOR bit is _not_ set + // and the index isn't negative. vertex.setColor(getColorFromPool(colorIndex, document.getColorPool())); // Color from pool + } if (_parent.valid()) _parent->addVertex(vertex);