OgreAnimation.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __Animation_H__
#define __Animation_H__
#include "OgrePrerequisites.h"
#include "OgreString.h"
#include "OgreIteratorWrappers.h"
#include "OgreAnimable.h"
#include "OgreAnimationTrack.h"
#include "OgreAnimationState.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class Animation;
class _OgreExport AnimationContainer
{
public:
virtual ~AnimationContainer() {}
virtual unsigned short getNumAnimations(void) const = 0;
virtual Animation* getAnimation(unsigned short index) const = 0;
virtual Animation* getAnimation(const String& name) const = 0;
virtual Animation* createAnimation(const String& name, Real length) = 0;
virtual bool hasAnimation(const String& name) const = 0;
virtual void removeAnimation(const String& name) = 0;
};
class _OgreExport Animation : public AnimationAlloc
{
public:
enum InterpolationMode
{
IM_LINEAR,
IM_SPLINE
};
enum RotationInterpolationMode
{
RIM_LINEAR,
RIM_SPHERICAL
};
Animation(const String& name, Real length);
virtual ~Animation();
const String& getName(void) const;
Real getLength(void) const;
void setLength(Real len);
NodeAnimationTrack* createNodeTrack(unsigned short handle);
NumericAnimationTrack* createNumericTrack(unsigned short handle);
VertexAnimationTrack* createVertexTrack(unsigned short handle, VertexAnimationType animType);
NodeAnimationTrack* createNodeTrack(unsigned short handle, Node* node);
NumericAnimationTrack* createNumericTrack(unsigned short handle,
const AnimableValuePtr& anim);
VertexAnimationTrack* createVertexTrack(unsigned short handle,
VertexData* data, VertexAnimationType animType);
unsigned short getNumNodeTracks(void) const;
NodeAnimationTrack* getNodeTrack(unsigned short handle) const;
bool hasNodeTrack(unsigned short handle) const;
unsigned short getNumNumericTracks(void) const;
NumericAnimationTrack* getNumericTrack(unsigned short handle) const;
bool hasNumericTrack(unsigned short handle) const;
unsigned short getNumVertexTracks(void) const;
VertexAnimationTrack* getVertexTrack(unsigned short handle) const;
bool hasVertexTrack(unsigned short handle) const;
void destroyNodeTrack(unsigned short handle);
void destroyNumericTrack(unsigned short handle);
void destroyVertexTrack(unsigned short handle);
void destroyAllTracks(void);
void destroyAllNodeTracks(void);
void destroyAllNumericTracks(void);
void destroyAllVertexTracks(void);
void apply(Real timePos, Real weight = 1.0, Real scale = 1.0f);
void applyToNode(Node* node, Real timePos, Real weight = 1.0, Real scale = 1.0f);
void apply(Skeleton* skeleton, Real timePos, Real weight = 1.0, Real scale = 1.0f);
void apply(Skeleton* skeleton, Real timePos, float weight,
const AnimationState::BoneBlendMask* blendMask, Real scale);
void apply(Entity* entity, Real timePos, Real weight, bool software,
bool hardware);
void applyToAnimable(const AnimableValuePtr& anim, Real timePos, Real weight = 1.0, Real scale = 1.0f);
void applyToVertexData(VertexData* data, Real timePos, Real weight = 1.0);
void setInterpolationMode(InterpolationMode im);
InterpolationMode getInterpolationMode(void) const;
void setRotationInterpolationMode(RotationInterpolationMode im);
RotationInterpolationMode getRotationInterpolationMode(void) const;
// Methods for setting the defaults
static void setDefaultInterpolationMode(InterpolationMode im);
static InterpolationMode getDefaultInterpolationMode(void);
static void setDefaultRotationInterpolationMode(RotationInterpolationMode im);
static RotationInterpolationMode getDefaultRotationInterpolationMode(void);
typedef map<unsigned short, NodeAnimationTrack*>::type NodeTrackList;
typedef ConstMapIterator<NodeTrackList> NodeTrackIterator;
typedef map<unsigned short, NumericAnimationTrack*>::type NumericTrackList;
typedef ConstMapIterator<NumericTrackList> NumericTrackIterator;
typedef map<unsigned short, VertexAnimationTrack*>::type VertexTrackList;
typedef ConstMapIterator<VertexTrackList> VertexTrackIterator;
const NodeTrackList& _getNodeTrackList(void) const;
NodeTrackIterator getNodeTrackIterator(void) const
{ return NodeTrackIterator(mNodeTrackList.begin(), mNodeTrackList.end()); }
const NumericTrackList& _getNumericTrackList(void) const;
NumericTrackIterator getNumericTrackIterator(void) const
{ return NumericTrackIterator(mNumericTrackList.begin(), mNumericTrackList.end()); }
const VertexTrackList& _getVertexTrackList(void) const;
VertexTrackIterator getVertexTrackIterator(void) const
{ return VertexTrackIterator(mVertexTrackList.begin(), mVertexTrackList.end()); }
void optimise(bool discardIdentityNodeTracks = true);
typedef set<ushort>::type TrackHandleList;
void _collectIdentityNodeTracks(TrackHandleList& tracks) const;
void _destroyNodeTracks(const TrackHandleList& tracks);
Animation* clone(const String& newName) const;
void _keyFrameListChanged(void) { mKeyFrameTimesDirty = true; }
TimeIndex _getTimeIndex(Real timePos) const;
void setUseBaseKeyFrame(bool useBaseKeyFrame, Real keyframeTime = 0.0f, const String& baseAnimName = StringUtil::BLANK);
bool getUseBaseKeyFrame() const;
Real getBaseKeyFrameTime() const;
const String& getBaseKeyFrameAnimationName() const;
void _applyBaseKeyFrame();
void _notifyContainer(AnimationContainer* c);
AnimationContainer* getContainer();
protected:
NodeTrackList mNodeTrackList;
NumericTrackList mNumericTrackList;
VertexTrackList mVertexTrackList;
String mName;
Real mLength;
InterpolationMode mInterpolationMode;
RotationInterpolationMode mRotationInterpolationMode;
static InterpolationMode msDefaultInterpolationMode;
static RotationInterpolationMode msDefaultRotationInterpolationMode;
typedef vector<Real>::type KeyFrameTimeList;
mutable KeyFrameTimeList mKeyFrameTimes;
mutable bool mKeyFrameTimesDirty;
bool mUseBaseKeyFrame;
Real mBaseKeyFrameTime;
String mBaseKeyFrameAnimationName;
AnimationContainer* mContainer;
void optimiseNodeTracks(bool discardIdentityTracks);
void optimiseVertexTracks(void);
void buildKeyFrameTimeList(void) const;
};
} // namespace Ogre
#include "OgreHeaderSuffix.h"
#endif // __Animation_H__
Ogre::Animation::NumericTrackList
map< unsigned short, NumericAnimationTrack * >::type NumericTrackList
Definition: OgreAnimation.h:375
Ogre::Animation::msDefaultRotationInterpolationMode
static RotationInterpolationMode msDefaultRotationInterpolationMode
Definition: OgreAnimation.h:520
Ogre::Animation::RotationInterpolationMode
RotationInterpolationMode
The types of rotational interpolation available.
Definition: OgreAnimation.h:106
Ogre::Animation::mContainer
AnimationContainer * mContainer
Definition: OgreAnimation.h:531
Ogre::TimeIndex
Time index object used to search keyframe at the given position.
Definition: OgreAnimationTrack.h:50
Ogre::Animation::getVertexTrackIterator
VertexTrackIterator getVertexTrackIterator(void) const
Get non-updateable iterator over node tracks.
Definition: OgreAnimation.h:399
Ogre::AnimationContainer::~AnimationContainer
virtual ~AnimationContainer()
Definition: OgreAnimation.h:61
OgreAnimable.h
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
OgreAnimationState.h
Ogre::set::type
std::set< T, P, A > type
Definition: OgrePrerequisites.h:522
Ogre::VertexData
Summary class collecting together vertex source information.
Definition: OgreVertexIndexData.h:49
Ogre::Animation::NumericTrackIterator
ConstMapIterator< NumericTrackList > NumericTrackIterator
Definition: OgreAnimation.h:376
Ogre::ConstMapIterator
Concrete IteratorWrapper for const access to the underlying key-value container.
Definition: OgreIteratorWrapper.h:352
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::Animation::mNumericTrackList
NumericTrackList mNumericTrackList
Numeric tracks, indexed by handle.
Definition: OgreAnimation.h:509
OgreString.h
Ogre::AnimationState::BoneBlendMask
vector< float >::type BoneBlendMask
Typedef for an array of float values used as a bone blend mask.
Definition: OgreAnimationState.h:59
Ogre::Skeleton
A collection of Bone objects used to animate a skinned mesh.
Definition: OgreSkeleton.h:87
OgreAnimationTrack.h
Ogre::NumericAnimationTrack
Specialised AnimationTrack for dealing with generic animable values.
Definition: OgreAnimationTrack.h:265
Ogre::AnimationContainer
An animation container interface, which allows generic access to sibling animations.
Definition: OgreAnimation.h:58
Ogre::Animation::NodeTrackIterator
ConstMapIterator< NodeTrackList > NodeTrackIterator
Definition: OgreAnimation.h:373
Ogre::VertexAnimationType
VertexAnimationType
Type of vertex animation.
Definition: OgreAnimationTrack.h:467
OgrePrerequisites.h
Ogre::Animation::mRotationInterpolationMode
RotationInterpolationMode mRotationInterpolationMode
Definition: OgreAnimation.h:517
Ogre::Animation::VertexTrackList
map< unsigned short, VertexAnimationTrack * >::type VertexTrackList
Definition: OgreAnimation.h:378
Ogre::Node
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:64
Ogre::Animation
An animation sequence.
Definition: OgreAnimation.h:92
Ogre::Animation::NodeTrackList
map< unsigned short, NodeAnimationTrack * >::type NodeTrackList
Definition: OgreAnimation.h:372
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::Animation::mInterpolationMode
InterpolationMode mInterpolationMode
Definition: OgreAnimation.h:516
Ogre::Animation::IM_LINEAR
Values are interpolated along straight lines.
Definition: OgreAnimation.h:100
Ogre::Animation::mNodeTrackList
NodeTrackList mNodeTrackList
Node tracks, indexed by handle.
Definition: OgreAnimation.h:507
Ogre::Animation::mLength
Real mLength
Definition: OgreAnimation.h:514
Ogre::Animation::VertexTrackIterator
ConstMapIterator< VertexTrackList > VertexTrackIterator
Definition: OgreAnimation.h:379
OgreHeaderSuffix.h
Ogre::Animation::mBaseKeyFrameTime
Real mBaseKeyFrameTime
Definition: OgreAnimation.h:529
Ogre::Animation::TrackHandleList
set< ushort >::type TrackHandleList
A list of track handles.
Definition: OgreAnimation.h:424
OgreIteratorWrappers.h
Ogre::Animation::mKeyFrameTimesDirty
bool mKeyFrameTimesDirty
Dirty flag indicate that keyframe time list need to rebuild.
Definition: OgreAnimation.h:526
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::Animation::mUseBaseKeyFrame
bool mUseBaseKeyFrame
Definition: OgreAnimation.h:528
Ogre::Animation::getNumericTrackIterator
NumericTrackIterator getNumericTrackIterator(void) const
Get non-updateable iterator over node tracks.
Definition: OgreAnimation.h:392
Ogre::SharedPtr< AnimableValue >
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::Animation::mVertexTrackList
VertexTrackList mVertexTrackList
Vertex tracks, indexed by handle.
Definition: OgreAnimation.h:511
OgreHeaderPrefix.h
Ogre::Animation::mBaseKeyFrameAnimationName
String mBaseKeyFrameAnimationName
Definition: OgreAnimation.h:530
Ogre::Entity
Defines an instance of a discrete, movable object based on a Mesh.
Definition: OgreEntity.h:82
Ogre::Animation::getNodeTrackIterator
NodeTrackIterator getNodeTrackIterator(void) const
Get non-updateable iterator over node tracks.
Definition: OgreAnimation.h:385
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::VertexAnimationTrack
Specialised AnimationTrack for dealing with changing vertex position information. ...
Definition: OgreAnimationTrack.h:480
Ogre::Animation::msDefaultInterpolationMode
static InterpolationMode msDefaultInterpolationMode
Definition: OgreAnimation.h:519
Ogre::Animation::InterpolationMode
InterpolationMode
The types of animation interpolation available.
Definition: OgreAnimation.h:97
Ogre::StringUtil::BLANK
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
Ogre::Animation::KeyFrameTimeList
vector< Real >::type KeyFrameTimeList
Global keyframe time list used to search global keyframe index.
Definition: OgreAnimation.h:523
Ogre::Animation::mKeyFrameTimes
KeyFrameTimeList mKeyFrameTimes
Definition: OgreAnimation.h:524
Ogre::Animation::mName
String mName
Definition: OgreAnimation.h:512
Ogre::NodeAnimationTrack
Specialised AnimationTrack for dealing with node transforms.
Definition: OgreAnimationTrack.h:326
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::Animation::_keyFrameListChanged
void _keyFrameListChanged(void)
Internal method used to tell the animation that keyframe list has been changed, which may cause it to...
Definition: OgreAnimation.h:449
Ogre::Animation::RIM_LINEAR
Values are interpolated linearly.
Definition: OgreAnimation.h:111

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.