ActionVisitor
Go to the documentation of this file.
/* -*-c++-*-
* Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGANIMATION_ACTIONVISITOR_H
#define OSGANIMATION_ACTIONVISITOR_H
#include <vector>
#include <osgAnimation/Export>
#include <osg/Referenced>
#include <osgAnimation/FrameAction>
namespace osgAnimation
{
class Timeline;
class Action;
class ActionBlendIn;
class ActionBlendOut;
class ActionAnimation;
class ActionStripAnimation;
#define META_ActionVisitor(library,name) \
virtual const char* libraryName() const { return #library; }\
virtual const char* className() const { return #name; }
class OSGANIMATION_EXPORT ActionVisitor : public osg::Referenced
{
public:
META_ActionVisitor(osgAnimation, ActionVisitor);
ActionVisitor();
void traverse(Action& visitor);
void pushFrameActionOnStack(const FrameAction& fa);
void popFrameAction();
void pushTimelineOnStack(Timeline* tm);
void popTimeline();
Timeline* getCurrentTimeline();
void setCurrentLayer(int layer) { _currentLayer = layer;}
int getCurrentLayer() const { return _currentLayer; }
const std::vector<FrameAction>& getStackedFrameAction() const { return _stackFrameAction; }
virtual void apply(Action& action);
virtual void apply(Timeline& tm);
virtual void apply(ActionBlendIn& action);
virtual void apply(ActionBlendOut& action);
virtual void apply(ActionAnimation& action);
virtual void apply(ActionStripAnimation& action);
protected:
std::vector<FrameAction> _stackFrameAction;
std::vector<Timeline*> _stackTimeline;
int _currentLayer;
};
class OSGANIMATION_EXPORT UpdateActionVisitor : public osgAnimation::ActionVisitor
{
protected:
unsigned int _frame;
unsigned int _currentAnimationPriority;
public:
META_ActionVisitor(osgAnimation, UpdateActionVisitor);
UpdateActionVisitor();
void setFrame(unsigned int frame) { _frame = frame;}
bool isActive(Action& action) const;
unsigned int getLocalFrame() const;
void apply(Timeline& action);
void apply(Action& action);
void apply(ActionBlendIn& action);
void apply(ActionBlendOut& action);
void apply(ActionAnimation& action);
void apply(ActionStripAnimation& action);
};
class OSGANIMATION_EXPORT ClearActionVisitor : public osgAnimation::ActionVisitor
{
public:
enum ClearType {
BEFORE_FRAME,
AFTER_FRAME
};
META_ActionVisitor(osgAnimation, ClearActionVisitor);
ClearActionVisitor(ClearType type = BEFORE_FRAME);
void setFrame(unsigned int frame) { _frame = frame;}
void apply(Timeline& action);
void apply(Action& action);
protected:
unsigned int _frame;
std::vector<osg::ref_ptr<Action> > _remove;
ClearType _clearType;
};
}
#endif
FrameAction
Referenced
osgAnimation::ActionAnimation
Definition ActionAnimation:26
osgAnimation::ActionBlendIn
blend in from 0 to weight in duration
Definition ActionBlendIn:27
osgAnimation::ActionBlendOut
blend out from weight to 0 in duration
Definition ActionBlendOut:27
osgAnimation::ActionStripAnimation
Definition ActionStripAnimation:30
osgAnimation::ActionVisitor
Definition ActionVisitor:39
osgAnimation::ActionVisitor::apply
virtual void apply(Timeline &tm)
osgAnimation::ActionVisitor::popFrameAction
void popFrameAction()
osgAnimation::ActionVisitor::apply
virtual void apply(ActionStripAnimation &action)
osgAnimation::ActionVisitor::pushTimelineOnStack
void pushTimelineOnStack(Timeline *tm)
osgAnimation::ActionVisitor::apply
virtual void apply(ActionBlendOut &action)
osgAnimation::ActionVisitor::setCurrentLayer
void setCurrentLayer(int layer)
Definition ActionVisitor:52
osgAnimation::ActionVisitor::getStackedFrameAction
const std::vector< FrameAction > & getStackedFrameAction() const
Definition ActionVisitor:55
osgAnimation::ActionVisitor::apply
virtual void apply(ActionAnimation &action)
osgAnimation::ActionVisitor::popTimeline
void popTimeline()
osgAnimation::ActionVisitor::_stackFrameAction
std::vector< FrameAction > _stackFrameAction
Definition ActionVisitor:65
osgAnimation::ActionVisitor::ActionVisitor
ActionVisitor()
osgAnimation::ActionVisitor::_currentLayer
int _currentLayer
Definition ActionVisitor:67
osgAnimation::ActionVisitor::traverse
void traverse(Action &visitor)
osgAnimation::ActionVisitor::getCurrentTimeline
Timeline * getCurrentTimeline()
osgAnimation::ActionVisitor::apply
virtual void apply(Action &action)
osgAnimation::ActionVisitor::META_ActionVisitor
META_ActionVisitor(osgAnimation, ActionVisitor)
osgAnimation::ActionVisitor::_stackTimeline
std::vector< Timeline * > _stackTimeline
Definition ActionVisitor:66
osgAnimation::ActionVisitor::getCurrentLayer
int getCurrentLayer() const
Definition ActionVisitor:53
osgAnimation::ActionVisitor::apply
virtual void apply(ActionBlendIn &action)
osgAnimation::ActionVisitor::pushFrameActionOnStack
void pushFrameActionOnStack(const FrameAction &fa)
osgAnimation::Action
Definition Action:37
osgAnimation::ClearActionVisitor::apply
void apply(Action &action)
osgAnimation::ClearActionVisitor::_clearType
ClearType _clearType
Definition ActionVisitor:112
osgAnimation::ClearActionVisitor::_remove
std::vector< osg::ref_ptr< Action > > _remove
Definition ActionVisitor:111
osgAnimation::ClearActionVisitor::_frame
unsigned int _frame
Definition ActionVisitor:110
osgAnimation::ClearActionVisitor::setFrame
void setFrame(unsigned int frame)
Definition ActionVisitor:104
osgAnimation::ClearActionVisitor::ClearType
ClearType
Definition ActionVisitor:97
osgAnimation::ClearActionVisitor::AFTER_FRAME
@ AFTER_FRAME
Definition ActionVisitor:99
osgAnimation::ClearActionVisitor::BEFORE_FRAME
@ BEFORE_FRAME
Definition ActionVisitor:98
osgAnimation::ClearActionVisitor::apply
void apply(Timeline &action)
osgAnimation::ClearActionVisitor::ClearActionVisitor
ClearActionVisitor(ClearType type=BEFORE_FRAME)
osgAnimation::ClearActionVisitor::META_ActionVisitor
META_ActionVisitor(osgAnimation, ClearActionVisitor)
osgAnimation::Timeline
Definition Timeline:32
osgAnimation::UpdateActionVisitor::UpdateActionVisitor
UpdateActionVisitor()
osgAnimation::UpdateActionVisitor::isActive
bool isActive(Action &action) const
osgAnimation::UpdateActionVisitor::apply
void apply(Action &action)
osgAnimation::UpdateActionVisitor::setFrame
void setFrame(unsigned int frame)
Definition ActionVisitor:79
osgAnimation::UpdateActionVisitor::apply
void apply(ActionStripAnimation &action)
osgAnimation::UpdateActionVisitor::apply
void apply(ActionAnimation &action)
osgAnimation::UpdateActionVisitor::META_ActionVisitor
META_ActionVisitor(osgAnimation, UpdateActionVisitor)
osgAnimation::UpdateActionVisitor::_frame
unsigned int _frame
Definition ActionVisitor:74
osgAnimation::UpdateActionVisitor::_currentAnimationPriority
unsigned int _currentAnimationPriority
Definition ActionVisitor:75
osgAnimation::UpdateActionVisitor::apply
void apply(ActionBlendOut &action)
osgAnimation::UpdateActionVisitor::getLocalFrame
unsigned int getLocalFrame() const
osgAnimation::UpdateActionVisitor::apply
void apply(ActionBlendIn &action)
osgAnimation::UpdateActionVisitor::apply
void apply(Timeline &action)
osg::Referenced
Definition Referenced:44
osgAnimation
Definition Action:34
osgAnimation::FrameAction
std::pair< unsigned int, osg::ref_ptr< Action > > FrameAction
Definition FrameAction:24
Export
OSGANIMATION_EXPORT
#define OSGANIMATION_EXPORT
Definition osgAnimation/Export:40