OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
statesetupdater.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_COMPONENTS_SCENEUTIL_STATESETCONTROLLER_H
2 #define OPENMW_COMPONENTS_SCENEUTIL_STATESETCONTROLLER_H
3 
4 #include <osg/NodeCallback>
5 
6 namespace SceneUtil
7 {
8 
19  class StateSetUpdater : public osg::NodeCallback
20  {
21  public:
23  StateSetUpdater(const StateSetUpdater& copy, const osg::CopyOp& copyop);
24 
25  META_Object(SceneUtil, StateSetUpdater)
26 
27  virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
28 
32  virtual void apply(osg::StateSet* stateset, osg::NodeVisitor* nv) {}
33 
36  virtual void setDefaults(osg::StateSet* stateset) {}
37 
38  protected:
40  void reset();
41 
42  private:
43  osg::ref_ptr<osg::StateSet> mStateSets[2];
44  };
45 
48  {
49  public:
51  CompositeStateSetUpdater(const CompositeStateSetUpdater& copy, const osg::CopyOp& copyop);
52 
54 
55  unsigned int getNumControllers();
57 
58  void addController(StateSetUpdater* ctrl);
59 
60  virtual void apply(osg::StateSet* stateset, osg::NodeVisitor* nv);
61 
62  protected:
63 
64  virtual void setDefaults(osg::StateSet *stateset);
65 
66  std::vector<osg::ref_ptr<StateSetUpdater> > mCtrls;
67  };
68 
69 }
70 
71 #endif
std::vector< osg::ref_ptr< StateSetUpdater > > mCtrls
Definition: statesetupdater.hpp:66
A variant of the StateSetController that can be made up of multiple controllers all controlling the s...
Definition: statesetupdater.hpp:47
void reset()
Reset mStateSets, forcing a setDefaults() on the next frame. Can be used to change the defaults if ne...
Definition: statesetupdater.cpp:31
void addController(StateSetUpdater *ctrl)
Definition: statesetupdater.cpp:81
Implements efficient per-frame updating of StateSets.
Definition: statesetupdater.hpp:19
virtual void setDefaults(osg::StateSet *stateset)
Definition: statesetupdater.cpp:54
StateSetUpdater * getController(int i)
Definition: statesetupdater.cpp:76
CompositeStateSetUpdater()
Definition: statesetupdater.cpp:60
virtual META_Object(SceneUtil, StateSetUpdater) virtual void operator()(osg apply(osg::StateSet *stateset, osg::NodeVisitor *nv) void
Definition: statesetupdater.hpp:32
virtual void setDefaults(osg::StateSet *stateset)
Definition: statesetupdater.hpp:36
osg::ref_ptr< osg::StateSet > mStateSets[2]
Definition: statesetupdater.hpp:43
StateSetUpdater()
Definition: statesetupdater.cpp:37
META_Object(SceneUtil, CompositeStateSetUpdater) unsigned int getNumControllers()
virtual void apply(osg::StateSet *stateset, osg::NodeVisitor *nv)
Definition: statesetupdater.cpp:48