OGRE  1.9.0
OgreAnimation.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28
29#ifndef __Animation_H__
30#define __Animation_H__
31
32#include "OgrePrerequisites.h"
33#include "OgreString.h"
35#include "OgreAnimable.h"
36#include "OgreAnimationTrack.h"
37#include "OgreAnimationState.h"
38#include "OgreHeaderPrefix.h"
39
40namespace Ogre {
49 class Animation;
50
59 {
60 public:
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
147
156
165 NodeAnimationTrack* createNodeTrack(unsigned short handle, Node* node);
166
173 const AnimableValuePtr& anim);
174
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
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
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
438
445 Animation* clone(const String& newName) const;
446
449 void _keyFrameListChanged(void) { mKeyFrameTimesDirty = true; }
450
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
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
#define _OgreExport
Definition: OgrePlatform.h:260
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
An animation container interface, which allows generic access to sibling animations.
Definition: OgreAnimation.h:59
virtual Animation * getAnimation(unsigned short index) const =0
Retrieve an animation by index.
virtual Animation * createAnimation(const String &name, Real length)=0
Create a new animation with a given length owned by this container.
virtual unsigned short getNumAnimations(void) const =0
Gets the number of animations in this container.
virtual Animation * getAnimation(const String &name) const =0
Retrieve an animation by name.
virtual void removeAnimation(const String &name)=0
Removes an Animation from this container.
virtual bool hasAnimation(const String &name) const =0
Returns whether this object contains the named animation.
vector< float >::type BoneBlendMask
Typedef for an array of float values used as a bone blend mask.
An animation sequence.
Definition: OgreAnimation.h:93
NodeAnimationTrack * getNodeTrack(unsigned short handle) const
Gets a node track by it's handle.
map< unsignedshort, NumericAnimationTrack * >::type NumericTrackList
void _applyBaseKeyFrame()
Internal method to adjust keyframes relative to a base keyframe (.
bool hasNumericTrack(unsigned short handle) const
Does a track exist with the given handle?
VertexAnimationTrack * getVertexTrack(unsigned short handle) const
Gets a Vertex track by it's handle.
void _destroyNodeTracks(const TrackHandleList &tracks)
Internal method for destroy given node tracks.
ConstMapIterator< NodeTrackList > NodeTrackIterator
const NumericTrackList & _getNumericTrackList(void) const
Fast access to NON-UPDATEABLE numeric track list.
bool getUseBaseKeyFrame() const
Whether a base keyframe is being used for this Animation.
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.
const String & getBaseKeyFrameAnimationName() const
If a base keyframe is being used, the Animation that provides that keyframe.
NodeTrackIterator getNodeTrackIterator(void) const
Get non-updateable iterator over node tracks.
static InterpolationMode getDefaultInterpolationMode(void)
Gets the default interpolation mode for all animations.
NumericAnimationTrack * createNumericTrack(unsigned short handle, const AnimableValuePtr &anim)
Creates a NumericAnimationTrack and associates it with an animable.
map< unsignedshort, VertexAnimationTrack * >::type VertexTrackList
bool hasVertexTrack(unsigned short handle) const
Does a track exist with the given handle?
void buildKeyFrameTimeList(void) const
Internal method to build global keyframe time list.
VertexAnimationTrack * createVertexTrack(unsigned short handle, VertexData *data, VertexAnimationType animType)
Creates a VertexAnimationTrack and associates it with VertexData.
NumericAnimationTrack * getNumericTrack(unsigned short handle) const
Gets a numeric track by it's handle.
void destroyAllTracks(void)
Removes and destroys all tracks making up this animation.
const NodeTrackList & _getNodeTrackList(void) const
Fast access to NON-UPDATEABLE node track list.
const VertexTrackList & _getVertexTrackList(void) const
Fast access to NON-UPDATEABLE Vertex track list.
KeyFrameTimeList mKeyFrameTimes
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.
Real getLength(void) const
Gets the total length of the animation.
NodeAnimationTrack * createNodeTrack(unsigned short handle, Node *node)
Creates a new AnimationTrack automatically associated with a Node.
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.
VertexTrackList mVertexTrackList
Vertex tracks, indexed by handle.
NumericTrackIterator getNumericTrackIterator(void) const
Get non-updateable iterator over node tracks.
void destroyAllNodeTracks(void)
Removes and destroys all tracks making up this animation.
static void setDefaultInterpolationMode(InterpolationMode im)
Sets the default animation interpolation mode.
VertexAnimationTrack * createVertexTrack(unsigned short handle, VertexAnimationType animType)
Creates a VertexAnimationTrack for animating vertex position data.
unsigned short getNumVertexTracks(void) const
Gets the number of VertexAnimationTrack objects contained in this animation.
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.
static RotationInterpolationMode getDefaultRotationInterpolationMode(void)
Gets the default rotation interpolation mode for all animations.
void _collectIdentityNodeTracks(TrackHandleList &tracks) const
Internal method for collecting identity node tracks.
void optimise(bool discardIdentityNodeTracks=true)
Optimise an animation by removing unnecessary tracks and keyframes.
ConstMapIterator< VertexTrackList > VertexTrackIterator
vector< Real >::type KeyFrameTimeList
Global keyframe time list used to search global keyframe index.
RotationInterpolationMode mRotationInterpolationMode
void optimiseVertexTracks(void)
NumericTrackList mNumericTrackList
Numeric tracks, indexed by handle.
void _notifyContainer(AnimationContainer *c)
void destroyNodeTrack(unsigned short handle)
Destroys the node track with the given handle.
unsigned short getNumNodeTracks(void) const
Gets the number of NodeAnimationTrack objects contained in this animation.
void optimiseNodeTracks(bool discardIdentityTracks)
void destroyAllVertexTracks(void)
Removes and destroys all tracks making up this animation.
AnimationContainer * mContainer
NodeAnimationTrack * createNodeTrack(unsigned short handle)
Creates a NodeAnimationTrack for animating a Node.
void destroyVertexTrack(unsigned short handle)
Destroys the Vertex track with the given handle.
set< ushort >::type TrackHandleList
A list of track handles.
static void setDefaultRotationInterpolationMode(RotationInterpolationMode im)
Sets the default rotation interpolation mode.
void apply(Real timePos, Real weight=1.0, Real scale=1.0f)
Applies an animation given a specific time point and weight.
const String & getName(void) const
Gets the name of this animation.
void setInterpolationMode(InterpolationMode im)
Tells the animation how to interpolate between keyframes.
virtual ~Animation()
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.
VertexTrackIterator getVertexTrackIterator(void) const
Get non-updateable iterator over node tracks.
InterpolationMode getInterpolationMode(void) const
Gets the current interpolation mode of this animation.
Animation * clone(const String &newName) const
Clone this animation.
NumericAnimationTrack * createNumericTrack(unsigned short handle)
Creates a NumericAnimationTrack for animating any numeric value.
RotationInterpolationMode getRotationInterpolationMode(void) const
Gets the current rotation interpolation mode of this animation.
static RotationInterpolationMode msDefaultRotationInterpolationMode
InterpolationMode
The types of animation interpolation available.
Definition: OgreAnimation.h:98
@ IM_LINEAR
Values are interpolated along straight lines.
void destroyAllNumericTracks(void)
Removes and destroys all tracks making up this animation.
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.
void setLength(Real len)
Sets the length of the animation.
NodeTrackList mNodeTrackList
Node tracks, indexed by handle.
void _keyFrameListChanged(void)
Internal method used to tell the animation that keyframe list has been changed, which may cause it to...
ConstMapIterator< NumericTrackList > NumericTrackIterator
String mBaseKeyFrameAnimationName
TimeIndex _getTimeIndex(Real timePos) const
Internal method used to convert time position to time index object.
map< unsignedshort, NodeAnimationTrack * >::type NodeTrackList
void destroyNumericTrack(unsigned short handle)
Destroys the numeric track with the given handle.
bool mKeyFrameTimesDirty
Dirty flag indicate that keyframe time list need to rebuild.
Animation(const String &name, Real length)
You should not use this constructor directly, use the parent object such as Skeleton instead.
unsigned short getNumNumericTracks(void) const
Gets the number of NumericAnimationTrack objects contained in this animation.
InterpolationMode mInterpolationMode
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.
Real getBaseKeyFrameTime() const
If a base keyframe is being used, the time of that keyframe.
static InterpolationMode msDefaultInterpolationMode
bool hasNodeTrack(unsigned short handle) const
Does a track exist with the given handle?
void setRotationInterpolationMode(RotationInterpolationMode im)
Tells the animation how to interpolate rotations.
AnimationContainer * getContainer()
Retrieve the container of this animation.
RotationInterpolationMode
The types of rotational interpolation available.
@ RIM_LINEAR
Values are interpolated linearly.
Concrete IteratorWrapper for const access to the underlying key-value container.
Defines an instance of a discrete, movable object based on a Mesh.
Definition: OgreEntity.h:83
Specialised AnimationTrack for dealing with node transforms.
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:65
Specialised AnimationTrack for dealing with generic animable values.
A collection of Bone objects used to animate a skinned mesh.
Definition: OgreSkeleton.h:88
Time index object used to search keyframe at the given position.
Specialised AnimationTrack for dealing with changing vertex position information.
Summary class collecting together vertex source information.
VertexAnimationType
Type of vertex animation.
float Real
Software floating point type.
_StringBase String
std::map< K, V, P, A > type
std::set< T, P, A > type
std::vector< T, A > type