Effect
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
//osgFX - Copyright (C) 2003 Marco Jez
#ifndef OSGFX__effect
#define OSGFX__effect
#include <osgFX/Export>
#include <osgFX/Technique>
#include <osg/buffered_value>
#include <osg/ref_ptr>
#include <osg/Node>
#include <osg/Group>
#include <osg/Geode>
#include <osg/OccluderNode>
#include <vector>
#define META_Effect(library, classname, effectname, effectdescription, effectauthor) \
META_Node(library, classname) \
virtual const char *effectName() const { return effectname; } \
virtual const char *effectDescription() const { return effectdescription; } \
virtual const char *effectAuthor() const { return effectauthor; }
namespace osgFX
{
class OSGFX_EXPORT Effect: public osg::Group {
public:
Effect();
Effect(const Effect& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
virtual inline bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Effect*>(obj) != NULL; }
virtual inline const char* libraryName() const { return "osgFX"; }
virtual inline const char* className() const { return "Effect"; }
virtual const char *effectName() const = 0;
virtual const char *effectDescription() const = 0;
virtual const char *effectAuthor() const = 0;
inline bool getEnabled() const;
inline void setEnabled(bool v);
inline virtual void setUpDemo() {}
inline int getNumTechniques() const;
inline Technique* getTechnique(int i);
inline const Technique* getTechnique(int i) const;
inline int getSelectedTechnique() const;
enum TechniqueSelection {
AUTO_DETECT = -1
};
inline void selectTechnique(int i = AUTO_DETECT);
virtual void traverse(osg::NodeVisitor& nv);
inline void inherited_traverse(osg::NodeVisitor& nv);
virtual void resizeGLObjectBuffers(unsigned int maxSize);
virtual void releaseGLObjects(osg::State* state = 0) const;
protected:
virtual ~Effect();
Effect &operator=(const Effect &) { return *this; }
inline void dirtyTechniques();
inline void addTechnique(Technique* tech);
virtual bool define_techniques() = 0;
private:
friend class Validator;
bool _enabled;
typedef std::vector<osg::ref_ptr<Technique> > Technique_list;
Technique_list _techs;
mutable osg::buffered_value<int> _sel_tech;
// use int instead of bool to avoid errors
mutable osg::buffered_value<int> _tech_selected;
int _global_sel_tech;
bool _techs_defined;
osg::ref_ptr<osg::Geode> _dummy_for_validation;
void build_dummy_node();
};
// INLINE METHODS
inline bool Effect::getEnabled() const
{
return _enabled;
}
inline void Effect::setEnabled(bool v)
{
_enabled = v;
}
inline int Effect::getNumTechniques() const
{
return static_cast<int>(_techs.size());
}
inline Technique* Effect::getTechnique(int i)
{
return _techs[i].get();
}
inline const Technique* Effect::getTechnique(int i) const
{
return _techs[i].get();
}
inline int Effect::getSelectedTechnique() const
{
return _global_sel_tech;
}
inline void Effect::selectTechnique(int i)
{
_global_sel_tech = i;
}
inline void Effect::addTechnique(Technique* tech)
{
_techs.push_back(tech);
}
inline void Effect::dirtyTechniques()
{
_techs_defined = false;
}
inline void Effect::inherited_traverse(osg::NodeVisitor& nv)
{
typedef osg::Group inherited;
inherited::traverse(nv);
}
}
#endif
Geode
Group
Node
OccluderNode
Technique
buffered_value
osgFX::Effect::effectAuthor
virtual const char * effectAuthor() const =0
osgFX::Effect::getEnabled
bool getEnabled() const
Definition Effect:167
osgFX::Effect::Effect
Effect(const Effect &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
osgFX::Effect::getTechnique
Technique * getTechnique(int i)
Definition Effect:182
osgFX::Effect::getNumTechniques
int getNumTechniques() const
Definition Effect:177
osgFX::Effect::isSameKindAs
virtual bool isSameKindAs(const osg::Object *obj) const
Definition Effect:71
osgFX::Effect::getSelectedTechnique
int getSelectedTechnique() const
Definition Effect:192
osgFX::Effect::effectDescription
virtual const char * effectDescription() const =0
osgFX::Effect::operator=
Effect & operator=(const Effect &)
Definition Effect:127
osgFX::Effect::setUpDemo
virtual void setUpDemo()
Definition Effect:95
osgFX::Effect::Effect
Effect()
osgFX::Effect::Validator
friend class Validator
Definition Effect:144
osgFX::Effect::effectName
virtual const char * effectName() const =0
osgFX::Effect::dirtyTechniques
void dirtyTechniques()
Definition Effect:207
osgFX::Effect::libraryName
virtual const char * libraryName() const
Definition Effect:72
osgFX::Effect::setEnabled
void setEnabled(bool v)
Definition Effect:172
osgFX::Effect::define_techniques
virtual bool define_techniques()=0
osgFX::Effect::selectTechnique
void selectTechnique(int i=AUTO_DETECT)
Definition Effect:197
osgFX::Effect::resizeGLObjectBuffers
virtual void resizeGLObjectBuffers(unsigned int maxSize)
osgFX::Effect::inherited_traverse
void inherited_traverse(osg::NodeVisitor &nv)
Definition Effect:212
osgFX::Effect::~Effect
virtual ~Effect()
osgFX::Effect::className
virtual const char * className() const
Definition Effect:73
osgFX::Effect::addTechnique
void addTechnique(Technique *tech)
Definition Effect:202
osgFX::Effect::traverse
virtual void traverse(osg::NodeVisitor &nv)
osgFX::Effect::releaseGLObjects
virtual void releaseGLObjects(osg::State *state=0) const
osgFX::Effect::TechniqueSelection
TechniqueSelection
Definition Effect:109
osgFX::Effect::AUTO_DETECT
@ AUTO_DETECT
Definition Effect:110
osgFX::Technique
Definition Technique:57
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Group
Definition Group:29
osg::NodeVisitor
Definition NodeVisitor:82
osg::Object
Definition Object:61
osg::State
Definition State:80
osg::buffered_value
Definition buffered_value:27
osg::ref_ptr
Definition ref_ptr:32
osgFX
Definition AnisotropicLighting:25
Export
OSGFX_EXPORT
#define OSGFX_EXPORT
Definition osgFX/Export:27
NULL
#define NULL
Definition osg/Export:55
ref_ptr