OGRE  2.0
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 "OgreIteratorWrappers.h"
34 #include "OgreAnimationTrack.h"
35 #include "OgreAnimationState.h"
36 #include "OgreHeaderPrefix.h"
37 
38 namespace Ogre {
47  class Animation;
48 
57  {
58  public:
59  virtual ~AnimationContainer() {}
60 
62  virtual unsigned short getNumAnimations(void) const = 0;
63 
65  virtual Animation* getAnimation(unsigned short index) const = 0;
66 
68  virtual Animation* getAnimation(const String& name) const = 0;
69 
71  virtual Animation* createAnimation(const String& name, Real length) = 0;
72 
74  virtual bool hasAnimation(const String& name) const = 0;
75 
77  virtual void removeAnimation(const String& name) = 0;
78 
79  };
91  {
92 
93  public:
96  {
100  IM_SPLINE
101  };
102 
105  {
113  RIM_SPHERICAL
114  };
119  Animation(const String& name, Real length);
120  virtual ~Animation();
121 
123  const String& getName(void) const;
124 
126  Real getLength(void) const;
127 
132  void setLength(Real len);
133 
138  NodeAnimationTrack* createNodeTrack(void);
139 
144  OldNodeAnimationTrack* createOldNodeTrack(unsigned short handle);
145 
150  NumericAnimationTrack* createNumericTrack(unsigned short handle);
151 
159  VertexAnimationTrack* createVertexTrack(unsigned short handle, VertexAnimationType animType);
160 
169  NodeAnimationTrack* createNodeTrack(Node* node);
170 
179  OldNodeAnimationTrack* createOldNodeTrack(unsigned short handle, OldNode* node);
180 
186  NumericAnimationTrack* createNumericTrack(unsigned short handle,
187  const AnimableValuePtr& anim);
188 
195  VertexAnimationTrack* createVertexTrack(unsigned short handle,
196  VertexData* data, VertexAnimationType animType);
197 
199  size_t getNumNodeTracks(void) const;
200 
202  NodeAnimationTrack* getNodeTrack( size_t handle ) const;
203 
205  size_t getNumOldNodeTracks(void) const;
206 
208  OldNodeAnimationTrack* getOldNodeTrack(unsigned short handle) const;
209 
211  bool hasOldNodeTrack(unsigned short handle) const;
212 
214  unsigned short getNumNumericTracks(void) const;
215 
217  NumericAnimationTrack* getNumericTrack(unsigned short handle) const;
218 
220  bool hasNumericTrack(unsigned short handle) const;
221 
223  unsigned short getNumVertexTracks(void) const;
224 
226  VertexAnimationTrack* getVertexTrack(unsigned short handle) const;
227 
229  bool hasVertexTrack(unsigned short handle) const;
230 
232  void destroyOldNodeTrack(unsigned short handle);
233 
235  void destroyNumericTrack(unsigned short handle);
236 
238  void destroyVertexTrack(unsigned short handle);
239 
241  void destroyAllTracks(void);
242 
244  void destroyAllNodeTracks(void);
245  void destroyAllOldNodeTracks(void);
247  void destroyAllNumericTracks(void);
249  void destroyAllVertexTracks(void);
250 
261  void apply(Real timePos, Real weight = 1.0, Real scale = 1.0f);
262 
273  void applyToNode(OldNode* node, Real timePos, Real weight = 1.0, Real scale = 1.0f);
274 
285  void apply(Skeleton* skeleton, Real timePos, Real weight = 1.0, Real scale = 1.0f);
286 
299  void apply(Skeleton* skeleton, Real timePos, float weight,
300  const AnimationState::BoneBlendMask* blendMask, Real scale);
301 
310  void apply(Entity* entity, Real timePos, Real weight, bool software,
311  bool hardware);
312 
322  void applyToAnimable(const AnimableValuePtr& anim, Real timePos, Real weight = 1.0, Real scale = 1.0f);
323 
331  void applyToVertexData(VertexData* data, Real timePos, Real weight = 1.0);
332 
345  void setInterpolationMode(InterpolationMode im);
346 
351  InterpolationMode getInterpolationMode(void) const;
362  void setRotationInterpolationMode(RotationInterpolationMode im);
363 
368  RotationInterpolationMode getRotationInterpolationMode(void) const;
369 
370  // Methods for setting the defaults
377  static void setDefaultInterpolationMode(InterpolationMode im);
378 
380  static InterpolationMode getDefaultInterpolationMode(void);
381 
388  static void setDefaultRotationInterpolationMode(RotationInterpolationMode im);
389 
391  static RotationInterpolationMode getDefaultRotationInterpolationMode(void);
392 
395 
398 
401 
404 
406  const NodeTrackList& _getNodeTrackList(void) const;
408  const OldNodeTrackList& _getOldNodeTrackList(void) const;
409 
412  { return NodeTrackIterator(mNodeTrackList.begin(), mNodeTrackList.end()); }
413 
416  { return OldNodeTrackIterator(mOldNodeTrackList.begin(), mOldNodeTrackList.end()); }
417 
419  const NumericTrackList& _getNumericTrackList(void) const;
420 
423  { return NumericTrackIterator(mNumericTrackList.begin(), mNumericTrackList.end()); }
424 
426  const VertexTrackList& _getVertexTrackList(void) const;
427 
430  { return VertexTrackIterator(mVertexTrackList.begin(), mVertexTrackList.end()); }
431 
451  void optimise(bool discardIdentityNodeTracks = true);
452 
455 
463  void _collectIdentityOldNodeTracks(TrackHandleList& tracks) const;
464 
467  void _destroyOldNodeTracks(const TrackHandleList& tracks);
468 
475  Animation* clone(const String& newName) const;
476 
479  void _keyFrameListChanged(void) { mKeyFrameTimesDirty = true; }
480 
491  TimeIndex _getTimeIndex(Real timePos) const;
492 
520  void setUseBaseKeyFrame(bool useBaseKeyFrame, Real keyframeTime = 0.0f, const String& baseAnimName = BLANKSTRING);
522  bool getUseBaseKeyFrame() const;
524  Real getBaseKeyFrameTime() const;
526  const String& getBaseKeyFrameAnimationName() const;
527 
529  void _applyBaseKeyFrame();
530 
531  void _notifyContainer(AnimationContainer* c);
533  AnimationContainer* getContainer();
534 
535  protected:
545 
547 
550 
553 
558  mutable bool mKeyFrameTimesDirty;
559 
564 
565  void optimiseOldNodeTracks(bool discardIdentityTracks);
566  void optimiseVertexTracks(void);
567 
569  void buildKeyFrameTimeList(void) const;
570  };
571 
574 } // namespace Ogre
575 
576 #include "OgreHeaderSuffix.h"
577 
578 #endif // __Animation_H__
579 
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:255
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:95
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
const String BLANKSTRING
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreCommon.h:574
VertexTrackList mVertexTrackList
Vertex tracks, indexed by handle.
std::set< T, P, A > type
Class representing a general-purpose OldNode an articulated scene graph.
Definition: OgreOldNode.h:63
map< unsigned short, NumericAnimationTrack * >::type NumericTrackList
Values are interpolated along straight lines.
Definition: OgreAnimation.h:98
RotationInterpolationMode mRotationInterpolationMode
InterpolationMode mInterpolationMode
Time index object used to search keyframe at the given position.
map< unsigned short, OldNodeAnimationTrack * >::type OldNodeTrackList
Defines an instance of a discrete, movable object based on a Mesh.
Definition: OgreEntity.h:81
Concrete IteratorWrapper for const access to the underlying container.
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...
ConstMapIterator< OldNodeTrackList > OldNodeTrackIterator
Specialised AnimationTrack for dealing with changing vertex position information. ...
NodeTrackIterator getNodeTrackIterator(void) const
Get non-updateable iterator over node tracks.
vector< NodeAnimationTrack * >::type NodeTrackList
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
Summary class collecting together vertex source information.
ConstVectorIterator< NodeTrackList > NodeTrackIterator
An animation container interface, which allows generic access to sibling animations.
Definition: OgreAnimation.h:56
Values are interpolated linearly.
Concrete IteratorWrapper for const access to the underlying key-value container.
VertexTrackIterator getVertexTrackIterator(void) const
Get non-updateable iterator over node tracks.
Specialised AnimationTrack for dealing with node transforms.
String mBaseKeyFrameAnimationName
_StringBase String
Definition: OgreCommon.h:53
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:90
OldNodeTrackIterator getOldNodeTrackIterator(void) const
Get non-updateable iterator over node tracks.
static InterpolationMode msDefaultInterpolationMode
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:58
A collection of OldBone objects used to animate a skinned mesh.
Definition: OgreSkeleton.h:84
OldNodeTrackList mOldNodeTrackList
OldNode tracks, indexed by handle.
bool mKeyFrameTimesDirty
Dirty flag indicate that keyframe time list need to rebuild.
map< unsigned short, VertexAnimationTrack * >::type VertexTrackList
ConstMapIterator< NumericTrackList > NumericTrackIterator