Timeline
Go to the documentation of this file.
/* -*-c++-*-
* Copyright (C) 2008 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_TIMELINE
#define OSGANIMATION_TIMELINE 1
#include <osgAnimation/Export>
#include <map>
#include <vector>
#include <osg/observer_ptr>
#include <osg/Notify>
#include <osg/Stats>
#include <osgAnimation/Action>
#include <osgAnimation/FrameAction>
#include <osgAnimation/AnimationManagerBase>
#include <osgAnimation/StatsVisitor>
namespace osgAnimation
{
class OSGANIMATION_EXPORT Timeline : public Action
{
public:
Timeline();
Timeline(const Timeline& nc,const osg::CopyOp& op = osg::CopyOp::SHALLOW_COPY);
META_Action(osgAnimation, Timeline);
enum TimelineStatus
{
Play,
Stop
};
TimelineStatus getStatus() const { return _state; }
typedef std::vector<FrameAction> ActionList;
typedef std::map<int, ActionList> ActionLayers;
const ActionList& getActionLayer(int i) { return _actions[i];}
unsigned int getCurrentFrame() const { return _currentFrame;}
double getCurrentTime() const { return _currentFrame * 1.0 / _fps;}
void play() { _state = Play; }
void gotoFrame(unsigned int frame) { _currentFrame = frame; }
void stop() { _state = Stop; }
bool getEvaluating() const { return _evaluating;}
bool isActive(Action* activeAction);
void removeAction(Action* action);
virtual void addActionAt(unsigned int frame, Action* action, int priority = 0);
virtual void addActionAt(double t, Action* action, int priority = 0);
void addActionNow(Action* action, int priority = 0);
void clearActions();
virtual void update(double simulationTime);
void setLastFrameEvaluated(unsigned int frame) { _previousFrameEvaluated = frame; }
void setEvaluating(bool state) { _evaluating = state;}
void traverse(ActionVisitor& visitor);
void setStats(osg::Stats* stats);
osg::Stats* getStats();
void collectStats(bool state);
osgAnimation::StatsActionVisitor* getStatsVisitor();
const ActionLayers& getActionLayers() const { return _actions; }
void processPendingOperation();
void setAnimationManager(AnimationManagerBase*);
protected:
osg::observer_ptr<AnimationManagerBase> _animationManager;
ActionLayers _actions;
double _lastUpdate;
double _speed;
unsigned int _currentFrame;
unsigned int _previousFrameEvaluated;
bool _initFirstFrame;
TimelineStatus _state;
bool _collectStats;
osg::ref_ptr<osg::Stats> _stats;
osg::ref_ptr<osgAnimation::StatsActionVisitor> _statsVisitor;
// to manage pending operation
bool _evaluating;
struct Command
{
Command():_priority(0) {}
Command(int priority, const FrameAction& action) : _priority(priority), _action(action) {}
int _priority;
FrameAction _action;
};
typedef std::vector<Command> CommandList;
CommandList _addActionOperations;
ActionList _removeActionOperations;
void internalRemoveAction(Action* action);
void internalAddAction(int priority, const FrameAction& ftl);
};
}
#endif
Action
AnimationManagerBase
FrameAction
Notify
StatsVisitor
Stats
osgAnimation::ActionVisitor
Definition ActionVisitor:39
osgAnimation::Action::_fps
unsigned int _fps
Definition Action:130
osgAnimation::Action::Action
Action()
osgAnimation::AnimationManagerBase
Definition AnimationManagerBase:29
osgAnimation::StatsActionVisitor
Definition StatsVisitor:27
osgAnimation::Timeline::_animationManager
osg::observer_ptr< AnimationManagerBase > _animationManager
Definition Timeline:85
osgAnimation::Timeline::_lastUpdate
double _lastUpdate
Definition Timeline:87
osgAnimation::Timeline::getCurrentTime
double getCurrentTime() const
Definition Timeline:53
osgAnimation::Timeline::_currentFrame
unsigned int _currentFrame
Definition Timeline:89
osgAnimation::Timeline::Timeline
Timeline(const Timeline &nc, const osg::CopyOp &op=osg::CopyOp::SHALLOW_COPY)
osgAnimation::Timeline::_speed
double _speed
Definition Timeline:88
osgAnimation::Timeline::addActionAt
virtual void addActionAt(double t, Action *action, int priority=0)
osgAnimation::Timeline::setStats
void setStats(osg::Stats *stats)
osgAnimation::Timeline::removeAction
void removeAction(Action *action)
osgAnimation::Timeline::_statsVisitor
osg::ref_ptr< osgAnimation::StatsActionVisitor > _statsVisitor
Definition Timeline:96
osgAnimation::Timeline::_initFirstFrame
bool _initFirstFrame
Definition Timeline:91
osgAnimation::Timeline::gotoFrame
void gotoFrame(unsigned int frame)
Definition Timeline:56
osgAnimation::Timeline::internalRemoveAction
void internalRemoveAction(Action *action)
osgAnimation::Timeline::_stats
osg::ref_ptr< osg::Stats > _stats
Definition Timeline:95
osgAnimation::Timeline::getStatus
TimelineStatus getStatus() const
Definition Timeline:46
osgAnimation::Timeline::processPendingOperation
void processPendingOperation()
osgAnimation::Timeline::getEvaluating
bool getEvaluating() const
Definition Timeline:58
osgAnimation::Timeline::setAnimationManager
void setAnimationManager(AnimationManagerBase *)
osgAnimation::Timeline::addActionAt
virtual void addActionAt(unsigned int frame, Action *action, int priority=0)
osgAnimation::Timeline::isActive
bool isActive(Action *activeAction)
osgAnimation::Timeline::getActionLayer
const ActionList & getActionLayer(int i)
Definition Timeline:51
osgAnimation::Timeline::ActionList
std::vector< FrameAction > ActionList
Definition Timeline:48
osgAnimation::Timeline::setEvaluating
void setEvaluating(bool state)
Definition Timeline:72
osgAnimation::Timeline::_addActionOperations
CommandList _addActionOperations
Definition Timeline:110
osgAnimation::Timeline::_actions
ActionLayers _actions
Definition Timeline:86
osgAnimation::Timeline::traverse
void traverse(ActionVisitor &visitor)
osgAnimation::Timeline::_previousFrameEvaluated
unsigned int _previousFrameEvaluated
Definition Timeline:90
osgAnimation::Timeline::CommandList
std::vector< Command > CommandList
Definition Timeline:109
osgAnimation::Timeline::META_Action
META_Action(osgAnimation, Timeline)
osgAnimation::Timeline::_removeActionOperations
ActionList _removeActionOperations
Definition Timeline:111
osgAnimation::Timeline::getActionLayers
const ActionLayers & getActionLayers() const
Definition Timeline:80
osgAnimation::Timeline::getStats
osg::Stats * getStats()
osgAnimation::Timeline::_evaluating
bool _evaluating
Definition Timeline:99
osgAnimation::Timeline::clearActions
void clearActions()
osgAnimation::Timeline::play
void play()
Definition Timeline:55
osgAnimation::Timeline::_state
TimelineStatus _state
Definition Timeline:92
osgAnimation::Timeline::collectStats
void collectStats(bool state)
osgAnimation::Timeline::ActionLayers
std::map< int, ActionList > ActionLayers
Definition Timeline:49
osgAnimation::Timeline::getStatsVisitor
osgAnimation::StatsActionVisitor * getStatsVisitor()
osgAnimation::Timeline::update
virtual void update(double simulationTime)
osgAnimation::Timeline::getCurrentFrame
unsigned int getCurrentFrame() const
Definition Timeline:52
osgAnimation::Timeline::_collectStats
bool _collectStats
Definition Timeline:94
osgAnimation::Timeline::stop
void stop()
Definition Timeline:57
osgAnimation::Timeline::internalAddAction
void internalAddAction(int priority, const FrameAction &ftl)
osgAnimation::Timeline::addActionNow
void addActionNow(Action *action, int priority=0)
osgAnimation::Timeline::Timeline
Timeline()
osgAnimation::Timeline::setLastFrameEvaluated
void setLastFrameEvaluated(unsigned int frame)
Definition Timeline:70
osgAnimation::Timeline::TimelineStatus
TimelineStatus
Definition Timeline:41
osgAnimation::Timeline::Play
@ Play
Definition Timeline:42
osgAnimation::Timeline::Stop
@ Stop
Definition Timeline:43
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Stats
Definition Stats:29
osg::observer_ptr
Definition observer_ptr:39
osg::ref_ptr
Definition ref_ptr:32
osgAnimation
Definition Action:34
osgAnimation::FrameAction
std::pair< unsigned int, osg::ref_ptr< Action > > FrameAction
Definition FrameAction:24
observer_ptr
Export
OSGANIMATION_EXPORT
#define OSGANIMATION_EXPORT
Definition osgAnimation/Export:40
osgAnimation::Timeline::Command::Command
Command()
Definition Timeline:103
osgAnimation::Timeline::Command::_action
FrameAction _action
Definition Timeline:106
osgAnimation::Timeline::Command::_priority
int _priority
Definition Timeline:105
osgAnimation::Timeline::Command::Command
Command(int priority, const FrameAction &action)
Definition Timeline:104