OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Animation.h
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_ANIMATION
16 #define OSGANIMATION_ANIMATION 1
17 
18 #include <osg/Object>
19 #include <osgAnimation/Export>
20 #include <osgAnimation/Channel>
21 #include <osg/ref_ptr>
22 #include <vector>
23 #include <map>
24 
25 namespace osgAnimation
26 {
27 
29  {
30  public:
32 
33  Animation() : _duration(0), _weight(0), _startTime(0), _playmode(LOOP) {}
35 
36  enum PlayMode
37  {
41  PPONG
42  };
43 
44  // addChannel insert the channel and call the computeDuration function
45  void addChannel (Channel* pChannel);
46 
51  ChannelList& getChannels();
52  const ChannelList& getChannels() const;
53 
59  void setDuration(double duration);
60 
61 
66  void computeDuration();
67 
68  double getDuration() const;
69 
70 
71  void setWeight (float weight);
72  float getWeight() const;
73 
74  bool update (double time, int priority = 0);
75  void resetTargets();
76 
77  void setPlayMode (PlayMode mode) { _playmode = mode; }
78  PlayMode getPlayMode() const { return _playmode; }
79 
80  void setStartTime(double time) { _startTime = time;}
81  double getStartTime() const { return _startTime;}
82 
83  protected:
84 
85  double computeDurationFromChannels() const;
86 
88 
89  double _duration;
91  float _weight;
92  double _startTime;
95 
96  };
97 
98  typedef std::vector<osg::ref_ptr<osgAnimation::Animation> > AnimationList;
99  typedef std::map<std::string, osg::ref_ptr<osgAnimation::Animation> > AnimationMap;
100 
101 
102 }
103 
104 #endif
double getStartTime() const
Definition: Animation.h:81
#define OSGANIMATION_EXPORT
Definition: Export.h:40
ChannelList _channels
Definition: Animation.h:94
void setStartTime(double time)
Definition: Animation.h:80
PlayMode getPlayMode() const
Definition: Animation.h:78
std::map< std::string, osg::ref_ptr< osgAnimation::Animation > > AnimationMap
Definition: Animation.h:99
std::vector< osg::ref_ptr< osgAnimation::Animation > > AnimationList
Definition: Animation.h:98
std::vector< osg::ref_ptr< osgAnimation::Channel > > ChannelList
Definition: Channel.h:160
void setPlayMode(PlayMode mode)
Definition: Animation.h:77
META_Object(osgAnimation, Animation) Animation()
Definition: Animation.h:31