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:
@@ -269,6 +269,10 @@ SOURCE=..\..\src\osg\Matrix.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\MatrixTransform.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\MemoryManager.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -377,7 +381,7 @@ SOURCE=..\..\src\osg\Transform.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\Transparency.cpp
|
||||
SOURCE=..\..\src\osg\BlendFunc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -585,6 +589,10 @@ SOURCE=..\..\Include\Osg\Matrix
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\Osg\MatrixTransform
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\osg\mem_ptr
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -729,7 +737,7 @@ SOURCE=..\..\Include\Osg\Transform
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\Osg\Transparency
|
||||
SOURCE=..\..\Include\Osg\BlendFunc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ SOURCE=..\..\..\src\osgPlugins\osg\Transform.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\osg\Transparency.cpp
|
||||
SOURCE=..\..\..\src\osgPlugins\osg\BlendFunc.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
84
include/osg/BlendFunc
Normal file
84
include/osg/BlendFunc
Normal file
@@ -0,0 +1,84 @@
|
||||
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
||||
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
#ifndef OSG_BLENDFUNC
|
||||
#define OSG_BLENDFUNC 1
|
||||
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** BlendFunc - encapsulates the OpenGL blend/transparency state.*/
|
||||
class SG_EXPORT BlendFunc : public StateAttribute
|
||||
{
|
||||
public :
|
||||
|
||||
BlendFunc();
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
BlendFunc(const BlendFunc& trans,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
StateAttribute(trans,copyop),
|
||||
_source_factor(trans._source_factor),
|
||||
_destination_factor(trans._destination_factor) {}
|
||||
|
||||
META_StateAttribute(osg, BlendFunc,BLENDFUNC);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(BlendFunc,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_source_factor)
|
||||
COMPARE_StateAttribute_Parameter(_destination_factor)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual void getAssociatedModes(std::vector<GLMode>& modes) const
|
||||
{
|
||||
modes.push_back(GL_BLEND);
|
||||
}
|
||||
|
||||
enum BlendFuncMode {
|
||||
DST_ALPHA = GL_DST_ALPHA,
|
||||
DST_COLOR = GL_DST_COLOR,
|
||||
ONE = GL_ONE,
|
||||
ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA,
|
||||
ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR,
|
||||
ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA,
|
||||
ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR,
|
||||
SRC_ALPHA = GL_SRC_ALPHA,
|
||||
SRC_ALPHA_SATURATE = GL_SRC_ALPHA_SATURATE,
|
||||
SRC_COLOR = GL_SRC_COLOR,
|
||||
ZERO = GL_ZERO
|
||||
};
|
||||
|
||||
inline void setFunction( const int source, const int destination )
|
||||
{
|
||||
_source_factor = source;
|
||||
_destination_factor = destination;
|
||||
}
|
||||
|
||||
void setSource(const int source) { _source_factor = source; }
|
||||
inline const int getSource() const { return _source_factor; }
|
||||
|
||||
void setDestination(const int destination) { _destination_factor = destination; }
|
||||
inline const int getDestination() const { return _destination_factor; }
|
||||
|
||||
virtual void apply(State& state) const;
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~BlendFunc();
|
||||
|
||||
int _source_factor;
|
||||
int _destination_factor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -50,8 +50,10 @@ class SG_EXPORT BoundingBox
|
||||
_max.set(-FLT_MAX,-FLT_MAX,-FLT_MAX);
|
||||
}
|
||||
|
||||
#ifdef USE_DEPRECATED_API
|
||||
/** deprecated, use valid() instead.*/
|
||||
inline const bool isValid() const { return _max.x()>=_min.x(); }
|
||||
#endif
|
||||
|
||||
inline const bool valid() const
|
||||
{
|
||||
|
||||
@@ -38,9 +38,10 @@ class SG_EXPORT BoundingSphere
|
||||
_radius = -1.0f;
|
||||
}
|
||||
|
||||
#ifdef USE_DEPRECATED_API
|
||||
/** deprecated, use valid() instead.*/
|
||||
inline const bool isValid() const { return _radius>=0.0f; }
|
||||
|
||||
#endif
|
||||
/** return true if the bounding sphere contains valid values,
|
||||
false if the bounding sphere is effectively unset.*/
|
||||
inline const bool valid() const { return _radius>=0.0f; }
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
#ifndef OSG_EXPORT
|
||||
#define OSG_EXPORT 1
|
||||
|
||||
// define used to include in API which is being fazed out
|
||||
// if you can compile your apps with this turned off you are
|
||||
// well placed for compatablity with future versions.
|
||||
#define USE_DEPRECATED_API
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4244 )
|
||||
#pragma warning( disable : 4251 )
|
||||
|
||||
@@ -131,7 +131,7 @@ class SG_EXPORT StateAttribute : public Object
|
||||
TEXGEN,
|
||||
TEXMAT,
|
||||
LIGHTMODEL,
|
||||
TRANSPARENCY,
|
||||
BLENDFUNC,
|
||||
STENCIL,
|
||||
COLORMASK,
|
||||
DEPTH,
|
||||
|
||||
@@ -36,8 +36,9 @@ class SG_EXPORT Transform : public Group
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
Transform(const Transform&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
#ifdef USE_DEPRECATED_API
|
||||
Transform(const Matrix& matix);
|
||||
|
||||
#endif
|
||||
META_Node(osg, Transform);
|
||||
|
||||
enum ReferenceFrame
|
||||
@@ -104,27 +105,59 @@ class SG_EXPORT Transform : public Group
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_DEPRECATED_API
|
||||
|
||||
virtual const bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const
|
||||
{
|
||||
if (_referenceFrame==RELATIVE_TO_ABSOLUTE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else // absolute
|
||||
{
|
||||
matrix.makeIdent();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
virtual const bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const
|
||||
{
|
||||
if (_referenceFrame==RELATIVE_TO_ABSOLUTE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else // absolute
|
||||
{
|
||||
matrix.makeIdent();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
virtual const bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const { return false; }
|
||||
|
||||
#else
|
||||
|
||||
/** Set the transform's matrix.*/
|
||||
void setMatrix(const Matrix& mat) { (*_matrix) = mat; _inverseDirty=true; computeInverse(); dirtyBound(); }
|
||||
void setMatrix(const Matrix& mat) { (*_deprecated_matrix) = mat; _deprecated_inverseDirty=true; computeInverse(); dirtyBound(); }
|
||||
|
||||
/** Get the transform's matrix. */
|
||||
inline const Matrix& getMatrix() const { return *_matrix; }
|
||||
inline const Matrix& getMatrix() const { return *_deprecated_matrix; }
|
||||
|
||||
/** preMult transform.*/
|
||||
void preMult(const Matrix& mat) { _matrix->preMult(mat); _inverseDirty=true; computeInverse(); dirtyBound(); }
|
||||
void preMult(const Matrix& mat) { _deprecated_matrix->preMult(mat); _deprecated_inverseDirty=true; computeInverse(); dirtyBound(); }
|
||||
|
||||
/** postMult transform.*/
|
||||
void postMult(const Matrix& mat) { _matrix->postMult(mat); _inverseDirty=true; computeInverse(); dirtyBound(); }
|
||||
void postMult(const Matrix& mat) { _deprecated_matrix->postMult(mat); _deprecated_inverseDirty=true; computeInverse(); dirtyBound(); }
|
||||
|
||||
virtual const bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const
|
||||
{
|
||||
if (_referenceFrame==RELATIVE_TO_PARENTS)
|
||||
{
|
||||
matrix.preMult(*_matrix);
|
||||
matrix.preMult(*_deprecated_matrix);
|
||||
}
|
||||
else // absolute
|
||||
{
|
||||
matrix = *_matrix;
|
||||
matrix = *_deprecated_matrix;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -133,14 +166,16 @@ class SG_EXPORT Transform : public Group
|
||||
{
|
||||
if (_referenceFrame==RELATIVE_TO_PARENTS)
|
||||
{
|
||||
matrix.postMult(*_inverse);
|
||||
matrix.postMult(*_deprecated_inverse);
|
||||
}
|
||||
else // absolute
|
||||
{
|
||||
matrix = *_inverse;
|
||||
matrix = *_deprecated_inverse;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
protected :
|
||||
|
||||
@@ -152,23 +187,26 @@ class SG_EXPORT Transform : public Group
|
||||
virtual const bool computeBound() const;
|
||||
|
||||
|
||||
inline void computeInverse() const
|
||||
{
|
||||
if (_inverseDirty)
|
||||
{
|
||||
_inverse->invert(*_matrix);
|
||||
_inverseDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ref_ptr<ComputeTransformCallback> _computeTransformCallback;
|
||||
|
||||
ReferenceFrame _referenceFrame;
|
||||
ref_ptr<Matrix> _matrix;
|
||||
mutable ref_ptr<Matrix> _inverse;
|
||||
mutable bool _inverseDirty;
|
||||
|
||||
#ifdef USE_DEPRECATED_API
|
||||
inline void computeInverse() const
|
||||
{
|
||||
if (_deprecated_inverseDirty)
|
||||
{
|
||||
_deprecated_inverse->invert(*_deprecated_matrix);
|
||||
_deprecated_inverseDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
ref_ptr<Matrix> _deprecated_matrix;
|
||||
mutable ref_ptr<Matrix> _deprecated_inverse;
|
||||
mutable bool _deprecated_inverseDirty;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -5,80 +5,13 @@
|
||||
#ifndef OSG_TRANSPARENCY
|
||||
#define OSG_TRANSPARENCY 1
|
||||
|
||||
#include <osg/StateAttribute>
|
||||
#include <osg/BlendFunc>
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** Transparency - encapsulates the OpenGL blend/transparency state.*/
|
||||
class SG_EXPORT Transparency : public StateAttribute
|
||||
{
|
||||
public :
|
||||
|
||||
Transparency();
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
Transparency(const Transparency& trans,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
StateAttribute(trans,copyop),
|
||||
_source_factor(trans._source_factor),
|
||||
_destination_factor(trans._destination_factor) {}
|
||||
|
||||
META_StateAttribute(osg, Transparency,TRANSPARENCY);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(Transparency,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_source_factor)
|
||||
COMPARE_StateAttribute_Parameter(_destination_factor)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual void getAssociatedModes(std::vector<GLMode>& modes) const
|
||||
{
|
||||
modes.push_back(GL_BLEND);
|
||||
}
|
||||
|
||||
enum TransparencyMode {
|
||||
DST_ALPHA = GL_DST_ALPHA,
|
||||
DST_COLOR = GL_DST_COLOR,
|
||||
ONE = GL_ONE,
|
||||
ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA,
|
||||
ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR,
|
||||
ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA,
|
||||
ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR,
|
||||
SRC_ALPHA = GL_SRC_ALPHA,
|
||||
SRC_ALPHA_SATURATE = GL_SRC_ALPHA_SATURATE,
|
||||
SRC_COLOR = GL_SRC_COLOR,
|
||||
ZERO = GL_ZERO
|
||||
};
|
||||
|
||||
inline void setFunction( const int source, const int destination )
|
||||
{
|
||||
_source_factor = source;
|
||||
_destination_factor = destination;
|
||||
}
|
||||
|
||||
void setSource(const int source) { _source_factor = source; }
|
||||
inline const int getSource() const { return _source_factor; }
|
||||
|
||||
void setDestination(const int destination) { _destination_factor = destination; }
|
||||
inline const int getDestination() const { return _destination_factor; }
|
||||
|
||||
virtual void apply(State& state) const;
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~Transparency();
|
||||
|
||||
int _source_factor;
|
||||
int _destination_factor;
|
||||
};
|
||||
|
||||
#ifdef USE_DEPRECATED_API
|
||||
typedef BlendFunc Transparency;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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