##

Animation.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _ANIMATION_HH_
#define _ANIMATION_HH_
#include <string>
#include <vector>
#include <ignition/math/Spline.hh>
#include <ignition/math/RotationSpline.hh>
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace common
{
class KeyFrame;
class PoseKeyFrame;
class NumericKeyFrame;
class GZ_COMMON_VISIBLE Animation
{
public: Animation(const std::string &_name, double _length, bool _loop);
public: virtual ~Animation();
public: double GetLength() const;
public: void SetLength(double _len);
public: void SetTime(double _time);
public: void AddTime(double _time);
public: double GetTime() const;
public: unsigned int GetKeyFrameCount() const;
public: KeyFrame* GetKeyFrame(unsigned int _index) const;
protected: double GetKeyFramesAtTime(double _time, KeyFrame **_kf1,
KeyFrame **_kf2,
unsigned int &_firstKeyIndex) const;
protected: std::string name;
protected: double length;
protected: double timePos;
protected: mutable bool build;
protected: bool loop;
protected: typedef std::vector<KeyFrame*> KeyFrame_V;
protected: KeyFrame_V keyFrames;
};
class GZ_COMMON_VISIBLE PoseAnimation : public Animation
{
public: PoseAnimation(const std::string &_name,
double _length, bool _loop);
public: virtual ~PoseAnimation();
public: PoseKeyFrame *CreateKeyFrame(double _time);
public: void GetInterpolatedKeyFrame(PoseKeyFrame &_kf) const;
protected: void GetInterpolatedKeyFrame(double _time,
PoseKeyFrame &_kf) const;
protected: void BuildInterpolationSplines() const;
private: mutable ignition::math::Spline *positionSpline;
private: mutable ignition::math::RotationSpline *rotationSpline;
};
class GZ_COMMON_VISIBLE NumericAnimation : public Animation
{
public: NumericAnimation(const std::string &_name,
double _length, bool _loop);
public: virtual ~NumericAnimation();
public: NumericKeyFrame *CreateKeyFrame(double _time);
public: void GetInterpolatedKeyFrame(NumericKeyFrame &_kf) const;
};
}
}
#endif
gazebo::common::Animation::build
bool build
determines if the interpolation splines need building
Definition: Animation.hh:104
gazebo::common::Animation::GetTime
double GetTime() const
Return the current time position.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::common::Animation::keyFrames
KeyFrame_V keyFrames
array of key frames
Definition: Animation.hh:113
gazebo::common::Animation::loop
bool loop
true if animation repeats
Definition: Animation.hh:107
gazebo::common::Animation::~Animation
virtual ~Animation()
Destructor.
gazebo::common::Animation::name
std::string name
animation name
Definition: Animation.hh:95
gazebo::common::Animation::length
double length
animation duration
Definition: Animation.hh:98
gazebo::common::Animation::timePos
double timePos
current time position
Definition: Animation.hh:101
gazebo::common::Animation::GetKeyFrameCount
unsigned int GetKeyFrameCount() const
Return the number of key frames in the animation.
common
common
Definition: FuelModelDatabase.hh:37
gazebo::common::Animation::GetKeyFramesAtTime
double GetKeyFramesAtTime(double _time, KeyFrame **_kf1, KeyFrame **_kf2, unsigned int &_firstKeyIndex) const
Get the two key frames that bound a time value.
gazebo::common::Animation
Manages an animation, which is a collection of keyframes and the ability to interpolate between the k...
Definition: Animation.hh:43
gazebo::common::PoseAnimation::GetInterpolatedKeyFrame
void GetInterpolatedKeyFrame(PoseKeyFrame &_kf) const
Get a keyframe using the animation's current time.
system.hh
gazebo::common::Animation::SetTime
void SetTime(double _time)
Set the current time position of the animation.
gazebo::common::NumericKeyFrame
A keyframe for a NumericAnimation.
Definition: KeyFrame.hh:86
gazebo::common::NumericAnimation::GetInterpolatedKeyFrame
void GetInterpolatedKeyFrame(NumericKeyFrame &_kf) const
Get a keyframe using the animation's current time.
gazebo::common::Animation::Animation
Animation(const std::string &_name, double _length, bool _loop)
Constructor.
gazebo::common::Animation::KeyFrame_V
std::vector< KeyFrame * > KeyFrame_V
array of keyframe type alias
Definition: Animation.hh:110
gazebo::common::Animation::GetKeyFrame
KeyFrame * GetKeyFrame(unsigned int _index) const
Get a key frame using an index value.
gazebo::common::Animation::GetLength
double GetLength() const
Return the duration of the animation.
gazebo::common::PoseAnimation::PoseAnimation
PoseAnimation(const std::string &_name, double _length, bool _loop)
Constructor.
gazebo::common::Animation::AddTime
void AddTime(double _time)
Add time to the animation.
gazebo::common::PoseAnimation
A pose animation.
Definition: Animation.hh:121
gazebo::common::NumericAnimation::NumericAnimation
NumericAnimation(const std::string &_name, double _length, bool _loop)
Constructor.
gazebo::common::NumericAnimation::CreateKeyFrame
NumericKeyFrame * CreateKeyFrame(double _time)
Create a numeric keyframe at the given time.
gazebo::common::Animation::SetLength
void SetLength(double _len)
Set the duration of the animation.
gazebo::common::NumericAnimation::~NumericAnimation
virtual ~NumericAnimation()
Destructor.
gazebo::common::NumericAnimation
A numeric animation.
Definition: Animation.hh:163
gazebo::common::PoseAnimation::CreateKeyFrame
PoseKeyFrame * CreateKeyFrame(double _time)
Create a pose keyframe at the given time.
gazebo::common::PoseAnimation::BuildInterpolationSplines
void BuildInterpolationSplines() const
Update the pose splines.
gazebo::common::PoseAnimation::~PoseAnimation
virtual ~PoseAnimation()
Destructor.
gazebo::common::KeyFrame
A key frame in an animation.
Definition: KeyFrame.hh:35
gazebo::common::PoseKeyFrame
A keyframe for a PoseAnimation.
Definition: KeyFrame.hh:53