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-2009 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 00060 AnimationState(const String& animName, AnimationStateSet *parent, 00061 Real timePos, Real length, Real weight = 1.0, bool enabled = false); 00063 AnimationState(AnimationStateSet* parent, const AnimationState &rhs); 00067 virtual ~AnimationState(); 00068 00070 const String& getAnimationName() const; 00072 Real getTimePosition(void) const; 00074 void setTimePosition(Real timePos); 00076 Real getLength() const; 00078 void setLength(Real len); 00080 Real getWeight(void) const; 00082 void setWeight(Real weight); 00087 void addTime(Real offset); 00088 00090 bool hasEnded(void) const; 00091 00093 bool getEnabled(void) const; 00095 void setEnabled(bool enabled); 00096 00098 bool operator==(const AnimationState& rhs) const; 00099 // Inequality operator 00100 bool operator!=(const AnimationState& rhs) const; 00101 00105 void setLoop(bool loop) { mLoop = loop; } 00107 bool getLoop(void) const { return mLoop; } 00108 00113 void copyStateFrom(const AnimationState& animState); 00114 00116 AnimationStateSet* getParent(void) const { return mParent; } 00117 00128 void createBlendMask(size_t blendMaskSizeHint, float initialWeight = 1.0f); 00130 void destroyBlendMask(); 00138 void _setBlendMaskData(const float* blendMaskData); 00146 void _setBlendMask(const BoneBlendMask* blendMask); 00148 const BoneBlendMask* getBlendMask() const {return mBlendMask;} 00150 bool hasBlendMask() const {return mBlendMask != 0;} 00152 void setBlendMaskEntry(size_t boneHandle, float weight); 00154 inline float getBlendMaskEntry(size_t boneHandle) const 00155 { 00156 assert(mBlendMask && mBlendMask->size() > boneHandle); 00157 return (*mBlendMask)[boneHandle]; 00158 } 00159 protected: 00161 BoneBlendMask* mBlendMask; 00162 00163 String mAnimationName; 00164 AnimationStateSet* mParent; 00165 Real mTimePos; 00166 Real mLength; 00167 Real mWeight; 00168 bool mEnabled; 00169 bool mLoop; 00170 00171 }; 00172 00173 // A map of animation states 00174 typedef map<String, AnimationState*>::type AnimationStateMap; 00175 typedef MapIterator<AnimationStateMap> AnimationStateIterator; 00176 typedef ConstMapIterator<AnimationStateMap> ConstAnimationStateIterator; 00177 // A list of enabled animation states 00178 typedef list<AnimationState*>::type EnabledAnimationStateList; 00179 typedef ConstVectorIterator<EnabledAnimationStateList> ConstEnabledAnimationStateIterator; 00180 00183 class _OgreExport AnimationStateSet : public AnimationAlloc 00184 { 00185 public: 00187 OGRE_AUTO_MUTEX 00189 AnimationStateSet(); 00191 AnimationStateSet(const AnimationStateSet& rhs); 00192 00193 ~AnimationStateSet(); 00194 00202 AnimationState* createAnimationState(const String& animName, 00203 Real timePos, Real length, Real weight = 1.0, bool enabled = false); 00205 AnimationState* getAnimationState(const String& name) const; 00207 bool hasAnimationState(const String& name) const; 00209 void removeAnimationState(const String& name); 00211 void removeAllAnimationStates(void); 00212 00219 AnimationStateIterator getAnimationStateIterator(void); 00226 ConstAnimationStateIterator getAnimationStateIterator(void) const; 00228 void copyMatchingState(AnimationStateSet* target) const; 00230 void _notifyDirty(void); 00232 unsigned long getDirtyFrameNumber(void) const { return mDirtyFrameNumber; } 00233 00235 void _notifyAnimationStateEnabled(AnimationState* target, bool enabled); 00237 bool hasEnabledAnimationState(void) const { return !mEnabledAnimationStates.empty(); } 00244 ConstEnabledAnimationStateIterator getEnabledAnimationStateIterator(void) const; 00245 00246 protected: 00247 unsigned long mDirtyFrameNumber; 00248 AnimationStateMap mAnimationStates; 00249 EnabledAnimationStateList mEnabledAnimationStates; 00250 00251 }; 00252 00261 class _OgreExport AnimationStateControllerValue : public ControllerValue<Real> 00262 { 00263 protected: 00264 AnimationState* mTargetAnimationState; 00265 public: 00267 AnimationStateControllerValue(AnimationState* targetAnimationState) 00268 : mTargetAnimationState(targetAnimationState) {} 00270 ~AnimationStateControllerValue() {} 00272 Real getValue(void) const; 00273 00275 void setValue(Real value); 00276 00277 }; 00278 00281 } 00282 00283 #endif 00284
Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:51