2 * Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net>
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.
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.
15#ifndef OSGANIMATION_ANIMATION
16#define OSGANIMATION_ANIMATION 1
19#include <osgAnimation/Export>
20#include <osgAnimation/Channel>
28 class OSGANIMATION_EXPORT Animation : public osg::Object
31 META_Object(osgAnimation, Animation)
34 _duration(0.0), _originalDuration(0.0),
35 _weight(0), _startTime(0), _playmode(LOOP) {}
37 Animation(const osgAnimation::Animation&, const osg::CopyOp&);
47 // addChannel insert the channel and call the computeDuration function
48 void addChannel (Channel* pChannel);
50 // removeChannel remove the channel from channels list and call the computeDuration function
51 void removeChannel (Channel* pChannel);
53 /** Those accessors let you add and remove channels
54 * if you modify something that can change the duration
55 * you are supposed to call computeDuration or setDuration
57 ChannelList& getChannels();
58 const ChannelList& getChannels() const;
60 /** Change the duration of animation
61 * then evaluate the animation in the range 0-duration
62 * it stretch the animation in time.
63 * see computeDuration too
65 void setDuration(double duration);
67 /** Compute duration from channel and keyframes
68 * if the duration is not specified you should
69 * call this method before using it
71 void computeDuration();
72 double getDuration() const;
73 double computeDurationFromChannels() const;
75 void setWeight (float weight);
76 float getWeight() const;
78 bool update (double time, int priority = 0);
81 void setPlayMode (PlayMode mode) { _playmode = mode; }
82 PlayMode getPlayMode() const { return _playmode; }
84 void setStartTime(double time) { _startTime = time;}
85 double getStartTime() const { return _startTime;}
92 double _originalDuration;
96 ChannelList _channels;
100 typedef std::vector<osg::ref_ptr<osgAnimation::Animation> > AnimationList;
101 typedef std::map<std::string, osg::ref_ptr<osgAnimation::Animation> > AnimationMap;