OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ActionVisitor.h
Go to the documentation of this file.
1 /* -*-c++-*-
2  * Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
3  *
4  * This library is open source and may be redistributed and/or modified under
5  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
6  * (at your option) any later version. The full license is in LICENSE file
7  * included with this distribution, and on the openscenegraph.org website.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * OpenSceneGraph Public License for more details.
13 */
14 
15 #ifndef OSGANIMATION_ACTIONVISITOR_H
16 #define OSGANIMATION_ACTIONVISITOR_H
17 
18 #include <vector>
19 #include <osgAnimation/Export>
20 #include <osg/Referenced>
21 #include <osgAnimation/FrameAction>
22 
23 namespace osgAnimation
24 {
25 
26  class Timeline;
27  class Action;
28  class ActionBlendIn;
29  class ActionBlendOut;
30  class ActionAnimation;
31  class ActionStripAnimation;
32 
33 #define META_ActionVisitor(library,name) \
34  virtual const char* libraryName() const { return #library; }\
35  virtual const char* className() const { return #name; }
36 
37 
39  {
40  public:
42  ActionVisitor();
43  void traverse(Action& visitor);
44 
45  void pushFrameActionOnStack(const FrameAction& fa);
46  void popFrameAction();
47 
48  void pushTimelineOnStack(Timeline* tm);
49  void popTimeline();
50 
51  Timeline* getCurrentTimeline();
52  void setCurrentLayer(int layer) { _currentLayer = layer;}
53  int getCurrentLayer() const { return _currentLayer; }
54 
55  const std::vector<FrameAction>& getStackedFrameAction() const { return _stackFrameAction; }
56 
57  virtual void apply(Action& action);
58  virtual void apply(Timeline& tm);
59  virtual void apply(ActionBlendIn& action);
60  virtual void apply(ActionBlendOut& action);
61  virtual void apply(ActionAnimation& action);
62  virtual void apply(ActionStripAnimation& action);
63 
64  protected:
65  std::vector<FrameAction> _stackFrameAction;
66  std::vector<Timeline*> _stackTimeline;
68  };
69 
70 
72  {
73  protected:
74  unsigned int _frame;
76  public:
79  void setFrame(unsigned int frame) { _frame = frame;}
80 
81  bool isActive(Action& action) const;
82  unsigned int getLocalFrame() const;
83 
84  void apply(Timeline& action);
85  void apply(Action& action);
86  void apply(ActionBlendIn& action);
87  void apply(ActionBlendOut& action);
88  void apply(ActionAnimation& action);
89  void apply(ActionStripAnimation& action);
90 
91  };
92 
93 
95  {
96  public:
97  enum ClearType {
99  AFTER_FRAME
100  };
101 
103  ClearActionVisitor(ClearType type = BEFORE_FRAME);
104  void setFrame(unsigned int frame) { _frame = frame;}
105 
106  void apply(Timeline& action);
107  void apply(Action& action);
108 
109  protected:
110  unsigned int _frame;
111  std::vector<osg::ref_ptr<Action> > _remove;
113  };
114 
115 }
116 
117 #endif
#define OSGANIMATION_EXPORT
Definition: Export.h:40
std::vector< osg::ref_ptr< Action > > _remove
std::vector< FrameAction > _stackFrameAction
Definition: ActionVisitor.h:65
void setFrame(unsigned int frame)
Definition: ActionVisitor.h:79
void setCurrentLayer(int layer)
Definition: ActionVisitor.h:52
void setFrame(unsigned int frame)
std::pair< unsigned int, osg::ref_ptr< Action > > FrameAction
Definition: FrameAction.h:23
blend in from 0 to weight in duration
Definition: ActionBlendIn.h:26
std::vector< Timeline * > _stackTimeline
Definition: ActionVisitor.h:66
const std::vector< FrameAction > & getStackedFrameAction() const
Definition: ActionVisitor.h:55
#define META_ActionVisitor(library, name)
Definition: ActionVisitor.h:33
blend out from weight to 0 in duration
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: GLU.h:71