root/OpenSceneGraph/trunk/include/osgAnimation/ActionVisitor @ 13041

Revision 13041, 3.5 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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
23namespace 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
38    class OSGANIMATION_EXPORT ActionVisitor : public osg::Referenced
39    {
40    public:
41        META_ActionVisitor(osgAnimation, ActionVisitor);
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;
67        int _currentLayer;
68    };
69
70
71    class OSGANIMATION_EXPORT UpdateActionVisitor : public osgAnimation::ActionVisitor
72    {
73    protected:
74        unsigned int _frame;
75        unsigned int _currentAnimationPriority;
76    public:
77        META_ActionVisitor(osgAnimation, UpdateActionVisitor);
78        UpdateActionVisitor();
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
94    class OSGANIMATION_EXPORT ClearActionVisitor : public osgAnimation::ActionVisitor
95    {
96    public:
97        enum ClearType {
98            BEFORE_FRAME,
99            AFTER_FRAME
100        };
101
102        META_ActionVisitor(osgAnimation, ClearActionVisitor);
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;
112        ClearType _clearType;
113    };
114
115}
116
117#endif
Note: See TracBrowser for help on using the browser.