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"
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);
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);
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 
216  Real timePos, Real length, Real weight = 1.0, bool enabled = false);
220  bool hasAnimationState(const String& name) const;
222  void removeAnimationState(const String& name);
225 
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(); }
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 
OgreHeaderSuffix.h
Ogre::AnimationStateSet::getAnimationState
AnimationState * getAnimationState(const String &name) const
Get an animation state by the name of the animation.
Ogre::ControllerValue
Can either be used as an input or output value.
Definition: OgreController.h:105
Ogre::AnimationState::getBlendMaskEntry
float getBlendMaskEntry(size_t boneHandle) const
Get the weight for the bone identified by the given handle.
Definition: OgreAnimationState.h:167
Ogre::AnimationState::_setBlendMask
void _setBlendMask(const BoneBlendMask *blendMask)
Set the blend mask.
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:59
Ogre
Definition: OgreAndroidLogListener.h:35
Ogre::AnimationState::getWeight
Real getWeight(void) const
Gets the weight (influence) of this animation.
Ogre::AnimationState::getTimePosition
Real getTimePosition(void) const
Gets the time position for this animation.
Ogre::AnimationState::_setBlendMaskData
void _setBlendMaskData(const float *blendMaskData)
Set the blend mask data (might be dangerous)
Ogre::AnimationState::createBlendMask
void createBlendMask(size_t blendMaskSizeHint, float initialWeight=1.0f)
Create a new blend mask with the given number of entries.
Ogre::map
Definition: OgrePrerequisites.h:534
Ogre::ConstEnabledAnimationStateIterator
ConstVectorIterator< EnabledAnimationStateList > ConstEnabledAnimationStateIterator
Definition: OgreAnimationState.h:192
Ogre::AnimationState::mBlendMask
BoneBlendMask * mBlendMask
The blend mask (containing per bone weights)
Definition: OgreAnimationState.h:174
Ogre::AnimationStateSet::_notifyDirty
void _notifyDirty(void)
Set the dirty flag and dirty frame number on this state set.
Ogre::AnimationStateSet::mDirtyFrameNumber
unsigned long mDirtyFrameNumber
Definition: OgreAnimationState.h:260
Ogre::AnimationState::setEnabled
void setEnabled(bool enabled)
Sets whether this animation is enabled.
Ogre::AnimationStateControllerValue
ControllerValue wrapper class for AnimationState.
Definition: OgreAnimationState.h:275
Ogre::AnimationStateSet::getAnimationStateIterator
ConstAnimationStateIterator getAnimationStateIterator(void) const
Get an iterator over all the animation states in this set.
Ogre::AnimationState::setTimePosition
void setTimePosition(Real timePos)
Sets the time position for this animation.
Ogre::AnimationStateSet::removeAllAnimationStates
void removeAllAnimationStates(void)
Remove all animation states.
Ogre::AnimationState::mWeight
Real mWeight
Definition: OgreAnimationState.h:180
Ogre::AnimationState::addTime
void addTime(Real offset)
Modifies the time position, adjusting for animation length.
Ogre::AnimationState::mLength
Real mLength
Definition: OgreAnimationState.h:179
Ogre::AnimationState::operator!=
bool operator!=(const AnimationState &rhs) const
Inequality operator.
Ogre::AnimationState::mAnimationName
String mAnimationName
Definition: OgreAnimationState.h:176
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::AnimationStateMap
map< String, AnimationState * >::type AnimationStateMap
Definition: OgreAnimationState.h:187
Ogre::AnimationStateControllerValue::AnimationStateControllerValue
AnimationStateControllerValue(AnimationState *targetAnimationState)
Constructor, pass in the target animation state.
Definition: OgreAnimationState.h:280
Ogre::AnimationStateSet::mEnabledAnimationStates
EnabledAnimationStateList mEnabledAnimationStates
Definition: OgreAnimationState.h:262
Ogre::AnimationState
Represents the state of an animation and the weight of its influence.
Definition: OgreAnimationState.h:55
Ogre::AnimationState::mEnabled
bool mEnabled
Definition: OgreAnimationState.h:181
Ogre::AnimationState::getParent
AnimationStateSet * getParent(void) const
Get the parent animation state set.
Definition: OgreAnimationState.h:129
Ogre::AnimationStateControllerValue::setValue
void setValue(Real value)
ControllerValue implementation.
Ogre::AnimationState::mTimePos
Real mTimePos
Definition: OgreAnimationState.h:178
OgreHeaderPrefix.h
Ogre::AnimationState::setWeight
void setWeight(Real weight)
Sets the weight (influence) of this animation.
Ogre::list
Definition: OgrePrerequisites.h:506
Ogre::AnimationState::hasBlendMask
bool hasBlendMask() const
Return whether there is currently a valid blend mask set.
Definition: OgreAnimationState.h:163
Ogre::AnimationState::setLoop
void setLoop(bool loop)
Sets whether or not an animation loops at the start and end of the animation if the time continues to...
Definition: OgreAnimationState.h:118
Ogre::AnimationStateSet::AnimationStateSet
AnimationStateSet(const AnimationStateSet &rhs)
Create an animation set by copying the contents of another.
OgrePrerequisites.h
Ogre::AnimationStateSet::getDirtyFrameNumber
unsigned long getDirtyFrameNumber(void) const
Get the latest animation state been altered frame number.
Definition: OgreAnimationState.h:245
Ogre::AnimationState::getLoop
bool getLoop(void) const
Gets whether or not this animation loops
Definition: OgreAnimationState.h:120
Ogre::AnimationState::setLength
void setLength(Real len)
Sets the total length of this animation (may be shorter than whole animation)
OgreThreadHeaders.h
Ogre::AnimationStateSet::OGRE_AUTO_MUTEX
OGRE_AUTO_MUTEX
Mutex, public for external locking if needed.
Definition: OgreAnimationState.h:200
OgreController.h
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::AnimationState::BoneBlendMask
vector< float >::type BoneBlendMask
Typedef for an array of float values used as a bone blend mask.
Definition: OgreAnimationState.h:59
Ogre::AnimationStateSet::~AnimationStateSet
~AnimationStateSet()
Ogre::AnimationStateSet::hasEnabledAnimationState
bool hasEnabledAnimationState(void) const
Tests if exists enabled animation state in this set.
Definition: OgreAnimationState.h:250
Ogre::AnimationState::copyStateFrom
void copyStateFrom(const AnimationState &animState)
Copies the states from another animation state, preserving the animation name (unlike operator=) but ...
Ogre::AnimationStateSet::mAnimationStates
AnimationStateMap mAnimationStates
Definition: OgreAnimationState.h:261
Ogre::AnimationState::getBlendMask
const BoneBlendMask * getBlendMask() const
Get the current blend mask (const version, may be 0)
Definition: OgreAnimationState.h:161
Ogre::AnimationStateControllerValue::getValue
Real getValue(void) const
ControllerValue implementation.
Ogre::AnimationState::getEnabled
bool getEnabled(void) const
Returns true if this animation is currently enabled.
Ogre::AnimationStateIterator
MapIterator< AnimationStateMap > AnimationStateIterator
Definition: OgreAnimationState.h:188
Ogre::AnimationStateSet::createAnimationState
AnimationState * createAnimationState(const String &animName, Real timePos, Real length, Real weight=1.0, bool enabled=false)
Create a new AnimationState instance.
Ogre::MapIterator
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
Definition: OgreIteratorWrapper.h:319
Ogre::AnimationState::getAnimationName
const String & getAnimationName() const
Gets the name of the animation to which this state applies.
Ogre::AnimationStateSet
Class encapsulating a set of AnimationState objects.
Definition: OgreAnimationState.h:197
OgreIteratorWrappers.h
Ogre::AnimationState::AnimationState
AnimationState(const String &animName, AnimationStateSet *parent, Real timePos, Real length, Real weight=1.0, bool enabled=false)
Normal constructor with all params supplied.
Ogre::AnimationStateSet::removeAnimationState
void removeAnimationState(const String &name)
Remove animation state with the given name.
Ogre::AnimationState::mParent
AnimationStateSet * mParent
Definition: OgreAnimationState.h:177
Ogre::AnimationStateControllerValue::~AnimationStateControllerValue
~AnimationStateControllerValue()
Destructor (parent already virtual)
Definition: OgreAnimationState.h:283
Ogre::AnimationStateSet::getEnabledAnimationStateIterator
ConstEnabledAnimationStateIterator getEnabledAnimationStateIterator(void) const
Get an iterator over all the enabled animation states in this set.
Ogre::AnimationState::hasEnded
bool hasEnded(void) const
Returns true if the animation has reached the end and is not looping.
Ogre::AnimationState::getLength
Real getLength() const
Gets the total length of this animation (may be shorter than whole animation)
Ogre::AnimationStateSet::hasAnimationState
bool hasAnimationState(const String &name) const
Tests if state for the named animation is present.
Ogre::AnimationState::~AnimationState
virtual ~AnimationState()
Ogre::AnimationState::destroyBlendMask
void destroyBlendMask()
Destroy the currently set blend mask.
Ogre::AnimationStateSet::AnimationStateSet
AnimationStateSet()
Create a blank animation state set.
Ogre::EnabledAnimationStateList
list< AnimationState * >::type EnabledAnimationStateList
Definition: OgreAnimationState.h:191
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::ConstMapIterator
Concrete IteratorWrapper for const access to the underlying key-value container.
Definition: OgreIteratorWrapper.h:352
Ogre::AnimationState::AnimationState
AnimationState(AnimationStateSet *parent, const AnimationState &rhs)
Constructor to copy from an existing state with new parent.
Ogre::AnimationStateSet::_notifyAnimationStateEnabled
void _notifyAnimationStateEnabled(AnimationState *target, bool enabled)
Internal method respond to enable/disable an animation state.
Ogre::AnimationStateControllerValue::mTargetAnimationState
AnimationState * mTargetAnimationState
Definition: OgreAnimationState.h:277
Ogre::AnimationStateSet::copyMatchingState
void copyMatchingState(AnimationStateSet *target) const
Copy the state of any matching animation states from this to another.
Ogre::AnimationState::mLoop
bool mLoop
Definition: OgreAnimationState.h:182
OgreString.h
Ogre::vector
Definition: OgrePrerequisites.h:492
Ogre::AnimationState::operator==
bool operator==(const AnimationState &rhs) const
Equality operator.
Ogre::AnimationStateSet::getAnimationStateIterator
AnimationStateIterator getAnimationStateIterator(void)
Get an iterator over all the animation states in this set.
Ogre::AnimationState::setBlendMaskEntry
void setBlendMaskEntry(size_t boneHandle, float weight)
Set the weight for the bone identified by the given handle.
Ogre::ConstAnimationStateIterator
ConstMapIterator< AnimationStateMap > ConstAnimationStateIterator
Definition: OgreAnimationState.h:189
Ogre::ConstVectorIterator
Concrete IteratorWrapper for const access to the underlying container.
Definition: OgreIteratorWrapper.h:217

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.