From Paul Martz, "add support for the v16.0 "Add" texture environment and "mirrored repeat" wrap mode."
This commit is contained in:
parent
fdda54e77e
commit
56d4c7a269
@ -57,14 +57,16 @@ class AttrData : public osg::Object
|
|||||||
|
|
||||||
enum WrapMode {
|
enum WrapMode {
|
||||||
WRAP_REPEAT = 0,
|
WRAP_REPEAT = 0,
|
||||||
WRAP_CLAMP = 1
|
WRAP_CLAMP = 1,
|
||||||
|
WRAP_MIRRORED_REPEAT = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TexEnvMode {
|
enum TexEnvMode {
|
||||||
TEXENV_MODULATE = 0,
|
TEXENV_MODULATE = 0,
|
||||||
TEXENV_BLEND = 1,
|
TEXENV_BLEND = 1,
|
||||||
TEXENV_DECAL = 2,
|
TEXENV_DECAL = 2,
|
||||||
TEXENV_COLOR = 3
|
TEXENV_COLOR = 3,
|
||||||
|
TEXENV_ADD = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Projection {
|
enum Projection {
|
||||||
@ -142,6 +144,7 @@ class AttrData : public osg::Object
|
|||||||
// 1 - TV_BLEND
|
// 1 - TV_BLEND
|
||||||
// 2 - TV_DECAL
|
// 2 - TV_DECAL
|
||||||
// 3 - TV_COLOR
|
// 3 - TV_COLOR
|
||||||
|
// 4 - TV_ADD
|
||||||
int32 intensityAsAlpha; // TRUE if intensity pattern to be loaded in alpha with white in color
|
int32 intensityAsAlpha; // TRUE if intensity pattern to be loaded in alpha with white in color
|
||||||
// int32 spare1[8]; // 8 words of spare
|
// int32 spare1[8]; // 8 words of spare
|
||||||
float64 size_u; // Real world size u for floating point databases
|
float64 size_u; // Real world size u for floating point databases
|
||||||
|
@ -234,6 +234,23 @@ protected:
|
|||||||
|
|
||||||
virtual ~TexturePalette() {}
|
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)
|
virtual void readRecord(RecordInputStream& in, Document& document)
|
||||||
{
|
{
|
||||||
int maxLength = (document.version() < VERSION_14) ? 80 : 200;
|
int maxLength = (document.version() < VERSION_14) ? 80 : 200;
|
||||||
@ -270,10 +287,10 @@ protected:
|
|||||||
if (attr.valid())
|
if (attr.valid())
|
||||||
{
|
{
|
||||||
// Wrap mode
|
// 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);
|
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);
|
texture->setWrap(osg::Texture2D::WRAP_T,wrap_t);
|
||||||
|
|
||||||
// Min filter
|
// Min filter
|
||||||
@ -343,6 +360,9 @@ protected:
|
|||||||
case AttrData::TEXENV_COLOR:
|
case AttrData::TEXENV_COLOR:
|
||||||
texenv->setMode(osg::TexEnv::REPLACE);
|
texenv->setMode(osg::TexEnv::REPLACE);
|
||||||
break;
|
break;
|
||||||
|
case AttrData::TEXENV_ADD:
|
||||||
|
texenv->setMode(osg::TexEnv::ADD);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
stateset->setTextureAttribute(0, texenv);
|
stateset->setTextureAttribute(0, texenv);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user