OgreAnimationState.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __AnimationSet_H__
#define __AnimationSet_H__
#include "OgrePrerequisites.h"
#include "OgreString.h"
#include "OgreController.h"
#include "OgreIteratorWrappers.h"
#include "Threading/OgreThreadHeaders.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class _OgreExport AnimationState : public AnimationAlloc
{
public:
typedef vector<float>::type BoneBlendMask;
AnimationState(const String& animName, AnimationStateSet *parent,
Real timePos, Real length, Real weight = 1.0, bool enabled = false);
AnimationState(AnimationStateSet* parent, const AnimationState &rhs);
virtual ~AnimationState();
const String& getAnimationName() const;
Real getTimePosition(void) const;
void setTimePosition(Real timePos);
Real getLength() const;
void setLength(Real len);
Real getWeight(void) const;
void setWeight(Real weight);
void addTime(Real offset);
bool hasEnded(void) const;
bool getEnabled(void) const;
void setEnabled(bool enabled);
bool operator==(const AnimationState& rhs) const;
bool operator!=(const AnimationState& rhs) const;
void setLoop(bool loop) { mLoop = loop; }
bool getLoop(void) const { return mLoop; }
void copyStateFrom(const AnimationState& animState);
AnimationStateSet* getParent(void) const { return mParent; }
void createBlendMask(size_t blendMaskSizeHint, float initialWeight = 1.0f);
void destroyBlendMask();
void _setBlendMaskData(const float* blendMaskData);
void _setBlendMask(const BoneBlendMask* blendMask);
const BoneBlendMask* getBlendMask() const {return mBlendMask;}
bool hasBlendMask() const {return mBlendMask != 0;}
void setBlendMaskEntry(size_t boneHandle, float weight);
inline float getBlendMaskEntry(size_t boneHandle) const
{
assert(mBlendMask && mBlendMask->size() > boneHandle);
return (*mBlendMask)[boneHandle];
}
protected:
BoneBlendMask* mBlendMask;
String mAnimationName;
AnimationStateSet* mParent;
Real mTimePos;
Real mLength;
Real mWeight;
bool mEnabled;
bool mLoop;
};
// A map of animation states
typedef map<String, AnimationState*>::type AnimationStateMap;
typedef MapIterator<AnimationStateMap> AnimationStateIterator;
typedef ConstMapIterator<AnimationStateMap> ConstAnimationStateIterator;
// A list of enabled animation states
typedef list<AnimationState*>::type EnabledAnimationStateList;
typedef ConstVectorIterator<EnabledAnimationStateList> ConstEnabledAnimationStateIterator;
class _OgreExport AnimationStateSet : public AnimationAlloc
{
public:
OGRE_AUTO_MUTEX;
AnimationStateSet();
AnimationStateSet(const AnimationStateSet& rhs);
~AnimationStateSet();
AnimationState* createAnimationState(const String& animName,
Real timePos, Real length, Real weight = 1.0, bool enabled = false);
AnimationState* getAnimationState(const String& name) const;
bool hasAnimationState(const String& name) const;
void removeAnimationState(const String& name);
void removeAllAnimationStates(void);
AnimationStateIterator getAnimationStateIterator(void);
ConstAnimationStateIterator getAnimationStateIterator(void) const;
void copyMatchingState(AnimationStateSet* target) const;
void _notifyDirty(void);
unsigned long getDirtyFrameNumber(void) const { return mDirtyFrameNumber; }
void _notifyAnimationStateEnabled(AnimationState* target, bool enabled);
bool hasEnabledAnimationState(void) const { return !mEnabledAnimationStates.empty(); }
ConstEnabledAnimationStateIterator getEnabledAnimationStateIterator(void) const;
protected:
unsigned long mDirtyFrameNumber;
AnimationStateMap mAnimationStates;
EnabledAnimationStateList mEnabledAnimationStates;
};
class _OgreExport AnimationStateControllerValue : public ControllerValue<Real>
{
protected:
AnimationState* mTargetAnimationState;
public:
AnimationStateControllerValue(AnimationState* targetAnimationState)
: mTargetAnimationState(targetAnimationState) {}
~AnimationStateControllerValue() {}
Real getValue(void) const;
void setValue(Real value);
};
}
#include "OgreHeaderSuffix.h"
#endif
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::AnimationState::hasBlendMask
bool hasBlendMask() const
Return whether there is currently a valid blend mask set.
Definition: OgreAnimationState.h:163
Ogre::AnimationState::mEnabled
bool mEnabled
Definition: OgreAnimationState.h:181
Ogre::AnimationStateSet::getDirtyFrameNumber
unsigned long getDirtyFrameNumber(void) const
Get the latest animation state been altered frame number.
Definition: OgreAnimationState.h:245
Ogre::AnimationState::mParent
AnimationStateSet * mParent
Definition: OgreAnimationState.h:177
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::list
Definition: OgrePrerequisites.h:505
Ogre::AnimationState::getBlendMask
const BoneBlendMask * getBlendMask() const
Get the current blend mask (const version, may be 0)
Definition: OgreAnimationState.h:161
Ogre::AnimationState::getLoop
bool getLoop(void) const
Gets whether or not this animation loops.
Definition: OgreAnimationState.h:120
Ogre::MapIterator
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
Definition: OgreIteratorWrapper.h:319
Ogre::AnimationStateSet::mAnimationStates
AnimationStateMap mAnimationStates
Definition: OgreAnimationState.h:261
Ogre::ConstEnabledAnimationStateIterator
ConstVectorIterator< EnabledAnimationStateList > ConstEnabledAnimationStateIterator
Definition: OgreAnimationState.h:192
Ogre::ConstMapIterator
Concrete IteratorWrapper for const access to the underlying key-value container.
Definition: OgreIteratorWrapper.h:352
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::AnimationState::mLoop
bool mLoop
Definition: OgreAnimationState.h:182
OgreString.h
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::AnimationStateControllerValue::mTargetAnimationState
AnimationState * mTargetAnimationState
Definition: OgreAnimationState.h:277
Ogre::ControllerValue
Can either be used as an input or output value.
Definition: OgreController.h:104
OgreController.h
Ogre::AnimationStateSet
Class encapsulating a set of AnimationState objects.
Definition: OgreAnimationState.h:196
OgrePrerequisites.h
Ogre::AnimationStateIterator
MapIterator< AnimationStateMap > AnimationStateIterator
Definition: OgreAnimationState.h:188
Ogre::AnimationStateControllerValue::~AnimationStateControllerValue
~AnimationStateControllerValue()
Destructor (parent already virtual)
Definition: OgreAnimationState.h:283
Ogre::AnimationState::mBlendMask
BoneBlendMask * mBlendMask
The blend mask (containing per bone weights)
Definition: OgreAnimationState.h:174
Ogre::AnimationStateMap
map< String, AnimationState * >::type AnimationStateMap
Definition: OgreAnimationState.h:187
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::operator!=
bool operator!=(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
Definition: OgreMemorySTLAllocator.h:202
Ogre::AnimationStateSet::hasEnabledAnimationState
bool hasEnabledAnimationState(void) const
Tests if exists enabled animation state in this set.
Definition: OgreAnimationState.h:250
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::ConstAnimationStateIterator
ConstMapIterator< AnimationStateMap > ConstAnimationStateIterator
Definition: OgreAnimationState.h:189
OgreHeaderSuffix.h
OgreThreadHeaders.h
OgreIteratorWrappers.h
Ogre::AnimationState::mWeight
Real mWeight
Definition: OgreAnimationState.h:180
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::AnimationState::mLength
Real mLength
Definition: OgreAnimationState.h:179
Ogre::AnimationState::mAnimationName
String mAnimationName
Definition: OgreAnimationState.h:176
Ogre::ConstVectorIterator
Concrete IteratorWrapper for const access to the underlying container.
Definition: OgreIteratorWrapper.h:217
Ogre::vector
Definition: OgrePrerequisites.h:491
OgreHeaderPrefix.h
Ogre::operator==
bool operator==(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
Definition: OgreMemorySTLAllocator.h:184
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::AnimationState
Represents the state of an animation and the weight of its influence.
Definition: OgreAnimationState.h:54
Ogre::AnimationStateSet::OGRE_AUTO_MUTEX
OGRE_AUTO_MUTEX
Mutex, public for external locking if needed.
Definition: OgreAnimationState.h:200
Ogre::AnimationStateSet::mDirtyFrameNumber
unsigned long mDirtyFrameNumber
Definition: OgreAnimationState.h:260
Ogre::AnimationStateControllerValue
ControllerValue wrapper class for AnimationState.
Definition: OgreAnimationState.h:274
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::getParent
AnimationStateSet * getParent(void) const
Get the parent animation state set.
Definition: OgreAnimationState.h:129
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::AnimationState::mTimePos
Real mTimePos
Definition: OgreAnimationState.h:178
Ogre::EnabledAnimationStateList
list< AnimationState * >::type EnabledAnimationStateList
Definition: OgreAnimationState.h:191

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