Have added a #define USE_DEPRECATED_API to include/osg/Export, and
various osg header and source files to optional compile in deprecated parts of the OSG API. Have renamed osg::Transparency osg::BlendFunc to bring it in line with the rest of the OSG's StateAttribute classes which are named after their OpenGL counterparts. include/osg/Transparency still exists and is simply a typedef to BlendFunc and is enclosed in a #ifdef USE_DEPRECTATED_API block. The matrix methods in the osg::Transform class have been moved/replicated in a osg::MatrixTransform sublcass from osg::Transform. The old matrix functionality is still present in the osg::Transform class but is guard by #ifdef USG_DEPRECATED_API blocks. One should now think of osg::Transform as being a Transform Node base class. MatrixTransform has all the functionality of the original Transform class, so should be used instead.
This commit is contained in:
@@ -183,7 +183,7 @@ void set2dScene(osg::Group* rootNode)
|
||||
textState->setAttribute(textMaterial );
|
||||
textState->setAttribute(transp);
|
||||
|
||||
textState->setMode(GL_TEXTURE_2D,osg::StateAttribute::ON);
|
||||
textState->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON);
|
||||
textState->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
||||
geode->setStateSet( textState );
|
||||
|
||||
|
||||
@@ -340,9 +340,10 @@ void build_world(osg::Group *root)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
int main()
|
||||
int main( int /*argc*/, char **argv )
|
||||
{
|
||||
osgGLUT::Viewer viewer;
|
||||
viewer.setWindowTitle(argv[0]);
|
||||
|
||||
osg::Group *root = osgNew osg::Group;
|
||||
build_world(root);
|
||||
|
||||
@@ -119,8 +119,8 @@ int main( int argc, char **argv )
|
||||
stateset->setAttributeAndModes(material,osg::StateAttribute::OVERRIDE_ON);
|
||||
stateset->setAttributeAndModes(polyoffset,osg::StateAttribute::OVERRIDE_ON);
|
||||
stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE_ON);
|
||||
stateset->setMode(GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE_OFF);
|
||||
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE_ON);
|
||||
stateset->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE_OFF);
|
||||
|
||||
// osg::LineStipple* linestipple = new osg::LineStipple;
|
||||
// linestipple->setFactor(1);
|
||||
|
||||
@@ -77,17 +77,11 @@ void set2dScene(osg::Group* rootNode)
|
||||
osgText::Text::BOUNDINGBOX |
|
||||
osgText::Text::ALIGNMENT );
|
||||
text->setAlignment(gAlignment);
|
||||
text->setColor(TEXT_COL_2D);
|
||||
geode = osgNew osg::Geode();
|
||||
geode->setName("BitmapFont");
|
||||
geode->addDrawable( text );
|
||||
|
||||
textMaterial = osgNew osg::Material();
|
||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D);
|
||||
textState = osgNew osg::StateSet();
|
||||
textState->setAttribute(textMaterial );
|
||||
geode->setStateSet( textState );
|
||||
|
||||
rootNode->addChild(geode);
|
||||
|
||||
xOffset+=90;
|
||||
@@ -105,24 +99,17 @@ void set2dScene(osg::Group* rootNode)
|
||||
osgText::Text::BOUNDINGBOX |
|
||||
osgText::Text::ALIGNMENT );
|
||||
text->setAlignment(gAlignment);
|
||||
text->setColor(TEXT_COL_2D);
|
||||
geode = osgNew osg::Geode();
|
||||
geode->setName("PixmapFont");
|
||||
geode->addDrawable( text );
|
||||
|
||||
textMaterial = osgNew osg::Material();
|
||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_2D);
|
||||
// to get antiaA pixmapFonts we have to draw them with blending
|
||||
osg::Transparency *transp= osgNew osg::Transparency();
|
||||
transp->setFunction(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
||||
|
||||
|
||||
textState = osgNew osg::StateSet();
|
||||
textState->setAttribute(textMaterial );
|
||||
textState->setAttribute(transp);
|
||||
textState->setMode(GL_BLEND,osg::StateAttribute::ON);
|
||||
textState->setAttributeAndModes(transp,osg::StateAttribute::ON);
|
||||
textState->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
||||
|
||||
|
||||
@@ -145,22 +132,19 @@ void set2dScene(osg::Group* rootNode)
|
||||
osgText::Text::BOUNDINGBOX |
|
||||
osgText::Text::ALIGNMENT );
|
||||
text->setAlignment(gAlignment);
|
||||
text->setColor(TEXT_COL_2D);
|
||||
geode = osgNew osg::Geode();
|
||||
geode->setName("TextureFont");
|
||||
geode->addDrawable( text );
|
||||
|
||||
textMaterial = osgNew osg::Material();
|
||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D);
|
||||
// to get antiaA pixmapFonts we have to draw them with blending
|
||||
transp= osgNew osg::Transparency();
|
||||
transp->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
textState = osgNew osg::StateSet();
|
||||
textState->setAttribute(textMaterial );
|
||||
textState->setAttribute(transp);
|
||||
textState->setAttributeAndModes(transp,osg::StateAttribute::ON);
|
||||
|
||||
textState->setMode(GL_TEXTURE_2D,osg::StateAttribute::ON);
|
||||
textState->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON);
|
||||
textState->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
||||
geode->setStateSet( textState );
|
||||
|
||||
@@ -182,17 +166,11 @@ void set2dScene(osg::Group* rootNode)
|
||||
osgText::Text::BOUNDINGBOX |
|
||||
osgText::Text::ALIGNMENT );
|
||||
text->setAlignment(gAlignment);
|
||||
text->setColor(TEXT_COL_2D);
|
||||
geode = osgNew osg::Geode();
|
||||
geode->setName("PolygonFont");
|
||||
geode->addDrawable( text );
|
||||
|
||||
textMaterial = osgNew osg::Material();
|
||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D);
|
||||
textState = osgNew osg::StateSet();
|
||||
textState->setAttribute(textMaterial );
|
||||
geode->setStateSet( textState );
|
||||
|
||||
rootNode->addChild(geode);
|
||||
|
||||
xOffset+=90;
|
||||
@@ -212,17 +190,11 @@ void set2dScene(osg::Group* rootNode)
|
||||
osgText::Text::BOUNDINGBOX |
|
||||
osgText::Text::ALIGNMENT );
|
||||
text->setAlignment(gAlignment);
|
||||
text->setColor(TEXT_COL_2D);
|
||||
geode = osgNew osg::Geode();
|
||||
geode->setName("OutlineFont");
|
||||
geode->addDrawable( text );
|
||||
|
||||
textMaterial = osgNew osg::Material();
|
||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D);
|
||||
textState = osgNew osg::StateSet();
|
||||
textState->setAttribute(textMaterial );
|
||||
geode->setStateSet( textState );
|
||||
|
||||
rootNode->addChild(geode);
|
||||
|
||||
|
||||
@@ -337,7 +309,7 @@ void setScene(osg::Group* rootNode)
|
||||
textState->setAttribute(transp);
|
||||
|
||||
// textState->setMode(GL_BLEND,osg::StateAttribute::ON);
|
||||
textState->setMode(GL_TEXTURE_2D,osg::StateAttribute::ON);
|
||||
textState->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON);
|
||||
textState->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
||||
geode->setStateSet( textState );
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#include <osg/Transparency>
|
||||
#include <osg/BlendFunc>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
Transparency::Transparency()
|
||||
BlendFunc::BlendFunc()
|
||||
{
|
||||
_source_factor = SRC_ALPHA;
|
||||
_destination_factor = ONE_MINUS_SRC_ALPHA;
|
||||
}
|
||||
|
||||
|
||||
Transparency::~Transparency()
|
||||
BlendFunc::~BlendFunc()
|
||||
{
|
||||
}
|
||||
|
||||
void Transparency::apply(State&) const
|
||||
void BlendFunc::apply(State&) const
|
||||
{
|
||||
glBlendFunc( (GLenum)_source_factor, (GLenum)_destination_factor );
|
||||
}
|
||||
@@ -8,6 +8,7 @@ CXXFILES =\
|
||||
Billboard.cpp\
|
||||
BoundingBox.cpp\
|
||||
BoundingSphere.cpp\
|
||||
BlendFunc.cpp\
|
||||
Camera.cpp\
|
||||
ClipNode.cpp\
|
||||
ClipPlane.cpp\
|
||||
@@ -73,7 +74,6 @@ CXXFILES =\
|
||||
TextureCubeMap.cpp\
|
||||
Timer.cpp\
|
||||
Transform.cpp\
|
||||
Transparency.cpp\
|
||||
Version.cpp\
|
||||
Viewport.cpp\
|
||||
|
||||
|
||||
@@ -6,30 +6,36 @@ Transform::Transform()
|
||||
{
|
||||
_referenceFrame = RELATIVE_TO_PARENTS;
|
||||
|
||||
_matrix = osgNew Matrix;
|
||||
_inverse = osgNew Matrix;
|
||||
_inverseDirty = false;
|
||||
#ifdef USE_DEPRECATED_API
|
||||
_deprecated_matrix = osgNew Matrix;
|
||||
_deprecated_inverse = osgNew Matrix;
|
||||
_deprecated_inverseDirty = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
Transform::Transform(const Transform& transform,const CopyOp& copyop):
|
||||
Group(transform,copyop),
|
||||
_computeTransformCallback(transform._computeTransformCallback),
|
||||
_referenceFrame(transform._referenceFrame),
|
||||
_matrix(osgNew Matrix(*transform._matrix)),
|
||||
_inverse(osgNew Matrix(*transform._inverse)),
|
||||
_inverseDirty(transform._inverseDirty)
|
||||
_referenceFrame(transform._referenceFrame)
|
||||
#ifdef USE_DEPRECATED_API
|
||||
,
|
||||
_deprecated_matrix(osgNew Matrix(*transform._deprecated_matrix)),
|
||||
_deprecated_inverse(osgNew Matrix(*transform._deprecated_inverse)),
|
||||
_deprecated_inverseDirty(transform._deprecated_inverseDirty)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef USE_DEPRECATED_API
|
||||
Transform::Transform(const Matrix& mat )
|
||||
{
|
||||
_referenceFrame = RELATIVE_TO_PARENTS;
|
||||
|
||||
_matrix = osgNew Matrix(mat);
|
||||
_inverse = osgNew Matrix();
|
||||
_inverseDirty = false;
|
||||
_deprecated_matrix = osgNew Matrix(mat);
|
||||
_deprecated_inverse = osgNew Matrix();
|
||||
_deprecated_inverseDirty = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Transform::~Transform()
|
||||
{
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
cf->setMode(osg::CullFace::BACK);
|
||||
dstate->setAttribute(cf);
|
||||
|
||||
dstate->setMode(GL_TEXTURE_2D,StateAttribute::OFF);
|
||||
dstate->setTextureMode(0,GL_TEXTURE_2D,StateAttribute::OFF);
|
||||
settexture();
|
||||
}
|
||||
return dstate;
|
||||
|
||||
@@ -2002,9 +2002,9 @@ void MyStateSet::Query( const osg::StateSet &sset )
|
||||
}
|
||||
|
||||
// TEXTURE / TEXTURE_0
|
||||
attr = sset.getAttribute( osg::StateAttribute::TEXTURE );
|
||||
attr = sset.getTextureAttribute(0, osg::StateAttribute::TEXTURE );
|
||||
if ( attr &&
|
||||
( sset.getMode( GL_TEXTURE_2D ) & osg::StateAttribute::ON )) {
|
||||
( sset.getTextureMode(0, GL_TEXTURE_2D ) & osg::StateAttribute::ON )) {
|
||||
|
||||
const osg::Texture &texture = (const osg::Texture &) (*attr);
|
||||
|
||||
@@ -2060,9 +2060,9 @@ void MyStateSet::Query( const osg::StateSet &sset )
|
||||
}
|
||||
|
||||
// TEXENV
|
||||
attr = sset.getAttribute( osg::StateAttribute::TEXENV );
|
||||
attr = sset.getTextureAttribute(0, osg::StateAttribute::TEXENV );
|
||||
if ( attr &&
|
||||
( sset.getMode( GL_TEXTURE_2D ) & osg::StateAttribute::ON )) {
|
||||
( sset.getTextureMode(0, GL_TEXTURE_2D ) & osg::StateAttribute::ON )) {
|
||||
AddAttribute( osg::StateAttribute::TEXENV );
|
||||
|
||||
const osg::TexEnv &texenv = (const osg::TexEnv &) (*attr);
|
||||
@@ -2071,9 +2071,9 @@ void MyStateSet::Query( const osg::StateSet &sset )
|
||||
}
|
||||
|
||||
// TEXGEN
|
||||
attr = sset.getAttribute( osg::StateAttribute::TEXGEN );
|
||||
attr = sset.getTextureAttribute(0, osg::StateAttribute::TEXGEN );
|
||||
if ( attr &&
|
||||
( sset.getMode( GL_TEXTURE_2D ) & osg::StateAttribute::ON )) {
|
||||
( sset.getTextureMode(0, GL_TEXTURE_2D ) & osg::StateAttribute::ON )) {
|
||||
|
||||
// FIXME: Just note that it is there for now. We don't actually support
|
||||
// texture coordinate generation yet (i.e. generating the "uv" component
|
||||
|
||||
@@ -118,7 +118,7 @@ static void initOSGAttrNames()
|
||||
ADD_ATTR( osg::StateAttribute::TEXENV , "TEXENV" );
|
||||
ADD_ATTR( osg::StateAttribute::TEXGEN , "TEXGEN" );
|
||||
ADD_ATTR( osg::StateAttribute::TEXMAT , "TEXMAT" );
|
||||
ADD_ATTR( osg::StateAttribute::TRANSPARENCY , "TRANSPARENCY" );
|
||||
ADD_ATTR( osg::StateAttribute::BLENDFUNC , "BLENDFUNC" );
|
||||
ADD_ATTR( osg::StateAttribute::STENCIL , "STENCIL" );
|
||||
ADD_ATTR( osg::StateAttribute::COLORMASK , "COLORMASK" );
|
||||
ADD_ATTR( osg::StateAttribute::DEPTH , "DEPTH" );
|
||||
|
||||
107
src/osgPlugins/osg/BlendFunc.cpp
Normal file
107
src/osgPlugins/osg/BlendFunc.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
#include "osg/BlendFunc"
|
||||
|
||||
#include "osgDB/Registry"
|
||||
#include "osgDB/Input"
|
||||
#include "osgDB/Output"
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
|
||||
// forward declare functions to use later.
|
||||
bool BlendFunc_readLocalData(Object& obj, Input& fr);
|
||||
bool BlendFunc_writeLocalData(const Object& obj, Output& fw);
|
||||
|
||||
bool BlendFunc_matchModeStr(const char* str,int& mode);
|
||||
const char* BlendFunc_getModeStr(int value);
|
||||
|
||||
// register the read and write functions with the osgDB::Registry.
|
||||
RegisterDotOsgWrapperProxy g_BlendFuncProxy
|
||||
(
|
||||
osgNew osg::BlendFunc,
|
||||
"BlendFunc",
|
||||
"Object StateAttribute BlendFunc",
|
||||
&BlendFunc_readLocalData,
|
||||
&BlendFunc_writeLocalData
|
||||
);
|
||||
|
||||
RegisterDotOsgWrapperProxy g_TransparencyProxy
|
||||
(
|
||||
osgNew osg::BlendFunc,
|
||||
"Transparancy",
|
||||
"Object StateAttribute Transparency",
|
||||
&BlendFunc_readLocalData,
|
||||
&BlendFunc_writeLocalData
|
||||
);
|
||||
|
||||
bool BlendFunc_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
BlendFunc& transparency = static_cast<BlendFunc&>(obj);
|
||||
|
||||
int mode;
|
||||
if (fr[0].matchWord("source") && BlendFunc_matchModeStr(fr[1].getStr(),mode))
|
||||
{
|
||||
transparency.setSource(mode);
|
||||
fr+=2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("destination") && BlendFunc_matchModeStr(fr[1].getStr(),mode))
|
||||
{
|
||||
transparency.setDestination(mode);
|
||||
fr+=2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool BlendFunc_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const BlendFunc& transparency = static_cast<const BlendFunc&>(obj);
|
||||
|
||||
fw.indent() << "source " << BlendFunc_getModeStr(transparency.getSource()) << std::endl;
|
||||
fw.indent() << "destination " << BlendFunc_getModeStr(transparency.getDestination()) << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool BlendFunc_matchModeStr(const char* str,int& mode)
|
||||
{
|
||||
if (strcmp(str,"DST_ALPHA")==0) mode = BlendFunc::DST_ALPHA;
|
||||
else if (strcmp(str,"DST_COLOR")==0) mode = BlendFunc::DST_COLOR;
|
||||
else if (strcmp(str,"ONE")==0) mode = BlendFunc::ONE;
|
||||
else if (strcmp(str,"ONE_MINUS_DST_ALPHA")==0) mode = BlendFunc::ONE_MINUS_DST_ALPHA;
|
||||
else if (strcmp(str,"ONE_MINUS_DST_COLOR")==0) mode = BlendFunc::ONE_MINUS_DST_COLOR;
|
||||
else if (strcmp(str,"ONE_MINUS_SRC_ALPHA")==0) mode = BlendFunc::ONE_MINUS_SRC_ALPHA;
|
||||
else if (strcmp(str,"ONE_MINUS_SRC_COLOR")==0) mode = BlendFunc::ONE_MINUS_SRC_COLOR;
|
||||
else if (strcmp(str,"SRC_ALPHA")==0) mode = BlendFunc::SRC_ALPHA;
|
||||
else if (strcmp(str,"SRC_ALPHA_SATURATE")==0) mode = BlendFunc::SRC_ALPHA_SATURATE;
|
||||
else if (strcmp(str,"SRC_COLOR")==0) mode = BlendFunc::SRC_COLOR;
|
||||
else return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
const char* BlendFunc_getModeStr(int value)
|
||||
{
|
||||
switch(value)
|
||||
{
|
||||
case(BlendFunc::DST_ALPHA) : return "DST_ALPHA";
|
||||
case(BlendFunc::DST_COLOR) : return "DST_COLOR";
|
||||
case(BlendFunc::ONE) : return "ONE";
|
||||
case(BlendFunc::ONE_MINUS_DST_ALPHA) : return "ONE_MINUS_DST_ALPHA";
|
||||
case(BlendFunc::ONE_MINUS_DST_COLOR) : return "ONE_MINUS_DST_COLOR";
|
||||
case(BlendFunc::ONE_MINUS_SRC_ALPHA) : return "ONE_MINUS_SRC_ALPHA";
|
||||
case(BlendFunc::ONE_MINUS_SRC_COLOR) : return "ONE_MINUS_SRC_COLOR";
|
||||
case(BlendFunc::SRC_ALPHA) : return "SRC_ALPHA";
|
||||
case(BlendFunc::SRC_ALPHA_SATURATE) : return "SRC_ALPHA_SATURATE";
|
||||
case(BlendFunc::SRC_COLOR) : return "SRC_COLOR";
|
||||
case(BlendFunc::ZERO) : return "ZERO";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ include $(TOPDIR)/Make/makedefs
|
||||
CXXFILES =\
|
||||
AlphaFunc.cpp\
|
||||
Billboard.cpp\
|
||||
BlendFunc.cpp\
|
||||
ClipPlane.cpp\
|
||||
ColorMask.cpp\
|
||||
ConvexPlanerOccluder.cpp\
|
||||
@@ -44,7 +45,7 @@ CXXFILES =\
|
||||
TexMat.cpp\
|
||||
Texture.cpp\
|
||||
Transform.cpp\
|
||||
Transparency.cpp\
|
||||
|
||||
|
||||
LIBS += $(OSG_LIBS) $(OTHER_LIBS)
|
||||
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
#include "osg/Transparency"
|
||||
|
||||
#include "osgDB/Registry"
|
||||
#include "osgDB/Input"
|
||||
#include "osgDB/Output"
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
|
||||
// forward declare functions to use later.
|
||||
bool Transparency_readLocalData(Object& obj, Input& fr);
|
||||
bool Transparency_writeLocalData(const Object& obj, Output& fw);
|
||||
|
||||
bool Transparency_matchModeStr(const char* str,int& mode);
|
||||
const char* Transparency_getModeStr(int value);
|
||||
|
||||
// register the read and write functions with the osgDB::Registry.
|
||||
RegisterDotOsgWrapperProxy g_TransparencyProxy
|
||||
(
|
||||
osgNew osg::Transparency,
|
||||
"Transparency",
|
||||
"Object StateAttribute Transparency",
|
||||
&Transparency_readLocalData,
|
||||
&Transparency_writeLocalData
|
||||
);
|
||||
|
||||
|
||||
bool Transparency_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
Transparency& transparency = static_cast<Transparency&>(obj);
|
||||
|
||||
int mode;
|
||||
if (fr[0].matchWord("source") && Transparency_matchModeStr(fr[1].getStr(),mode))
|
||||
{
|
||||
transparency.setSource(mode);
|
||||
fr+=2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("destination") && Transparency_matchModeStr(fr[1].getStr(),mode))
|
||||
{
|
||||
transparency.setDestination(mode);
|
||||
fr+=2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool Transparency_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const Transparency& transparency = static_cast<const Transparency&>(obj);
|
||||
|
||||
fw.indent() << "source " << Transparency_getModeStr(transparency.getSource()) << std::endl;
|
||||
fw.indent() << "destination " << Transparency_getModeStr(transparency.getDestination()) << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Transparency_matchModeStr(const char* str,int& mode)
|
||||
{
|
||||
if (strcmp(str,"DST_ALPHA")==0) mode = Transparency::DST_ALPHA;
|
||||
else if (strcmp(str,"DST_COLOR")==0) mode = Transparency::DST_COLOR;
|
||||
else if (strcmp(str,"ONE")==0) mode = Transparency::ONE;
|
||||
else if (strcmp(str,"ONE_MINUS_DST_ALPHA")==0) mode = Transparency::ONE_MINUS_DST_ALPHA;
|
||||
else if (strcmp(str,"ONE_MINUS_DST_COLOR")==0) mode = Transparency::ONE_MINUS_DST_COLOR;
|
||||
else if (strcmp(str,"ONE_MINUS_SRC_ALPHA")==0) mode = Transparency::ONE_MINUS_SRC_ALPHA;
|
||||
else if (strcmp(str,"ONE_MINUS_SRC_COLOR")==0) mode = Transparency::ONE_MINUS_SRC_COLOR;
|
||||
else if (strcmp(str,"SRC_ALPHA")==0) mode = Transparency::SRC_ALPHA;
|
||||
else if (strcmp(str,"SRC_ALPHA_SATURATE")==0) mode = Transparency::SRC_ALPHA_SATURATE;
|
||||
else if (strcmp(str,"SRC_COLOR")==0) mode = Transparency::SRC_COLOR;
|
||||
else return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
const char* Transparency_getModeStr(int value)
|
||||
{
|
||||
switch(value)
|
||||
{
|
||||
case(Transparency::DST_ALPHA) : return "DST_ALPHA";
|
||||
case(Transparency::DST_COLOR) : return "DST_COLOR";
|
||||
case(Transparency::ONE) : return "ONE";
|
||||
case(Transparency::ONE_MINUS_DST_ALPHA) : return "ONE_MINUS_DST_ALPHA";
|
||||
case(Transparency::ONE_MINUS_DST_COLOR) : return "ONE_MINUS_DST_COLOR";
|
||||
case(Transparency::ONE_MINUS_SRC_ALPHA) : return "ONE_MINUS_SRC_ALPHA";
|
||||
case(Transparency::ONE_MINUS_SRC_COLOR) : return "ONE_MINUS_SRC_COLOR";
|
||||
case(Transparency::SRC_ALPHA) : return "SRC_ALPHA";
|
||||
case(Transparency::SRC_ALPHA_SATURATE) : return "SRC_ALPHA_SATURATE";
|
||||
case(Transparency::SRC_COLOR) : return "SRC_COLOR";
|
||||
case(Transparency::ZERO) : return "ZERO";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -790,15 +790,15 @@ osg::StateSet* ConvertFromPerformer::visitGeoState(osg::Drawable* osgDrawable,pf
|
||||
}
|
||||
}
|
||||
|
||||
if (inherit & PFSTATE_ENTEXTURE) osgStateSet->setMode(GL_TEXTURE_2D,osg::StateAttribute::INHERIT);
|
||||
if (inherit & PFSTATE_ENTEXTURE) osgStateSet->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::INHERIT);
|
||||
else
|
||||
{
|
||||
int mode = geostate->getMode(PFSTATE_ENTEXTURE);
|
||||
switch(mode)
|
||||
{
|
||||
case(PF_ON): osgStateSet->setMode(GL_TEXTURE_2D,osg::StateAttribute::ON);break;
|
||||
case(PF_ON): osgStateSet->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON);break;
|
||||
case(PF_OFF):
|
||||
default: osgStateSet->setMode(GL_TEXTURE_2D,osg::StateAttribute::OFF);break;
|
||||
default: osgStateSet->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OFF);break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user