OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
controller.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_COMPONENTS_SCENEUTIL_CONTROLLER_H
2 #define OPENMW_COMPONENTS_SCENEUTIL_CONTROLLER_H
3 
4 #include <boost/shared_ptr.hpp>
5 
6 #include <osg/NodeVisitor>
7 
8 namespace SceneUtil
9 {
10 
12  {
13  public:
14  virtual ~ControllerSource() { }
15  virtual float getValue(osg::NodeVisitor* nv) = 0;
16  };
17 
19  {
20  public:
22  virtual float getValue(osg::NodeVisitor* nv);
23  };
24 
27  {
28  public:
29  virtual float calculate(float input) const = 0;
30 
33  virtual float getMaximum() const = 0;
34  };
35 
36  class Controller
37  {
38  public:
39  Controller();
40  virtual ~Controller() {}
41 
42  bool hasInput() const;
43 
44  float getInputValue(osg::NodeVisitor* nv);
45 
46  void setSource(boost::shared_ptr<ControllerSource> source);
47  void setFunction(boost::shared_ptr<ControllerFunction> function);
48 
49  boost::shared_ptr<ControllerSource> getSource() const;
50  boost::shared_ptr<ControllerFunction> getFunction() const;
51 
52  private:
53  boost::shared_ptr<ControllerSource> mSource;
54 
55  // The source value gets passed through this function before it's passed on to the DestValue.
56  boost::shared_ptr<ControllerFunction> mFunction;
57  };
58 
60  class ControllerVisitor : public osg::NodeVisitor
61  {
62  public:
64 
65  virtual void apply(osg::Node& node);
66 
67  virtual void visit(osg::Node& node, Controller& ctrl) = 0;
68  };
69 
71  {
72  public:
74  AssignControllerSourcesVisitor(boost::shared_ptr<ControllerSource> toAssign);
75 
78  virtual void visit(osg::Node& node, Controller& ctrl);
79 
80  private:
81  boost::shared_ptr<ControllerSource> mToAssign;
82  };
83 
86  {
87  public:
89 
90  virtual void visit(osg::Node& , Controller& ctrl);
91 
92  float getMaxLength() const;
93 
94  private:
95  float mMaxLength;
96  };
97 
98 }
99 
100 #endif
FrameTimeSource()
Definition: controller.cpp:49
virtual void visit(osg::Node &node, Controller &ctrl)=0
boost::shared_ptr< ControllerSource > getSource() const
Definition: controller.cpp:39
virtual float getValue(osg::NodeVisitor *nv)
Definition: controller.cpp:53
Finds the maximum of all controller functions in the given scene graph.
Definition: controller.hpp:85
void setSource(boost::shared_ptr< ControllerSource > source)
Definition: controller.cpp:29
virtual void visit(osg::Node &, Controller &ctrl)
Definition: controller.cpp:110
float getMaxLength() const
Definition: controller.cpp:116
FindMaxControllerLengthVisitor()
Definition: controller.cpp:104
void setFunction(boost::shared_ptr< ControllerFunction > function)
Definition: controller.cpp:34
float mMaxLength
Definition: controller.hpp:95
Pure virtual base class - visit() all controllers that are attached as UpdateCallbacks in a scene gra...
Definition: controller.hpp:60
virtual ~Controller()
Definition: controller.hpp:40
virtual float getValue(osg::NodeVisitor *nv)=0
float getInputValue(osg::NodeVisitor *nv)
Definition: controller.cpp:21
Controller()
Definition: controller.cpp:12
virtual void visit(osg::Node &node, Controller &ctrl)
Definition: controller.cpp:98
Definition: controller.hpp:36
virtual float getMaximum() const =0
AssignControllerSourcesVisitor()
Definition: controller.cpp:87
boost::shared_ptr< ControllerFunction > getFunction() const
Definition: controller.cpp:44
boost::shared_ptr< ControllerSource > mSource
Definition: controller.hpp:53
virtual ~ControllerSource()
Definition: controller.hpp:14
ControllerVisitor()
Definition: controller.cpp:58
Definition: controller.hpp:18
boost::shared_ptr< ControllerSource > mToAssign
Definition: controller.hpp:81
boost::shared_ptr< ControllerFunction > mFunction
Definition: controller.hpp:56
Definition: controller.hpp:26
bool hasInput() const
Definition: controller.cpp:16
Definition: controller.hpp:11
virtual float calculate(float input) const =0
Definition: controller.hpp:70
virtual void apply(osg::Node &node)
Definition: controller.cpp:64