OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-2014 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 
224  void destroyAllNodeTracks(void);
226  void destroyAllNumericTracks(void);
228  void destroyAllVertexTracks(void);
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 
324  void setInterpolationMode(InterpolationMode im);
325 
330  InterpolationMode getInterpolationMode(void) const;
341  void setRotationInterpolationMode(RotationInterpolationMode im);
342 
347  RotationInterpolationMode getRotationInterpolationMode(void) const;
348 
349  // Methods for setting the defaults
356  static void setDefaultInterpolationMode(InterpolationMode im);
357 
359  static InterpolationMode getDefaultInterpolationMode(void);
360 
367  static void setDefaultRotationInterpolationMode(RotationInterpolationMode im);
368 
370  static RotationInterpolationMode getDefaultRotationInterpolationMode(void);
371 
374 
377 
380 
382  const NodeTrackList& _getNodeTrackList(void) const;
383 
386  { return NodeTrackIterator(mNodeTrackList.begin(), mNodeTrackList.end()); }
387 
389  const NumericTrackList& _getNumericTrackList(void) const;
390 
393  { return NumericTrackIterator(mNumericTrackList.begin(), mNumericTrackList.end()); }
394 
396  const VertexTrackList& _getVertexTrackList(void) const;
397 
400  { return VertexTrackIterator(mVertexTrackList.begin(), mVertexTrackList.end()); }
401 
421  void optimise(bool discardIdentityNodeTracks = true);
422 
425 
433  void _collectIdentityNodeTracks(TrackHandleList& tracks) const;
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;
494  Real getBaseKeyFrameTime() const;
496  const String& getBaseKeyFrameAnimationName() const;
497 
499  void _applyBaseKeyFrame();
500 
501  void _notifyContainer(AnimationContainer* c);
503  AnimationContainer* getContainer();
504 
505  protected:
513 
515 
518 
521 
526  mutable bool mKeyFrameTimesDirty;
527 
532 
533  void optimiseNodeTracks(bool discardIdentityTracks);
534  void optimiseVertexTracks(void);
535 
537  void buildKeyFrameTimeList(void) const;
538  };
539 
542 } // namespace Ogre
543 
544 #include "OgreHeaderSuffix.h"
545 
546 #endif // __Animation_H__
547 
map< unsigned short, NodeAnimationTrack * >::type NodeTrackList
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:260
RotationInterpolationMode
The types of rotational interpolation available.
vector< Real >::type KeyFrameTimeList
Global keyframe time list used to search global keyframe index.
InterpolationMode
The types of animation interpolation available.
Definition: OgreAnimation.h:97
Specialised AnimationTrack for dealing with generic animable values.
NodeTrackList mNodeTrackList
Node tracks, indexed by handle.
Specialised AnimationTrack for dealing with node transforms.
KeyFrameTimeList mKeyFrameTimes
ConstMapIterator< VertexTrackList > VertexTrackIterator
VertexTrackList mVertexTrackList
Vertex tracks, indexed by handle.
std::set< T, P, A > type
map< unsigned short, NumericAnimationTrack * >::type NumericTrackList
Values are interpolated along straight lines.
RotationInterpolationMode mRotationInterpolationMode
InterpolationMode mInterpolationMode
Time index object used to search keyframe at the given position.
Defines an instance of a discrete, movable object based on a Mesh.
Definition: OgreEntity.h:82
static RotationInterpolationMode msDefaultRotationInterpolationMode
NumericTrackIterator getNumericTrackIterator(void) const
Get non-updateable iterator over node tracks.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Specialised AnimationTrack for dealing with changing vertex position information. ...
NodeTrackIterator getNodeTrackIterator(void) const
Get non-updateable iterator over node tracks.
set< ushort >::type TrackHandleList
A list of track handles.
void _keyFrameListChanged(void)
Internal method used to tell the animation that keyframe list has been changed, which may cause it to...
AnimationContainer * mContainer
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
Summary class collecting together vertex source information.
An animation container interface, which allows generic access to sibling animations.
Definition: OgreAnimation.h:58
Values are interpolated linearly.
Concrete IteratorWrapper for const access to the underlying key-value container.
ConstMapIterator< NodeTrackList > NodeTrackIterator
VertexTrackIterator getVertexTrackIterator(void) const
Get non-updateable iterator over node tracks.
String mBaseKeyFrameAnimationName
_StringBase String
NumericTrackList mNumericTrackList
Numeric tracks, indexed by handle.
VertexAnimationType
Type of vertex animation.
vector< float >::type BoneBlendMask
Typedef for an array of float values used as a bone blend mask.
An animation sequence.
Definition: OgreAnimation.h:92
static InterpolationMode msDefaultInterpolationMode
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:64
A collection of Bone objects used to animate a skinned mesh.
Definition: OgreSkeleton.h:87
bool mKeyFrameTimesDirty
Dirty flag indicate that keyframe time list need to rebuild.
map< unsigned short, VertexAnimationTrack * >::type VertexTrackList
ConstMapIterator< NumericTrackList > NumericTrackIterator