OGRE  1.8
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-2013 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 #include "OgreHeaderPrefix.h"
38 
39 namespace Ogre {
40 
54  {
55  public:
56 
59 
74  AnimationState(const String& animName, AnimationStateSet *parent,
75  Real timePos, Real length, Real weight = 1.0, bool enabled = false);
77  AnimationState(AnimationStateSet* parent, const AnimationState &rhs);
78  virtual ~AnimationState();
79 
81  const String& getAnimationName() const;
83  Real getTimePosition(void) const;
85  void setTimePosition(Real timePos);
87  Real getLength() const;
89  void setLength(Real len);
91  Real getWeight(void) const;
93  void setWeight(Real weight);
99  void addTime(Real offset);
100 
102  bool hasEnded(void) const;
103 
105  bool getEnabled(void) const;
107  void setEnabled(bool enabled);
108 
110  bool operator==(const AnimationState& rhs) const;
112  bool operator!=(const AnimationState& rhs) const;
113 
117  void setLoop(bool loop) { mLoop = loop; }
119  bool getLoop(void) const { return mLoop; }
120 
125  void copyStateFrom(const AnimationState& animState);
126 
128  AnimationStateSet* getParent(void) const { return mParent; }
129 
140  void createBlendMask(size_t blendMaskSizeHint, float initialWeight = 1.0f);
142  void destroyBlendMask();
150  void _setBlendMaskData(const float* blendMaskData);
158  void _setBlendMask(const BoneBlendMask* blendMask);
160  const BoneBlendMask* getBlendMask() const {return mBlendMask;}
162  bool hasBlendMask() const {return mBlendMask != 0;}
164  void setBlendMaskEntry(size_t boneHandle, float weight);
166  inline float getBlendMaskEntry(size_t boneHandle) const
167  {
168  assert(mBlendMask && mBlendMask->size() > boneHandle);
169  return (*mBlendMask)[boneHandle];
170  }
171  protected:
174 
180  bool mEnabled;
181  bool mLoop;
182 
183  };
184 
185  // A map of animation states
189  // A list of enabled animation states
192 
196  {
197  public:
203  AnimationStateSet(const AnimationStateSet& rhs);
204 
205  ~AnimationStateSet();
206 
214  AnimationState* createAnimationState(const String& animName,
215  Real timePos, Real length, Real weight = 1.0, bool enabled = false);
217  AnimationState* getAnimationState(const String& name) const;
219  bool hasAnimationState(const String& name) const;
221  void removeAnimationState(const String& name);
223  void removeAllAnimationStates(void);
224 
231  AnimationStateIterator getAnimationStateIterator(void);
238  ConstAnimationStateIterator getAnimationStateIterator(void) const;
240  void copyMatchingState(AnimationStateSet* target) const;
242  void _notifyDirty(void);
244  unsigned long getDirtyFrameNumber(void) const { return mDirtyFrameNumber; }
245 
247  void _notifyAnimationStateEnabled(AnimationState* target, bool enabled);
249  bool hasEnabledAnimationState(void) const { return !mEnabledAnimationStates.empty(); }
256  ConstEnabledAnimationStateIterator getEnabledAnimationStateIterator(void) const;
257 
258  protected:
259  unsigned long mDirtyFrameNumber;
262 
263  };
264 
274  {
275  protected:
277  public:
280  : mTargetAnimationState(targetAnimationState) {}
284  Real getValue(void) const;
285 
287  void setValue(Real value);
288 
289  };
290 
293 }
294 
295 #include "OgreHeaderSuffix.h"
296 
297 #endif
298 
Class encapsulating a set of AnimationState objects.
#define OGRE_AUTO_MUTEX
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:233
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 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
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++)