OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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-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 __AnimationState_H__
30 #define __AnimationState_H__
31 
32 #include "OgrePrerequisites.h"
33 
34 #include "OgreCommon.h"
35 #include "OgreController.h"
36 #include "OgreIteratorWrappers.h"
38 #include "OgreHeaderPrefix.h"
39 
40 namespace Ogre {
41 
55  {
56  public:
57 
60 
75  AnimationState(const String& animName, AnimationStateSet *parent,
76  Real timePos, Real length, Real weight = 1.0, bool enabled = false);
78  AnimationState(AnimationStateSet* parent, const AnimationState &rhs);
79  virtual ~AnimationState();
80 
82  const String& getAnimationName() const;
84  Real getTimePosition(void) const;
86  void setTimePosition(Real timePos);
88  Real getLength() const;
90  void setLength(Real len);
92  Real getWeight(void) const;
94  void setWeight(Real weight);
100  void addTime(Real offset);
101 
103  bool hasEnded(void) const;
104 
106  bool getEnabled(void) const;
108  void setEnabled(bool enabled);
109 
111  bool operator==(const AnimationState& rhs) const;
113  bool operator!=(const AnimationState& rhs) const;
114 
118  void setLoop(bool loop) { mLoop = loop; }
120  bool getLoop(void) const { return mLoop; }
121 
126  void copyStateFrom(const AnimationState& animState);
127 
129  AnimationStateSet* getParent(void) const { return mParent; }
130 
141  void createBlendMask(size_t blendMaskSizeHint, float initialWeight = 1.0f);
143  void destroyBlendMask();
151  void _setBlendMaskData(const float* blendMaskData);
159  void _setBlendMask(const BoneBlendMask* blendMask);
161  const BoneBlendMask* getBlendMask() const {return mBlendMask;}
163  bool hasBlendMask() const {return mBlendMask != 0;}
165  void setBlendMaskEntry(size_t boneHandle, float weight);
167  inline float getBlendMaskEntry(size_t boneHandle) const
168  {
169  assert(mBlendMask && mBlendMask->size() > boneHandle);
170  return (*mBlendMask)[boneHandle];
171  }
172  protected:
175 
181  bool mEnabled;
182  bool mLoop;
183 
184  };
185 
186  // A map of animation states
190  // A list of enabled animation states
193 
197  {
198  public:
205 
207 
215  AnimationState* createAnimationState(const String& animName,
216  Real timePos, Real length, Real weight = 1.0, bool enabled = false);
218  AnimationState* getAnimationState(const String& name) const;
220  bool hasAnimationState(const String& name) const;
222  void removeAnimationState(const String& name);
224  void removeAllAnimationStates(void);
225 
232  AnimationStateIterator getAnimationStateIterator(void);
239  ConstAnimationStateIterator getAnimationStateIterator(void) const;
241  void copyMatchingState(AnimationStateSet* target) const;
243  void _notifyDirty(void);
245  unsigned long getDirtyFrameNumber(void) const { return mDirtyFrameNumber; }
246 
248  void _notifyAnimationStateEnabled(AnimationState* target, bool enabled);
250  bool hasEnabledAnimationState(void) const { return !mEnabledAnimationStates.empty(); }
257  ConstEnabledAnimationStateIterator getEnabledAnimationStateIterator(void) const;
258 
259  protected:
260  unsigned long mDirtyFrameNumber;
263 
264  };
265 
275  {
276  protected:
278  public:
281  : mTargetAnimationState(targetAnimationState) {}
285  Real getValue(void) const;
286 
288  void setValue(Real value);
289 
290  };
291 
294 }
295 
296 #include "OgreHeaderSuffix.h"
297 
298 #endif
299 
Class encapsulating a set of AnimationState objects.
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:255
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...
OGRE_AUTO_MUTEX
Mutex, public for external locking if needed.
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 its 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
Definition: OgreCommon.h:53
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++)