OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OgreAnimationState.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 __AnimationSet_H__
30 #define __AnimationSet_H__
31 
32 #include "OgrePrerequisites.h"
33 
34 #include "OgreString.h"
35 #include "OgreController.h"
36 #include "OgreIteratorWrappers.h"
37 
38 namespace Ogre {
39 
53  {
54  public:
55 
58 
60  AnimationState(const String& animName, AnimationStateSet *parent,
61  Real timePos, Real length, Real weight = 1.0, bool enabled = false);
63  AnimationState(AnimationStateSet* parent, const AnimationState &rhs);
67  virtual ~AnimationState();
68 
70  const String& getAnimationName() const;
72  Real getTimePosition(void) const;
74  void setTimePosition(Real timePos);
76  Real getLength() const;
78  void setLength(Real len);
80  Real getWeight(void) const;
82  void setWeight(Real weight);
87  void addTime(Real offset);
88 
90  bool hasEnded(void) const;
91 
93  bool getEnabled(void) const;
95  void setEnabled(bool enabled);
96 
98  bool operator==(const AnimationState& rhs) const;
99  // Inequality operator
100  bool operator!=(const AnimationState& rhs) const;
101 
105  void setLoop(bool loop) { mLoop = loop; }
107  bool getLoop(void) const { return mLoop; }
108 
113  void copyStateFrom(const AnimationState& animState);
114 
116  AnimationStateSet* getParent(void) const { return mParent; }
117 
128  void createBlendMask(size_t blendMaskSizeHint, float initialWeight = 1.0f);
130  void destroyBlendMask();
138  void _setBlendMaskData(const float* blendMaskData);
146  void _setBlendMask(const BoneBlendMask* blendMask);
148  const BoneBlendMask* getBlendMask() const {return mBlendMask;}
150  bool hasBlendMask() const {return mBlendMask != 0;}
152  void setBlendMaskEntry(size_t boneHandle, float weight);
154  inline float getBlendMaskEntry(size_t boneHandle) const
155  {
156  assert(mBlendMask && mBlendMask->size() > boneHandle);
157  return (*mBlendMask)[boneHandle];
158  }
159  protected:
162 
168  bool mEnabled;
169  bool mLoop;
170 
171  };
172 
173  // A map of animation states
177  // A list of enabled animation states
180 
184  {
185  public:
191  AnimationStateSet(const AnimationStateSet& rhs);
192 
193  ~AnimationStateSet();
194 
202  AnimationState* createAnimationState(const String& animName,
203  Real timePos, Real length, Real weight = 1.0, bool enabled = false);
205  AnimationState* getAnimationState(const String& name) const;
207  bool hasAnimationState(const String& name) const;
209  void removeAnimationState(const String& name);
211  void removeAllAnimationStates(void);
212 
219  AnimationStateIterator getAnimationStateIterator(void);
226  ConstAnimationStateIterator getAnimationStateIterator(void) const;
228  void copyMatchingState(AnimationStateSet* target) const;
230  void _notifyDirty(void);
232  unsigned long getDirtyFrameNumber(void) const { return mDirtyFrameNumber; }
233 
235  void _notifyAnimationStateEnabled(AnimationState* target, bool enabled);
237  bool hasEnabledAnimationState(void) const { return !mEnabledAnimationStates.empty(); }
244  ConstEnabledAnimationStateIterator getEnabledAnimationStateIterator(void) const;
245 
246  protected:
247  unsigned long mDirtyFrameNumber;
250 
251  };
252 
262  {
263  protected:
265  public:
268  : mTargetAnimationState(targetAnimationState) {}
272  Real getValue(void) const;
273 
275  void setValue(Real value);
276 
277  };
278 
281 }
282 
283 #endif
284 
Class encapsulating a set of AnimationState objects.
#define OGRE_AUTO_MUTEX
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:203
MapIterator< AnimationStateMap > AnimationStateIterator
float getBlendMaskEntry(size_t boneHandle) const
get the weight for the bone identified by the given handle
list< AnimationState * >::type EnabledAnimationStateList
void setLoop(bool loop)
Sets whether or not an animation loops at the start and end of the animation if the time continues to...
EnabledAnimationStateList mEnabledAnimationStates
bool hasBlendMask() const
return whether there is currently a valid blend mask set
map< String, AnimationState * >::type AnimationStateMap
Represents the state of an animation and the weight of it's influence.
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
BoneBlendMask * mBlendMask
the blend mask (containing per bone weights)
const BoneBlendMask * getBlendMask() const
get the current blend mask (const version, may be 0)
AnimationStateSet * mParent
Can either be used as an input or output value.
AnimationStateControllerValue(AnimationState *targetAnimationState)
Constructor, pass in the target animation state.
ConstVectorIterator< EnabledAnimationStateList > ConstEnabledAnimationStateIterator
~AnimationStateControllerValue()
Destructor (parent already virtual)
Concrete IteratorWrapper for const access to the underlying container.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
ControllerValue wrapper class for AnimationState.
unsigned long getDirtyFrameNumber(void) const
Get the latest animation state been altered frame number.
bool getLoop(void) const
Gets whether or not this animation loops.
AnimationStateMap mAnimationStates
Concrete IteratorWrapper for const access to the underlying key-value container.
_StringBase String
ConstMapIterator< AnimationStateMap > ConstAnimationStateIterator
bool hasEnabledAnimationState(void) const
Tests if exists enabled animation state in this set.
vector< float >::type BoneBlendMask
typedef for an array of float values used as a bone blend mask
AnimationStateSet * getParent(void) const
Get the parent animation state set.
bool operator==(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
bool operator!=(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)