OgreAnimation.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 
29 #ifndef __Animation_H__
30 #define __Animation_H__
31 
32 #include "OgrePrerequisites.h"
33 #include "OgreString.h"
34 #include "OgreIteratorWrappers.h"
35 #include "OgreAnimable.h"
36 #include "OgreAnimationTrack.h"
37 #include "OgreAnimationState.h"
38 #include "OgreHeaderPrefix.h"
39 
40 namespace Ogre {
49  class Animation;
50 
59  {
60  public:
61  virtual ~AnimationContainer() {}
62 
64  virtual unsigned short getNumAnimations(void) const = 0;
65 
67  virtual Animation* getAnimation(unsigned short index) const = 0;
68 
70  virtual Animation* getAnimation(const String& name) const = 0;
71 
73  virtual Animation* createAnimation(const String& name, Real length) = 0;
74 
76  virtual bool hasAnimation(const String& name) const = 0;
77 
79  virtual void removeAnimation(const String& name) = 0;
80 
81  };
93  {
94 
95  public:
98  {
102  IM_SPLINE
103  };
104 
107  {
115  RIM_SPHERICAL
116  };
121  Animation(const String& name, Real length);
122  virtual ~Animation();
123 
125  const String& getName(void) const;
126 
128  Real getLength(void) const;
129 
134  void setLength(Real len);
135 
140  NodeAnimationTrack* createNodeTrack(unsigned short handle);
141 
146  NumericAnimationTrack* createNumericTrack(unsigned short handle);
147 
155  VertexAnimationTrack* createVertexTrack(unsigned short handle, VertexAnimationType animType);
156 
165  NodeAnimationTrack* createNodeTrack(unsigned short handle, Node* node);
166 
172  NumericAnimationTrack* createNumericTrack(unsigned short handle,
173  const AnimableValuePtr& anim);
174 
181  VertexAnimationTrack* createVertexTrack(unsigned short handle,
182  VertexData* data, VertexAnimationType animType);
183 
185  unsigned short getNumNodeTracks(void) const;
186 
188  NodeAnimationTrack* getNodeTrack(unsigned short handle) const;
189 
191  bool hasNodeTrack(unsigned short handle) const;
192 
194  unsigned short getNumNumericTracks(void) const;
195 
197  NumericAnimationTrack* getNumericTrack(unsigned short handle) const;
198 
200  bool hasNumericTrack(unsigned short handle) const;
201 
203  unsigned short getNumVertexTracks(void) const;
204 
206  VertexAnimationTrack* getVertexTrack(unsigned short handle) const;
207 
209  bool hasVertexTrack(unsigned short handle) const;
210 
212  void destroyNodeTrack(unsigned short handle);
213 
215  void destroyNumericTrack(unsigned short handle);
216 
218  void destroyVertexTrack(unsigned short handle);
219 
221  void destroyAllTracks(void);
222 
229 
240  void apply(Real timePos, Real weight = 1.0, Real scale = 1.0f);
241 
252  void applyToNode(Node* node, Real timePos, Real weight = 1.0, Real scale = 1.0f);
253 
264  void apply(Skeleton* skeleton, Real timePos, Real weight = 1.0, Real scale = 1.0f);
265 
278  void apply(Skeleton* skeleton, Real timePos, float weight,
279  const AnimationState::BoneBlendMask* blendMask, Real scale);
280 
289  void apply(Entity* entity, Real timePos, Real weight, bool software,
290  bool hardware);
291 
301  void applyToAnimable(const AnimableValuePtr& anim, Real timePos, Real weight = 1.0, Real scale = 1.0f);
302 
310  void applyToVertexData(VertexData* data, Real timePos, Real weight = 1.0);
311 
325 
342 
348 
349  // Methods for setting the defaults
357 
360 
368 
371 
374 
377 
380 
382  const NodeTrackList& _getNodeTrackList(void) const;
383 
386  { return NodeTrackIterator(mNodeTrackList.begin(), mNodeTrackList.end()); }
387 
390 
393  { return NumericTrackIterator(mNumericTrackList.begin(), mNumericTrackList.end()); }
394 
397 
400  { return VertexTrackIterator(mVertexTrackList.begin(), mVertexTrackList.end()); }
401 
421  void optimise(bool discardIdentityNodeTracks = true);
422 
425 
434 
437  void _destroyNodeTracks(const TrackHandleList& tracks);
438 
445  Animation* clone(const String& newName) const;
446 
449  void _keyFrameListChanged(void) { mKeyFrameTimesDirty = true; }
450 
461  TimeIndex _getTimeIndex(Real timePos) const;
462 
490  void setUseBaseKeyFrame(bool useBaseKeyFrame, Real keyframeTime = 0.0f, const String& baseAnimName = StringUtil::BLANK);
492  bool getUseBaseKeyFrame() const;
497 
500 
504 
505  protected:
513 
515 
518 
521 
526  mutable bool mKeyFrameTimesDirty;
527 
532 
533  void optimiseNodeTracks(bool discardIdentityTracks);
535 
537  void buildKeyFrameTimeList(void) const;
538  };
539 
542 } // namespace Ogre
543 
544 #include "OgreHeaderSuffix.h"
545 
546 #endif // __Animation_H__
547 
OgreHeaderSuffix.h
Ogre::AnimationContainer::getAnimation
virtual Animation * getAnimation(const String &name) const =0
Retrieve an animation by name.
Ogre::AnimationContainer::~AnimationContainer
virtual ~AnimationContainer()
Definition: OgreAnimation.h:61
Ogre::Animation::getNumericTrackIterator
NumericTrackIterator getNumericTrackIterator(void) const
Get non-updateable iterator over node tracks.
Definition: OgreAnimation.h:392
Ogre::Animation::destroyAllVertexTracks
void destroyAllVertexTracks(void)
Removes and destroys all tracks making up this animation.
Ogre::Animation::getNumericTrack
NumericAnimationTrack * getNumericTrack(unsigned short handle) const
Gets a numeric track by it's handle.
Ogre::Animation::createNumericTrack
NumericAnimationTrack * createNumericTrack(unsigned short handle)
Creates a NumericAnimationTrack for animating any numeric value.
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:59
Ogre
Definition: OgreAndroidLogListener.h:35
Ogre::Animation::applyToVertexData
void applyToVertexData(VertexData *data, Real timePos, Real weight=1.0)
Applies all vertex tracks given a specific time point and weight to the specified vertex data.
Ogre::Animation::InterpolationMode
InterpolationMode
The types of animation interpolation available.
Definition: OgreAnimation.h:98
Ogre::Animation::mBaseKeyFrameAnimationName
String mBaseKeyFrameAnimationName
Definition: OgreAnimation.h:530
Ogre::Animation::destroyAllNumericTracks
void destroyAllNumericTracks(void)
Removes and destroys all tracks making up this animation.
OgreAnimable.h
Ogre::map
Definition: OgrePrerequisites.h:534
Ogre::Animation::getVertexTrack
VertexAnimationTrack * getVertexTrack(unsigned short handle) const
Gets a Vertex track by it's handle.
Ogre::Animation::mName
String mName
Definition: OgreAnimation.h:512
Ogre::Animation::getBaseKeyFrameAnimationName
const String & getBaseKeyFrameAnimationName() const
If a base keyframe is being used, the Animation that provides that keyframe.
Ogre::Animation::setUseBaseKeyFrame
void setUseBaseKeyFrame(bool useBaseKeyFrame, Real keyframeTime=0.0f, const String &baseAnimName=StringUtil::BLANK)
Sets a base keyframe which for the skeletal / pose keyframes in this animation.
Ogre::set::type
std::set< T, P, A > type
Definition: OgrePrerequisites.h:522
Ogre::Animation::getDefaultInterpolationMode
static InterpolationMode getDefaultInterpolationMode(void)
Gets the default interpolation mode for all animations.
Ogre::Animation::getLength
Real getLength(void) const
Gets the total length of the animation.
Ogre::Animation::createVertexTrack
VertexAnimationTrack * createVertexTrack(unsigned short handle, VertexAnimationType animType)
Creates a VertexAnimationTrack for animating vertex position data.
Ogre::VertexAnimationType
VertexAnimationType
Type of vertex animation.
Definition: OgreAnimationTrack.h:468
Ogre::Animation::getInterpolationMode
InterpolationMode getInterpolationMode(void) const
Gets the current interpolation mode of this animation.
Ogre::Animation::getVertexTrackIterator
VertexTrackIterator getVertexTrackIterator(void) const
Get non-updateable iterator over node tracks.
Definition: OgreAnimation.h:399
Ogre::Animation::clone
Animation * clone(const String &newName) const
Clone this animation.
Ogre::NumericAnimationTrack
Specialised AnimationTrack for dealing with generic animable values.
Definition: OgreAnimationTrack.h:266
Ogre::Animation::NumericTrackList
map< unsigned short, NumericAnimationTrack * >::type NumericTrackList
Definition: OgreAnimation.h:375
Ogre::Animation::hasVertexTrack
bool hasVertexTrack(unsigned short handle) const
Does a track exist with the given handle?
Ogre::Animation::NodeTrackIterator
ConstMapIterator< NodeTrackList > NodeTrackIterator
Definition: OgreAnimation.h:373
Ogre::Animation::IM_LINEAR
@ IM_LINEAR
Values are interpolated along straight lines.
Definition: OgreAnimation.h:100
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::Animation::VertexTrackList
map< unsigned short, VertexAnimationTrack * >::type VertexTrackList
Definition: OgreAnimation.h:378
Ogre::Animation::createVertexTrack
VertexAnimationTrack * createVertexTrack(unsigned short handle, VertexData *data, VertexAnimationType animType)
Creates a VertexAnimationTrack and associates it with VertexData.
Ogre::VertexAnimationTrack
Specialised AnimationTrack for dealing with changing vertex position information.
Definition: OgreAnimationTrack.h:481
Ogre::Animation::getNumNumericTracks
unsigned short getNumNumericTracks(void) const
Gets the number of NumericAnimationTrack objects contained in this animation.
Ogre::Animation::getDefaultRotationInterpolationMode
static RotationInterpolationMode getDefaultRotationInterpolationMode(void)
Gets the default rotation interpolation mode for all animations.
Ogre::Animation::~Animation
virtual ~Animation()
Ogre::Animation::mLength
Real mLength
Definition: OgreAnimation.h:514
Ogre::AnimationContainer::hasAnimation
virtual bool hasAnimation(const String &name) const =0
Returns whether this object contains the named animation.
Ogre::Entity
Defines an instance of a discrete, movable object based on a Mesh.
Definition: OgreEntity.h:83
Ogre::AnimationContainer::getAnimation
virtual Animation * getAnimation(unsigned short index) const =0
Retrieve an animation by index.
Ogre::Animation::mNumericTrackList
NumericTrackList mNumericTrackList
Numeric tracks, indexed by handle.
Definition: OgreAnimation.h:509
Ogre::Animation::_getTimeIndex
TimeIndex _getTimeIndex(Real timePos) const
Internal method used to convert time position to time index object.
Ogre::Animation::getUseBaseKeyFrame
bool getUseBaseKeyFrame() const
Whether a base keyframe is being used for this Animation.
Ogre::VertexData
Summary class collecting together vertex source information.
Definition: OgreVertexIndexData.h:50
Ogre::Animation::buildKeyFrameTimeList
void buildKeyFrameTimeList(void) const
Internal method to build global keyframe time list.
Ogre::Animation::setDefaultRotationInterpolationMode
static void setDefaultRotationInterpolationMode(RotationInterpolationMode im)
Sets the default rotation interpolation mode.
Ogre::StringUtil::BLANK
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
OgreHeaderPrefix.h
Ogre::Animation::mNodeTrackList
NodeTrackList mNodeTrackList
Node tracks, indexed by handle.
Definition: OgreAnimation.h:507
Ogre::Animation::mKeyFrameTimesDirty
bool mKeyFrameTimesDirty
Dirty flag indicate that keyframe time list need to rebuild.
Definition: OgreAnimation.h:526
Ogre::Animation::apply
void apply(Real timePos, Real weight=1.0, Real scale=1.0f)
Applies an animation given a specific time point and weight.
Ogre::Animation::hasNodeTrack
bool hasNodeTrack(unsigned short handle) const
Does a track exist with the given handle?
Ogre::Animation::destroyVertexTrack
void destroyVertexTrack(unsigned short handle)
Destroys the Vertex track with the given handle.
Ogre::Animation::VertexTrackIterator
ConstMapIterator< VertexTrackList > VertexTrackIterator
Definition: OgreAnimation.h:379
OgrePrerequisites.h
Ogre::Animation::getName
const String & getName(void) const
Gets the name of this animation.
Ogre::NodeAnimationTrack
Specialised AnimationTrack for dealing with node transforms.
Definition: OgreAnimationTrack.h:327
Ogre::Animation::destroyNodeTrack
void destroyNodeTrack(unsigned short handle)
Destroys the node track with the given handle.
Ogre::Animation::mBaseKeyFrameTime
Real mBaseKeyFrameTime
Definition: OgreAnimation.h:529
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::Animation::createNumericTrack
NumericAnimationTrack * createNumericTrack(unsigned short handle, const AnimableValuePtr &anim)
Creates a NumericAnimationTrack and associates it with an animable.
Ogre::Animation::RIM_LINEAR
@ RIM_LINEAR
Values are interpolated linearly.
Definition: OgreAnimation.h:111
Ogre::Animation::mRotationInterpolationMode
RotationInterpolationMode mRotationInterpolationMode
Definition: OgreAnimation.h:517
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::Animation::getNodeTrackIterator
NodeTrackIterator getNodeTrackIterator(void) const
Get non-updateable iterator over node tracks.
Definition: OgreAnimation.h:385
Ogre::Animation::setRotationInterpolationMode
void setRotationInterpolationMode(RotationInterpolationMode im)
Tells the animation how to interpolate rotations.
Ogre::AnimationContainer::removeAnimation
virtual void removeAnimation(const String &name)=0
Removes an Animation from this container.
Ogre::Animation::Animation
Animation(const String &name, Real length)
You should not use this constructor directly, use the parent object such as Skeleton instead.
Ogre::Animation
An animation sequence.
Definition: OgreAnimation.h:93
OgreAnimationTrack.h
Ogre::Animation::_getNodeTrackList
const NodeTrackList & _getNodeTrackList(void) const
Fast access to NON-UPDATEABLE node track list.
Ogre::Animation::mVertexTrackList
VertexTrackList mVertexTrackList
Vertex tracks, indexed by handle.
Definition: OgreAnimation.h:511
Ogre::Animation::msDefaultInterpolationMode
static InterpolationMode msDefaultInterpolationMode
Definition: OgreAnimation.h:519
Ogre::Animation::destroyNumericTrack
void destroyNumericTrack(unsigned short handle)
Destroys the numeric track with the given handle.
Ogre::SharedPtr< AnimableValue >
Ogre::Animation::applyToAnimable
void applyToAnimable(const AnimableValuePtr &anim, Real timePos, Real weight=1.0, Real scale=1.0f)
Applies all numeric tracks given a specific time point and weight to the specified animable value.
Ogre::Animation::createNodeTrack
NodeAnimationTrack * createNodeTrack(unsigned short handle, Node *node)
Creates a new AnimationTrack automatically associated with a Node.
OgreAnimationState.h
Ogre::Animation::_getNumericTrackList
const NumericTrackList & _getNumericTrackList(void) const
Fast access to NON-UPDATEABLE numeric track list.
OgreIteratorWrappers.h
Ogre::Animation::getBaseKeyFrameTime
Real getBaseKeyFrameTime() const
If a base keyframe is being used, the time of that keyframe.
Ogre::Skeleton
A collection of Bone objects used to animate a skinned mesh.
Definition: OgreSkeleton.h:88
Ogre::Animation::KeyFrameTimeList
vector< Real >::type KeyFrameTimeList
Global keyframe time list used to search global keyframe index.
Definition: OgreAnimation.h:523
Ogre::Animation::getNumVertexTracks
unsigned short getNumVertexTracks(void) const
Gets the number of VertexAnimationTrack objects contained in this animation.
Ogre::Animation::mKeyFrameTimes
KeyFrameTimeList mKeyFrameTimes
Definition: OgreAnimation.h:524
Ogre::Animation::_notifyContainer
void _notifyContainer(AnimationContainer *c)
Ogre::Animation::destroyAllNodeTracks
void destroyAllNodeTracks(void)
Removes and destroys all tracks making up this animation.
Ogre::Animation::destroyAllTracks
void destroyAllTracks(void)
Removes and destroys all tracks making up this animation.
Ogre::Animation::getContainer
AnimationContainer * getContainer()
Retrieve the container of this animation.
Ogre::Animation::optimiseNodeTracks
void optimiseNodeTracks(bool discardIdentityTracks)
Ogre::Animation::RotationInterpolationMode
RotationInterpolationMode
The types of rotational interpolation available.
Definition: OgreAnimation.h:107
Ogre::Animation::apply
void apply(Skeleton *skeleton, Real timePos, Real weight=1.0, Real scale=1.0f)
Applies all node tracks given a specific time point and weight to a given skeleton.
Ogre::Animation::optimise
void optimise(bool discardIdentityNodeTracks=true)
Optimise an animation by removing unnecessary tracks and keyframes.
Ogre::Animation::_applyBaseKeyFrame
void _applyBaseKeyFrame()
Internal method to adjust keyframes relative to a base keyframe (.
Ogre::Animation::_destroyNodeTracks
void _destroyNodeTracks(const TrackHandleList &tracks)
Internal method for destroy given node tracks.
Ogre::Animation::NodeTrackList
map< unsigned short, NodeAnimationTrack * >::type NodeTrackList
Definition: OgreAnimation.h:372
Ogre::AnimationContainer::createAnimation
virtual Animation * createAnimation(const String &name, Real length)=0
Create a new animation with a given length owned by this container.
Ogre::Animation::_getVertexTrackList
const VertexTrackList & _getVertexTrackList(void) const
Fast access to NON-UPDATEABLE Vertex track list.
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::Animation::mInterpolationMode
InterpolationMode mInterpolationMode
Definition: OgreAnimation.h:516
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::ConstMapIterator
Concrete IteratorWrapper for const access to the underlying key-value container.
Definition: OgreIteratorWrapper.h:352
Ogre::Animation::hasNumericTrack
bool hasNumericTrack(unsigned short handle) const
Does a track exist with the given handle?
Ogre::Animation::getNodeTrack
NodeAnimationTrack * getNodeTrack(unsigned short handle) const
Gets a node track by it's handle.
Ogre::AnimationContainer::getNumAnimations
virtual unsigned short getNumAnimations(void) const =0
Gets the number of animations in this container.
Ogre::Animation::msDefaultRotationInterpolationMode
static RotationInterpolationMode msDefaultRotationInterpolationMode
Definition: OgreAnimation.h:520
Ogre::Animation::apply
void apply(Skeleton *skeleton, Real timePos, float weight, const AnimationState::BoneBlendMask *blendMask, Real scale)
Applies all node tracks given a specific time point and weight to a given skeleton.
Ogre::Node
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:65
Ogre::Animation::mContainer
AnimationContainer * mContainer
Definition: OgreAnimation.h:531
OgreString.h
Ogre::Animation::getRotationInterpolationMode
RotationInterpolationMode getRotationInterpolationMode(void) const
Gets the current rotation interpolation mode of this animation.
Ogre::vector
Definition: OgrePrerequisites.h:492
Ogre::Animation::applyToNode
void applyToNode(Node *node, Real timePos, Real weight=1.0, Real scale=1.0f)
Applies all node tracks given a specific time point and weight to the specified node.
Ogre::Animation::_collectIdentityNodeTracks
void _collectIdentityNodeTracks(TrackHandleList &tracks) const
Internal method for collecting identity node tracks.
Ogre::Animation::getNumNodeTracks
unsigned short getNumNodeTracks(void) const
Gets the number of NodeAnimationTrack objects contained in this animation.
Ogre::Animation::setLength
void setLength(Real len)
Sets the length of the animation.
Ogre::Animation::optimiseVertexTracks
void optimiseVertexTracks(void)
Ogre::TimeIndex
Time index object used to search keyframe at the given position.
Definition: OgreAnimationTrack.h:51
Ogre::Animation::NumericTrackIterator
ConstMapIterator< NumericTrackList > NumericTrackIterator
Definition: OgreAnimation.h:376
Ogre::Animation::TrackHandleList
set< ushort >::type TrackHandleList
A list of track handles.
Definition: OgreAnimation.h:424
Ogre::Animation::apply
void apply(Entity *entity, Real timePos, Real weight, bool software, bool hardware)
Applies all vertex tracks given a specific time point and weight to a given entity.
Ogre::Animation::setInterpolationMode
void setInterpolationMode(InterpolationMode im)
Tells the animation how to interpolate between keyframes.
Ogre::Animation::createNodeTrack
NodeAnimationTrack * createNodeTrack(unsigned short handle)
Creates a NodeAnimationTrack for animating a Node.
Ogre::Animation::setDefaultInterpolationMode
static void setDefaultInterpolationMode(InterpolationMode im)
Sets the default animation interpolation mode.
Ogre::Animation::mUseBaseKeyFrame
bool mUseBaseKeyFrame
Definition: OgreAnimation.h:528
Ogre::AnimationContainer
An animation container interface, which allows generic access to sibling animations.
Definition: OgreAnimation.h:59

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