OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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-2011 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 
39 namespace Ogre {
59  {
60 
61  public:
64  {
68  IM_SPLINE
69  };
70 
73  {
81  RIM_SPHERICAL
82  };
87  Animation(const String& name, Real length);
88  virtual ~Animation();
89 
91  const String& getName(void) const;
92 
94  Real getLength(void) const;
95 
100  void setLength(Real len);
101 
106  NodeAnimationTrack* createNodeTrack(unsigned short handle);
107 
112  NumericAnimationTrack* createNumericTrack(unsigned short handle);
113 
121  VertexAnimationTrack* createVertexTrack(unsigned short handle, VertexAnimationType animType);
122 
131  NodeAnimationTrack* createNodeTrack(unsigned short handle, Node* node);
132 
138  NumericAnimationTrack* createNumericTrack(unsigned short handle,
139  const AnimableValuePtr& anim);
140 
147  VertexAnimationTrack* createVertexTrack(unsigned short handle,
148  VertexData* data, VertexAnimationType animType);
149 
151  unsigned short getNumNodeTracks(void) const;
152 
154  NodeAnimationTrack* getNodeTrack(unsigned short handle) const;
155 
157  bool hasNodeTrack(unsigned short handle) const;
158 
160  unsigned short getNumNumericTracks(void) const;
161 
163  NumericAnimationTrack* getNumericTrack(unsigned short handle) const;
164 
166  bool hasNumericTrack(unsigned short handle) const;
167 
169  unsigned short getNumVertexTracks(void) const;
170 
172  VertexAnimationTrack* getVertexTrack(unsigned short handle) const;
173 
175  bool hasVertexTrack(unsigned short handle) const;
176 
178  void destroyNodeTrack(unsigned short handle);
179 
181  void destroyNumericTrack(unsigned short handle);
182 
184  void destroyVertexTrack(unsigned short handle);
185 
187  void destroyAllTracks(void);
188 
190  void destroyAllNodeTracks(void);
192  void destroyAllNumericTracks(void);
194  void destroyAllVertexTracks(void);
195 
206  void apply(Real timePos, Real weight = 1.0, Real scale = 1.0f);
207 
218  void applyToNode(Node* node, Real timePos, Real weight = 1.0, Real scale = 1.0f);
219 
230  void apply(Skeleton* skeleton, Real timePos, Real weight = 1.0, Real scale = 1.0f);
231 
244  void apply(Skeleton* skeleton, Real timePos, float weight,
245  const AnimationState::BoneBlendMask* blendMask, Real scale);
246 
256  void apply(Entity* entity, Real timePos, Real weight, bool software,
257  bool hardware);
258 
268  void applyToAnimable(const AnimableValuePtr& anim, Real timePos, Real weight = 1.0, Real scale = 1.0f);
269 
277  void applyToVertexData(VertexData* data, Real timePos, Real weight = 1.0);
278 
291  void setInterpolationMode(InterpolationMode im);
292 
297  InterpolationMode getInterpolationMode(void) const;
308  void setRotationInterpolationMode(RotationInterpolationMode im);
309 
314  RotationInterpolationMode getRotationInterpolationMode(void) const;
315 
316  // Methods for setting the defaults
323  static void setDefaultInterpolationMode(InterpolationMode im);
324 
326  static InterpolationMode getDefaultInterpolationMode(void);
327 
334  static void setDefaultRotationInterpolationMode(RotationInterpolationMode im);
335 
337  static RotationInterpolationMode getDefaultRotationInterpolationMode(void);
338 
341 
344 
347 
349  const NodeTrackList& _getNodeTrackList(void) const;
350 
353  { return NodeTrackIterator(mNodeTrackList.begin(), mNodeTrackList.end()); }
354 
356  const NumericTrackList& _getNumericTrackList(void) const;
357 
360  { return NumericTrackIterator(mNumericTrackList.begin(), mNumericTrackList.end()); }
361 
363  const VertexTrackList& _getVertexTrackList(void) const;
364 
367  { return VertexTrackIterator(mVertexTrackList.begin(), mVertexTrackList.end()); }
368 
388  void optimise(bool discardIdentityNodeTracks = true);
389 
392 
400  void _collectIdentityNodeTracks(TrackHandleList& tracks) const;
401 
404  void _destroyNodeTracks(const TrackHandleList& tracks);
405 
412  Animation* clone(const String& newName) const;
413 
416  void _keyFrameListChanged(void) { mKeyFrameTimesDirty = true; }
417 
428  TimeIndex _getTimeIndex(Real timePos) const;
429 
430  protected:
438 
440 
443 
446 
451  mutable bool mKeyFrameTimesDirty;
452 
453  void optimiseNodeTracks(bool discardIdentityTracks);
454  void optimiseVertexTracks(void);
455 
457  void buildKeyFrameTimeList(void) const;
458  };
459 
462 }
463 
464 
465 #endif
466 
map< unsigned short, NodeAnimationTrack * >::type NodeTrackList
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:203
RotationInterpolationMode
The types of rotational interpolation available.
Definition: OgreAnimation.h:72
vector< Real >::type KeyFrameTimeList
Global keyframe time list used to search global keyframe index.
InterpolationMode
The types of animation interpolation available.
Definition: OgreAnimation.h:63
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.
Definition: OgreAnimation.h:66
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:81
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...
Summary class collecting together vertex source information.
Values are interpolated linearly.
Definition: OgreAnimation.h:77
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.
_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:58
static InterpolationMode msDefaultInterpolationMode
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:62
A collection of Bone objects used to animate a skinned mesh.
Definition: OgreSkeleton.h:85
bool mKeyFrameTimesDirty
Dirty flag indicate that keyframe time list need to rebuild.
map< unsigned short, VertexAnimationTrack * >::type VertexTrackList
ConstMapIterator< NumericTrackList > NumericTrackIterator