OGRE  1.9.0
OgreAnimationState.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE 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"
38#include "OgreHeaderPrefix.h"
39
40namespace 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
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
#define _OgreExport
Definition: OgrePlatform.h:260
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
ControllerValue wrapper class for AnimationState.
~AnimationStateControllerValue()
Destructor (parent already virtual)
Real getValue(void) const
ControllerValue implementation.
void setValue(Real value)
ControllerValue implementation.
AnimationStateControllerValue(AnimationState *targetAnimationState)
Constructor, pass in the target animation state.
Class encapsulating a set of AnimationState objects.
AnimationStateSet(const AnimationStateSet &rhs)
Create an animation set by copying the contents of another.
bool hasAnimationState(const String &name) const
Tests if state for the named animation is present.
EnabledAnimationStateList mEnabledAnimationStates
void removeAnimationState(const String &name)
Remove animation state with the given name.
AnimationStateMap mAnimationStates
void removeAllAnimationStates(void)
Remove all animation states.
bool hasEnabledAnimationState(void) const
Tests if exists enabled animation state in this set.
void copyMatchingState(AnimationStateSet *target) const
Copy the state of any matching animation states from this to another.
AnimationState * createAnimationState(const String &animName, Real timePos, Real length, Real weight=1.0, bool enabled=false)
Create a new AnimationState instance.
void _notifyDirty(void)
Set the dirty flag and dirty frame number on this state set.
AnimationState * getAnimationState(const String &name) const
Get an animation state by the name of the animation.
unsigned long getDirtyFrameNumber(void) const
Get the latest animation state been altered frame number.
AnimationStateIterator getAnimationStateIterator(void)
Get an iterator over all the animation states in this set.
void _notifyAnimationStateEnabled(AnimationState *target, bool enabled)
Internal method respond to enable/disable an animation state.
ConstEnabledAnimationStateIterator getEnabledAnimationStateIterator(void) const
Get an iterator over all the enabled animation states in this set.
OGRE_AUTO_MUTEX
Mutex, public for external locking if needed.
ConstAnimationStateIterator getAnimationStateIterator(void) const
Get an iterator over all the animation states in this set.
AnimationStateSet()
Create a blank animation state set.
Represents the state of an animation and the weight of its influence.
virtual ~AnimationState()
void createBlendMask(size_t blendMaskSizeHint, float initialWeight=1.0f)
Create a new blend mask with the given number of entries.
AnimationState(const String &animName, AnimationStateSet *parent, Real timePos, Real length, Real weight=1.0, bool enabled=false)
Normal constructor with all params supplied.
bool hasEnded(void) const
Returns true if the animation has reached the end and is not looping.
void _setBlendMask(const BoneBlendMask *blendMask)
Set the blend mask.
void setLoop(bool loop)
Sets whether or not an animation loops at the start and end of the animation if the time continues to...
BoneBlendMask * mBlendMask
The blend mask (containing per bone weights)
Real getTimePosition(void) const
Gets the time position for this animation.
float getBlendMaskEntry(size_t boneHandle) const
Get the weight for the bone identified by the given handle.
void addTime(Real offset)
Modifies the time position, adjusting for animation length.
bool operator==(const AnimationState &rhs) const
Equality operator.
AnimationState(AnimationStateSet *parent, const AnimationState &rhs)
Constructor to copy from an existing state with new parent.
bool operator!=(const AnimationState &rhs) const
Inequality operator.
void destroyBlendMask()
Destroy the currently set blend mask.
void setEnabled(bool enabled)
Sets whether this animation is enabled.
void setWeight(Real weight)
Sets the weight (influence) of this animation.
Real getLength() const
Gets the total length of this animation (may be shorter than whole animation)
AnimationStateSet * mParent
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.
void setBlendMaskEntry(size_t boneHandle, float weight)
Set the weight for the bone identified by the given handle.
void _setBlendMaskData(const float *blendMaskData)
Set the blend mask data (might be dangerous)
void copyStateFrom(const AnimationState &animState)
Copies the states from another animation state, preserving the animation name (unlike operator=) but ...
bool hasBlendMask() const
Return whether there is currently a valid blend mask set.
Real getWeight(void) const
Gets the weight (influence) of this animation.
void setTimePosition(Real timePos)
Sets the time position for this animation.
bool getLoop(void) const
Gets whether or not this animation loops
void setLength(Real len)
Sets the total length of this animation (may be shorter than whole animation)
const BoneBlendMask * getBlendMask() const
Get the current blend mask (const version, may be 0)
const String & getAnimationName() const
Gets the name of the animation to which this state applies.
bool getEnabled(void) const
Returns true if this animation is currently enabled.
Concrete IteratorWrapper for const access to the underlying key-value container.
Concrete IteratorWrapper for const access to the underlying container.
Can either be used as an input or output value.
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
ConstVectorIterator< EnabledAnimationStateList > ConstEnabledAnimationStateIterator
list< AnimationState * >::type EnabledAnimationStateList
ConstMapIterator< AnimationStateMap > ConstAnimationStateIterator
MapIterator< AnimationStateMap > AnimationStateIterator
map< String, AnimationState * >::type AnimationStateMap
float Real
Software floating point type.
_StringBase String
std::list< T, A > type
std::map< K, V, P, A > type
std::vector< T, A > type