From 56d4c7a269a152dfd5831f0ca3981b1eac89bc64 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 15 May 2006 11:27:07 +0000 Subject: [PATCH] From Paul Martz, "add support for the v16.0 "Add" texture environment and "mirrored repeat" wrap mode." --- src/osgPlugins/OpenFlight/AttrData.h | 9 +++++--- src/osgPlugins/OpenFlight/PaletteRecords.cpp | 24 ++++++++++++++++++-- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/osgPlugins/OpenFlight/AttrData.h b/src/osgPlugins/OpenFlight/AttrData.h index a1362c6a3..ac35427ec 100644 --- a/src/osgPlugins/OpenFlight/AttrData.h +++ b/src/osgPlugins/OpenFlight/AttrData.h @@ -20,7 +20,7 @@ class AttrData : public osg::Object AttrData(); - AttrData(const AttrData& attr, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); + AttrData(const AttrData& attr, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); META_Object(flt,AttrData); @@ -57,14 +57,16 @@ class AttrData : public osg::Object enum WrapMode { WRAP_REPEAT = 0, - WRAP_CLAMP = 1 + WRAP_CLAMP = 1, + WRAP_MIRRORED_REPEAT = 2 }; enum TexEnvMode { TEXENV_MODULATE = 0, TEXENV_BLEND = 1, TEXENV_DECAL = 2, - TEXENV_COLOR = 3 + TEXENV_COLOR = 3, + TEXENV_ADD = 4 }; enum Projection { @@ -142,6 +144,7 @@ class AttrData : public osg::Object // 1 - TV_BLEND // 2 - TV_DECAL // 3 - TV_COLOR + // 4 - TV_ADD int32 intensityAsAlpha; // TRUE if intensity pattern to be loaded in alpha with white in color // int32 spare1[8]; // 8 words of spare float64 size_u; // Real world size u for floating point databases diff --git a/src/osgPlugins/OpenFlight/PaletteRecords.cpp b/src/osgPlugins/OpenFlight/PaletteRecords.cpp index 11813daed..434104320 100644 --- a/src/osgPlugins/OpenFlight/PaletteRecords.cpp +++ b/src/osgPlugins/OpenFlight/PaletteRecords.cpp @@ -234,6 +234,23 @@ protected: virtual ~TexturePalette() {} + osg::Texture2D::WrapMode convertWrapMode( int32 wrap ) + { + switch( wrap ) + { + case AttrData::WRAP_CLAMP: + return osg::Texture2D::CLAMP; + break; + case AttrData::WRAP_MIRRORED_REPEAT: + return osg::Texture2D::MIRROR; + break; + default: + case AttrData::WRAP_REPEAT: + return osg::Texture2D::REPEAT; + break; + } + } + virtual void readRecord(RecordInputStream& in, Document& document) { int maxLength = (document.version() < VERSION_14) ? 80 : 200; @@ -270,10 +287,10 @@ protected: if (attr.valid()) { // Wrap mode - osg::Texture2D::WrapMode wrap_s = (attr->wrapMode_u==AttrData::WRAP_CLAMP) ? osg::Texture2D::CLAMP : osg::Texture2D::REPEAT; + osg::Texture2D::WrapMode wrap_s = convertWrapMode( attr->wrapMode_u ); texture->setWrap(osg::Texture2D::WRAP_S,wrap_s); - osg::Texture2D::WrapMode wrap_t = (attr->wrapMode_v==AttrData::WRAP_CLAMP) ? osg::Texture2D::CLAMP : osg::Texture2D::REPEAT; + osg::Texture2D::WrapMode wrap_t = convertWrapMode( attr->wrapMode_v ); texture->setWrap(osg::Texture2D::WRAP_T,wrap_t); // Min filter @@ -343,6 +360,9 @@ protected: case AttrData::TEXENV_COLOR: texenv->setMode(osg::TexEnv::REPLACE); break; + case AttrData::TEXENV_ADD: + texenv->setMode(osg::TexEnv::ADD); + break; } stateset->setTextureAttribute(0, texenv); }