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-2013 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 __Animation_H__ 00030 #define __Animation_H__ 00031 00032 #include "OgrePrerequisites.h" 00033 #include "OgreString.h" 00034 #include "OgreIteratorWrappers.h" 00035 #include "OgreAnimable.h" 00036 #include "OgreAnimationTrack.h" 00037 #include "OgreAnimationState.h" 00038 #include "OgreHeaderPrefix.h" 00039 00040 namespace Ogre { 00049 class Animation; 00050 00058 class _OgreExport AnimationContainer 00059 { 00060 public: 00061 virtual ~AnimationContainer() {} 00062 00064 virtual unsigned short getNumAnimations(void) const = 0; 00065 00067 virtual Animation* getAnimation(unsigned short index) const = 0; 00068 00070 virtual Animation* getAnimation(const String& name) const = 0; 00071 00073 virtual Animation* createAnimation(const String& name, Real length) = 0; 00074 00076 virtual bool hasAnimation(const String& name) const = 0; 00077 00079 virtual void removeAnimation(const String& name) = 0; 00080 00081 }; 00092 class _OgreExport Animation : public AnimationAlloc 00093 { 00094 00095 public: 00097 enum InterpolationMode 00098 { 00100 IM_LINEAR, 00102 IM_SPLINE 00103 }; 00104 00106 enum RotationInterpolationMode 00107 { 00111 RIM_LINEAR, 00115 RIM_SPHERICAL 00116 }; 00121 Animation(const String& name, Real length); 00122 virtual ~Animation(); 00123 00125 const String& getName(void) const; 00126 00128 Real getLength(void) const; 00129 00134 void setLength(Real len); 00135 00140 NodeAnimationTrack* createNodeTrack(unsigned short handle); 00141 00146 NumericAnimationTrack* createNumericTrack(unsigned short handle); 00147 00155 VertexAnimationTrack* createVertexTrack(unsigned short handle, VertexAnimationType animType); 00156 00165 NodeAnimationTrack* createNodeTrack(unsigned short handle, Node* node); 00166 00172 NumericAnimationTrack* createNumericTrack(unsigned short handle, 00173 const AnimableValuePtr& anim); 00174 00181 VertexAnimationTrack* createVertexTrack(unsigned short handle, 00182 VertexData* data, VertexAnimationType animType); 00183 00185 unsigned short getNumNodeTracks(void) const; 00186 00188 NodeAnimationTrack* getNodeTrack(unsigned short handle) const; 00189 00191 bool hasNodeTrack(unsigned short handle) const; 00192 00194 unsigned short getNumNumericTracks(void) const; 00195 00197 NumericAnimationTrack* getNumericTrack(unsigned short handle) const; 00198 00200 bool hasNumericTrack(unsigned short handle) const; 00201 00203 unsigned short getNumVertexTracks(void) const; 00204 00206 VertexAnimationTrack* getVertexTrack(unsigned short handle) const; 00207 00209 bool hasVertexTrack(unsigned short handle) const; 00210 00212 void destroyNodeTrack(unsigned short handle); 00213 00215 void destroyNumericTrack(unsigned short handle); 00216 00218 void destroyVertexTrack(unsigned short handle); 00219 00221 void destroyAllTracks(void); 00222 00224 void destroyAllNodeTracks(void); 00226 void destroyAllNumericTracks(void); 00228 void destroyAllVertexTracks(void); 00229 00240 void apply(Real timePos, Real weight = 1.0, Real scale = 1.0f); 00241 00252 void applyToNode(Node* node, Real timePos, Real weight = 1.0, Real scale = 1.0f); 00253 00264 void apply(Skeleton* skeleton, Real timePos, Real weight = 1.0, Real scale = 1.0f); 00265 00278 void apply(Skeleton* skeleton, Real timePos, float weight, 00279 const AnimationState::BoneBlendMask* blendMask, Real scale); 00280 00289 void apply(Entity* entity, Real timePos, Real weight, bool software, 00290 bool hardware); 00291 00301 void applyToAnimable(const AnimableValuePtr& anim, Real timePos, Real weight = 1.0, Real scale = 1.0f); 00302 00310 void applyToVertexData(VertexData* data, Real timePos, Real weight = 1.0); 00311 00324 void setInterpolationMode(InterpolationMode im); 00325 00330 InterpolationMode getInterpolationMode(void) const; 00341 void setRotationInterpolationMode(RotationInterpolationMode im); 00342 00347 RotationInterpolationMode getRotationInterpolationMode(void) const; 00348 00349 // Methods for setting the defaults 00356 static void setDefaultInterpolationMode(InterpolationMode im); 00357 00359 static InterpolationMode getDefaultInterpolationMode(void); 00360 00367 static void setDefaultRotationInterpolationMode(RotationInterpolationMode im); 00368 00370 static RotationInterpolationMode getDefaultRotationInterpolationMode(void); 00371 00372 typedef map<unsigned short, NodeAnimationTrack*>::type NodeTrackList; 00373 typedef ConstMapIterator<NodeTrackList> NodeTrackIterator; 00374 00375 typedef map<unsigned short, NumericAnimationTrack*>::type NumericTrackList; 00376 typedef ConstMapIterator<NumericTrackList> NumericTrackIterator; 00377 00378 typedef map<unsigned short, VertexAnimationTrack*>::type VertexTrackList; 00379 typedef ConstMapIterator<VertexTrackList> VertexTrackIterator; 00380 00382 const NodeTrackList& _getNodeTrackList(void) const; 00383 00385 NodeTrackIterator getNodeTrackIterator(void) const 00386 { return NodeTrackIterator(mNodeTrackList.begin(), mNodeTrackList.end()); } 00387 00389 const NumericTrackList& _getNumericTrackList(void) const; 00390 00392 NumericTrackIterator getNumericTrackIterator(void) const 00393 { return NumericTrackIterator(mNumericTrackList.begin(), mNumericTrackList.end()); } 00394 00396 const VertexTrackList& _getVertexTrackList(void) const; 00397 00399 VertexTrackIterator getVertexTrackIterator(void) const 00400 { return VertexTrackIterator(mVertexTrackList.begin(), mVertexTrackList.end()); } 00401 00421 void optimise(bool discardIdentityNodeTracks = true); 00422 00424 typedef set<ushort>::type TrackHandleList; 00425 00433 void _collectIdentityNodeTracks(TrackHandleList& tracks) const; 00434 00437 void _destroyNodeTracks(const TrackHandleList& tracks); 00438 00445 Animation* clone(const String& newName) const; 00446 00449 void _keyFrameListChanged(void) { mKeyFrameTimesDirty = true; } 00450 00461 TimeIndex _getTimeIndex(Real timePos) const; 00462 00490 void setUseBaseKeyFrame(bool useBaseKeyFrame, Real keyframeTime = 0.0f, const String& baseAnimName = StringUtil::BLANK); 00492 bool getUseBaseKeyFrame() const; 00494 Real getBaseKeyFrameTime() const; 00496 const String& getBaseKeyFrameAnimationName() const; 00497 00499 void _applyBaseKeyFrame(); 00500 00501 void _notifyContainer(AnimationContainer* c); 00503 AnimationContainer* getContainer(); 00504 00505 protected: 00507 NodeTrackList mNodeTrackList; 00509 NumericTrackList mNumericTrackList; 00511 VertexTrackList mVertexTrackList; 00512 String mName; 00513 00514 Real mLength; 00515 00516 InterpolationMode mInterpolationMode; 00517 RotationInterpolationMode mRotationInterpolationMode; 00518 00519 static InterpolationMode msDefaultInterpolationMode; 00520 static RotationInterpolationMode msDefaultRotationInterpolationMode; 00521 00523 typedef vector<Real>::type KeyFrameTimeList; 00524 mutable KeyFrameTimeList mKeyFrameTimes; 00526 mutable bool mKeyFrameTimesDirty; 00527 00528 bool mUseBaseKeyFrame; 00529 Real mBaseKeyFrameTime; 00530 String mBaseKeyFrameAnimationName; 00531 AnimationContainer* mContainer; 00532 00533 void optimiseNodeTracks(bool discardIdentityTracks); 00534 void optimiseVertexTracks(void); 00535 00537 void buildKeyFrameTimeList(void) const; 00538 }; 00539 00542 } // namespace Ogre 00543 00544 #include "OgreHeaderSuffix.h" 00545 00546 #endif // __Animation_H__ 00547
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:40