2 * Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
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.
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.
15#ifndef OSGANIMATION_ACTIONVISITOR_H
16#define OSGANIMATION_ACTIONVISITOR_H
19#include <osgAnimation/Export>
20#include <osg/Referenced>
21#include <osgAnimation/FrameAction>
30 class ActionAnimation;
31 class ActionStripAnimation;
33#define META_ActionVisitor(library,name) \
34 virtual const char* libraryName() const { return #library; }\
35 virtual const char* className() const { return #name; }
38 class OSGANIMATION_EXPORT ActionVisitor : public osg::Referenced
41 META_ActionVisitor(osgAnimation, ActionVisitor);
43 void traverse(Action& visitor);
45 void pushFrameActionOnStack(const FrameAction& fa);
46 void popFrameAction();
48 void pushTimelineOnStack(Timeline* tm);
51 Timeline* getCurrentTimeline();
52 void setCurrentLayer(int layer) { _currentLayer = layer;}
53 int getCurrentLayer() const { return _currentLayer; }
55 const std::vector<FrameAction>& getStackedFrameAction() const { return _stackFrameAction; }
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);
65 std::vector<FrameAction> _stackFrameAction;
66 std::vector<Timeline*> _stackTimeline;
71 class OSGANIMATION_EXPORT UpdateActionVisitor : public osgAnimation::ActionVisitor
75 unsigned int _currentAnimationPriority;
77 META_ActionVisitor(osgAnimation, UpdateActionVisitor);
78 UpdateActionVisitor();
79 void setFrame(unsigned int frame) { _frame = frame;}
81 bool isActive(Action& action) const;
82 unsigned int getLocalFrame() const;
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);
94 class OSGANIMATION_EXPORT ClearActionVisitor : public osgAnimation::ActionVisitor
102 META_ActionVisitor(osgAnimation, ClearActionVisitor);
103 ClearActionVisitor(ClearType type = BEFORE_FRAME);
104 void setFrame(unsigned int frame) { _frame = frame;}
106 void apply(Timeline& action);
107 void apply(Action& action);
111 std::vector<osg::ref_ptr<Action> > _remove;
112 ClearType _clearType;