OgreAnimationState.h
Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2012 Torus Knot Software Ltd
    00008
    00009 Permission is hereby granted, free of charge, to any person obtaining a copy
    00010 of this software and associated documentation files (the "Software"), to deal
    00011 in the Software without restriction, including without limitation the rights
    00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00013 copies of the Software, and to permit persons to whom the Software is
    00014 furnished to do so, subject to the following conditions:
    00015
    00016 The above copyright notice and this permission notice shall be included in
    00017 all copies or substantial portions of the Software.
    00018
    00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00025 THE SOFTWARE.
    00026 -----------------------------------------------------------------------------
    00027 */
    00028
    00029 #ifndef __AnimationSet_H__
    00030 #define __AnimationSet_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033
    00034 #include "OgreString.h"
    00035 #include "OgreController.h"
    00036 #include "OgreIteratorWrappers.h"
    00037
    00038 namespace Ogre {
    00039
    00052     class _OgreExport AnimationState : public AnimationAlloc
    00053     {
    00054     public:
    00055
    00057         typedef vector<float>::type BoneBlendMask;
    00058
    00073         AnimationState(const String& animName, AnimationStateSet *parent,
    00074             Real timePos, Real length, Real weight = 1.0, bool enabled = false);
    00076         AnimationState(AnimationStateSet* parent, const AnimationState &rhs);
    00077         virtual ~AnimationState();
    00078
    00080         const String& getAnimationName() const;
    00082         Real getTimePosition(void) const;
    00084         void setTimePosition(Real timePos);
    00086         Real getLength() const;
    00088         void setLength(Real len);
    00090         Real getWeight(void) const;
    00092         void setWeight(Real weight);
    00098         void addTime(Real offset);
    00099
    00101         bool hasEnded(void) const;
    00102
    00104         bool getEnabled(void) const;
    00106         void setEnabled(bool enabled);
    00107
    00109         bool operator==(const AnimationState& rhs) const;
    00111         bool operator!=(const AnimationState& rhs) const;
    00112
    00116         void setLoop(bool loop) { mLoop = loop; }
    00118         bool getLoop(void) const { return mLoop; }
    00119
    00124         void copyStateFrom(const AnimationState& animState);
    00125
    00127         AnimationStateSet* getParent(void) const { return mParent; }
    00128
    00139       void createBlendMask(size_t blendMaskSizeHint, float initialWeight = 1.0f);
    00141       void destroyBlendMask();
    00149       void _setBlendMaskData(const float* blendMaskData);
    00157       void _setBlendMask(const BoneBlendMask* blendMask);
    00159       const BoneBlendMask* getBlendMask() const {return mBlendMask;}
    00161       bool hasBlendMask() const {return mBlendMask != 0;}
    00163       void setBlendMaskEntry(size_t boneHandle, float weight);
    00165       inline float getBlendMaskEntry(size_t boneHandle) const
    00166       {
    00167           assert(mBlendMask && mBlendMask->size() > boneHandle);
    00168           return (*mBlendMask)[boneHandle];
    00169       }
    00170     protected:
    00172         BoneBlendMask* mBlendMask;
    00173
    00174         String mAnimationName;
    00175         AnimationStateSet* mParent;
    00176         Real mTimePos;
    00177         Real mLength;
    00178         Real mWeight;
    00179         bool mEnabled;
    00180         bool mLoop;
    00181
    00182     };
    00183
    00184     // A map of animation states
    00185     typedef map<String, AnimationState*>::type AnimationStateMap;
    00186     typedef MapIterator<AnimationStateMap> AnimationStateIterator;
    00187     typedef ConstMapIterator<AnimationStateMap> ConstAnimationStateIterator;
    00188     // A list of enabled animation states
    00189     typedef list<AnimationState*>::type EnabledAnimationStateList;
    00190     typedef ConstVectorIterator<EnabledAnimationStateList> ConstEnabledAnimationStateIterator;
    00191
    00194     class _OgreExport AnimationStateSet : public AnimationAlloc
    00195     {
    00196     public:
    00198         OGRE_AUTO_MUTEX
    00200         AnimationStateSet();
    00202         AnimationStateSet(const AnimationStateSet& rhs);
    00203
    00204         ~AnimationStateSet();
    00205
    00213         AnimationState* createAnimationState(const String& animName,
    00214             Real timePos, Real length, Real weight = 1.0, bool enabled = false);
    00216         AnimationState* getAnimationState(const String& name) const;
    00218         bool hasAnimationState(const String& name) const;
    00220         void removeAnimationState(const String& name);
    00222         void removeAllAnimationStates(void);
    00223
    00230         AnimationStateIterator getAnimationStateIterator(void);
    00237         ConstAnimationStateIterator getAnimationStateIterator(void) const;
    00239         void copyMatchingState(AnimationStateSet* target) const;
    00241         void _notifyDirty(void);
    00243         unsigned long getDirtyFrameNumber(void) const { return mDirtyFrameNumber; }
    00244
    00246         void _notifyAnimationStateEnabled(AnimationState* target, bool enabled);
    00248         bool hasEnabledAnimationState(void) const { return !mEnabledAnimationStates.empty(); }
    00255         ConstEnabledAnimationStateIterator getEnabledAnimationStateIterator(void) const;
    00256
    00257     protected:
    00258         unsigned long mDirtyFrameNumber;
    00259         AnimationStateMap mAnimationStates;
    00260         EnabledAnimationStateList mEnabledAnimationStates;
    00261
    00262     };
    00263
    00272     class _OgreExport AnimationStateControllerValue : public ControllerValue<Real>
    00273     {
    00274     protected:
    00275         AnimationState* mTargetAnimationState;
    00276     public:
    00278         AnimationStateControllerValue(AnimationState* targetAnimationState)
    00279             : mTargetAnimationState(targetAnimationState) {}
    00281         ~AnimationStateControllerValue() {}
    00283         Real getValue(void) const;
    00284
    00286         void setValue(Real value);
    00287
    00288     };
    00289
    00292 }
    00293
    00294 #endif
    00295

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:20