From Paul Martz, "add support for the v16.0 "Add" texture environment and "mirrored repeat" wrap mode."

This commit is contained in:
Robert Osfield 2006-05-15 11:27:07 +00:00
parent fdda54e77e
commit 56d4c7a269
2 changed files with 28 additions and 5 deletions

View File

@ -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

View File

@ -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);
}