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:
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
|
||||
|
||||
Reference in New Issue
Block a user