OpenSceneGraph 3.6.5
Timeline
Go to the documentation of this file.
1/* -*-c++-*-
2 * Copyright (C) 2008 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_TIMELINE
16#define OSGANIMATION_TIMELINE 1
17
18#include <osgAnimation/Export>
19#include <map>
20#include <vector>
21#include <osg/observer_ptr>
22#include <osg/Notify>
23#include <osg/Stats>
24#include <osgAnimation/Action>
28
29namespace osgAnimation
30{
32 {
33 public:
34
37
39
41 {
44 };
45
46 TimelineStatus getStatus() const { return _state; }
47
48 typedef std::vector<FrameAction> ActionList;
49 typedef std::map<int, ActionList> ActionLayers;
50
51 const ActionList& getActionLayer(int i) { return _actions[i];}
52 unsigned int getCurrentFrame() const { return _currentFrame;}
53 double getCurrentTime() const { return _currentFrame * 1.0 / _fps;}
54
55 void play() { _state = Play; }
56 void gotoFrame(unsigned int frame) { _currentFrame = frame; }
57 void stop() { _state = Stop; }
58 bool getEvaluating() const { return _evaluating;}
59
60 bool isActive(Action* activeAction);
61
62 void removeAction(Action* action);
63 virtual void addActionAt(unsigned int frame, Action* action, int priority = 0);
64 virtual void addActionAt(double t, Action* action, int priority = 0);
65 void addActionNow(Action* action, int priority = 0);
66
68
69 virtual void update(double simulationTime);
70 void setLastFrameEvaluated(unsigned int frame) { _previousFrameEvaluated = frame; }
71
72 void setEvaluating(bool state) { _evaluating = state;}
73 void traverse(ActionVisitor& visitor);
74
75 void setStats(osg::Stats* stats);
77 void collectStats(bool state);
79
80 const ActionLayers& getActionLayers() const { return _actions; }
81
84 protected:
88 double _speed;
89 unsigned int _currentFrame;
93
97
98 // to manage pending operation
100
101 struct Command
102 {
104 Command(int priority, const FrameAction& action) : _priority(priority), _action(action) {}
107 };
108
109 typedef std::vector<Command> CommandList;
112
114 void internalAddAction(int priority, const FrameAction& ftl);
115
116 };
117
118
119
120}
121
122#endif
The osgAnimation library provides general purpose utility classes for animation.
Definition Action:34
std::pair< unsigned int, osg::ref_ptr< Action > > FrameAction
Definition FrameAction:24
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Smart pointer for observed objects, that automatically set pointers to them to null when they are del...
Definition observer_ptr:39
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Definition Stats:29
unsigned int _fps
Definition Action:130
Definition ActionVisitor:39
Definition AnimationManagerBase:29
Definition StatsVisitor:27
osg::observer_ptr< AnimationManagerBase > _animationManager
Definition Timeline:85
double _lastUpdate
Definition Timeline:87
double getCurrentTime() const
Definition Timeline:53
unsigned int _currentFrame
Definition Timeline:89
Timeline(const Timeline &nc, const osg::CopyOp &op=osg::CopyOp::SHALLOW_COPY)
double _speed
Definition Timeline:88
virtual void addActionAt(double t, Action *action, int priority=0)
void setStats(osg::Stats *stats)
void removeAction(Action *action)
osg::ref_ptr< osgAnimation::StatsActionVisitor > _statsVisitor
Definition Timeline:96
bool _initFirstFrame
Definition Timeline:91
void gotoFrame(unsigned int frame)
Definition Timeline:56
void internalRemoveAction(Action *action)
osg::ref_ptr< osg::Stats > _stats
Definition Timeline:95
TimelineStatus getStatus() const
Definition Timeline:46
bool getEvaluating() const
Definition Timeline:58
void setAnimationManager(AnimationManagerBase *)
virtual void addActionAt(unsigned int frame, Action *action, int priority=0)
bool isActive(Action *activeAction)
const ActionList & getActionLayer(int i)
Definition Timeline:51
std::vector< FrameAction > ActionList
Definition Timeline:48
void setEvaluating(bool state)
Definition Timeline:72
CommandList _addActionOperations
Definition Timeline:110
ActionLayers _actions
Definition Timeline:86
void traverse(ActionVisitor &visitor)
unsigned int _previousFrameEvaluated
Definition Timeline:90
std::vector< Command > CommandList
Definition Timeline:109
META_Action(osgAnimation, Timeline)
ActionList _removeActionOperations
Definition Timeline:111
const ActionLayers & getActionLayers() const
Definition Timeline:80
osg::Stats * getStats()
bool _evaluating
Definition Timeline:99
void play()
Definition Timeline:55
TimelineStatus _state
Definition Timeline:92
void collectStats(bool state)
std::map< int, ActionList > ActionLayers
Definition Timeline:49
osgAnimation::StatsActionVisitor * getStatsVisitor()
virtual void update(double simulationTime)
unsigned int getCurrentFrame() const
Definition Timeline:52
bool _collectStats
Definition Timeline:94
void stop()
Definition Timeline:57
void internalAddAction(int priority, const FrameAction &ftl)
void addActionNow(Action *action, int priority=0)
void setLastFrameEvaluated(unsigned int frame)
Definition Timeline:70
TimelineStatus
Definition Timeline:41
@ Play
Definition Timeline:42
@ Stop
Definition Timeline:43
Command()
Definition Timeline:103
FrameAction _action
Definition Timeline:106
int _priority
Definition Timeline:105
Command(int priority, const FrameAction &action)
Definition Timeline:104
#define OSGANIMATION_EXPORT
Definition Export:40

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.