OpenSceneGraph/include/osgAnimation/ActionVisitor
Cedric Pinson b6ab5bbe27 From Cedric Pinson, The following modification are
Update Timeline.cpp to add current layer to the ActionVisitor, use correctly the priority
Add accessors in Action.cpp to retrieve protected data
Split files and rename them to classname
Change de default color of UpdateMaterial to FFOOFF to detect unset value
Add accessors in LinkVisitor instead of accessing data directly
Update osganimationtimeline example to fit the api callback
2009-08-31 09:40:56 +00:00

118 lines
3.4 KiB
C++

/* -*-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 BlendIn;
class BlendOut;
class ActionAnimation;
class StripAnimation;
#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(BlendIn& action);
virtual void apply(BlendOut& action);
virtual void apply(ActionAnimation& action);
virtual void apply(StripAnimation& action);
protected:
std::vector<FrameAction> _stackFrameAction;
std::vector<Timeline*> _stackTimeline;
int _currentLayer;
};
class OSGANIMATION_EXPORT UpdateActionVisitor : public osgAnimation::ActionVisitor
{
protected:
unsigned int _frame;
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(BlendIn& action);
void apply(BlendOut& action);
void apply(ActionAnimation& action);
void apply(StripAnimation& 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