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 __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 00039 namespace Ogre { 00048 class Animation; 00049 00057 class _OgreExport AnimationContainer 00058 { 00059 public: 00061 virtual unsigned short getNumAnimations(void) const = 0; 00062 00064 virtual Animation* getAnimation(unsigned short index) const = 0; 00065 00067 virtual Animation* getAnimation(const String& name) const = 0; 00068 00070 virtual Animation* createAnimation(const String& name, Real length) = 0; 00071 00073 virtual bool hasAnimation(const String& name) const = 0; 00074 00076 virtual void removeAnimation(const String& name) = 0; 00077 00078 }; 00089 class _OgreExport Animation : public AnimationAlloc 00090 { 00091 00092 public: 00094 enum InterpolationMode 00095 { 00097 IM_LINEAR, 00099 IM_SPLINE 00100 }; 00101 00103 enum RotationInterpolationMode 00104 { 00108 RIM_LINEAR, 00112 RIM_SPHERICAL 00113 }; 00118 Animation(const String& name, Real length); 00119 virtual ~Animation(); 00120 00122 const String& getName(void) const; 00123 00125 Real getLength(void) const; 00126 00131 void setLength(Real len); 00132 00137 NodeAnimationTrack* createNodeTrack(unsigned short handle); 00138 00143 NumericAnimationTrack* createNumericTrack(unsigned short handle); 00144 00152 VertexAnimationTrack* createVertexTrack(unsigned short handle, VertexAnimationType animType); 00153 00162 NodeAnimationTrack* createNodeTrack(unsigned short handle, Node* node); 00163 00169 NumericAnimationTrack* createNumericTrack(unsigned short handle, 00170 const AnimableValuePtr& anim); 00171 00178 VertexAnimationTrack* createVertexTrack(unsigned short handle, 00179 VertexData* data, VertexAnimationType animType); 00180 00182 unsigned short getNumNodeTracks(void) const; 00183 00185 NodeAnimationTrack* getNodeTrack(unsigned short handle) const; 00186 00188 bool hasNodeTrack(unsigned short handle) const; 00189 00191 unsigned short getNumNumericTracks(void) const; 00192 00194 NumericAnimationTrack* getNumericTrack(unsigned short handle) const; 00195 00197 bool hasNumericTrack(unsigned short handle) const; 00198 00200 unsigned short getNumVertexTracks(void) const; 00201 00203 VertexAnimationTrack* getVertexTrack(unsigned short handle) const; 00204 00206 bool hasVertexTrack(unsigned short handle) const; 00207 00209 void destroyNodeTrack(unsigned short handle); 00210 00212 void destroyNumericTrack(unsigned short handle); 00213 00215 void destroyVertexTrack(unsigned short handle); 00216 00218 void destroyAllTracks(void); 00219 00221 void destroyAllNodeTracks(void); 00223 void destroyAllNumericTracks(void); 00225 void destroyAllVertexTracks(void); 00226 00237 void apply(Real timePos, Real weight = 1.0, Real scale = 1.0f); 00238 00249 void applyToNode(Node* node, Real timePos, Real weight = 1.0, Real scale = 1.0f); 00250 00261 void apply(Skeleton* skeleton, Real timePos, Real weight = 1.0, Real scale = 1.0f); 00262 00275 void apply(Skeleton* skeleton, Real timePos, float weight, 00276 const AnimationState::BoneBlendMask* blendMask, Real scale); 00277 00287 void apply(Entity* entity, Real timePos, Real weight, bool software, 00288 bool hardware); 00289 00299 void applyToAnimable(const AnimableValuePtr& anim, Real timePos, Real weight = 1.0, Real scale = 1.0f); 00300 00308 void applyToVertexData(VertexData* data, Real timePos, Real weight = 1.0); 00309 00322 void setInterpolationMode(InterpolationMode im); 00323 00328 InterpolationMode getInterpolationMode(void) const; 00339 void setRotationInterpolationMode(RotationInterpolationMode im); 00340 00345 RotationInterpolationMode getRotationInterpolationMode(void) const; 00346 00347 // Methods for setting the defaults 00354 static void setDefaultInterpolationMode(InterpolationMode im); 00355 00357 static InterpolationMode getDefaultInterpolationMode(void); 00358 00365 static void setDefaultRotationInterpolationMode(RotationInterpolationMode im); 00366 00368 static RotationInterpolationMode getDefaultRotationInterpolationMode(void); 00369 00370 typedef map<unsigned short, NodeAnimationTrack*>::type NodeTrackList; 00371 typedef ConstMapIterator<NodeTrackList> NodeTrackIterator; 00372 00373 typedef map<unsigned short, NumericAnimationTrack*>::type NumericTrackList; 00374 typedef ConstMapIterator<NumericTrackList> NumericTrackIterator; 00375 00376 typedef map<unsigned short, VertexAnimationTrack*>::type VertexTrackList; 00377 typedef ConstMapIterator<VertexTrackList> VertexTrackIterator; 00378 00380 const NodeTrackList& _getNodeTrackList(void) const; 00381 00383 NodeTrackIterator getNodeTrackIterator(void) const 00384 { return NodeTrackIterator(mNodeTrackList.begin(), mNodeTrackList.end()); } 00385 00387 const NumericTrackList& _getNumericTrackList(void) const; 00388 00390 NumericTrackIterator getNumericTrackIterator(void) const 00391 { return NumericTrackIterator(mNumericTrackList.begin(), mNumericTrackList.end()); } 00392 00394 const VertexTrackList& _getVertexTrackList(void) const; 00395 00397 VertexTrackIterator getVertexTrackIterator(void) const 00398 { return VertexTrackIterator(mVertexTrackList.begin(), mVertexTrackList.end()); } 00399 00419 void optimise(bool discardIdentityNodeTracks = true); 00420 00422 typedef set<ushort>::type TrackHandleList; 00423 00431 void _collectIdentityNodeTracks(TrackHandleList& tracks) const; 00432 00435 void _destroyNodeTracks(const TrackHandleList& tracks); 00436 00443 Animation* clone(const String& newName) const; 00444 00447 void _keyFrameListChanged(void) { mKeyFrameTimesDirty = true; } 00448 00459 TimeIndex _getTimeIndex(Real timePos) const; 00460 00488 void setUseBaseKeyFrame(bool useBaseKeyFrame, Real keyframeTime = 0.0f, const String& baseAnimName = StringUtil::BLANK); 00490 bool getUseBaseKeyFrame() const; 00492 Real getBaseKeyFrameTime() const; 00494 const String& getBaseKeyFrameAnimationName() const; 00495 00497 void _applyBaseKeyFrame(); 00498 00499 void _notifyContainer(AnimationContainer* c); 00501 AnimationContainer* getContainer(); 00502 00503 protected: 00505 NodeTrackList mNodeTrackList; 00507 NumericTrackList mNumericTrackList; 00509 VertexTrackList mVertexTrackList; 00510 String mName; 00511 00512 Real mLength; 00513 00514 InterpolationMode mInterpolationMode; 00515 RotationInterpolationMode mRotationInterpolationMode; 00516 00517 static InterpolationMode msDefaultInterpolationMode; 00518 static RotationInterpolationMode msDefaultRotationInterpolationMode; 00519 00521 typedef vector<Real>::type KeyFrameTimeList; 00522 mutable KeyFrameTimeList mKeyFrameTimes; 00524 mutable bool mKeyFrameTimesDirty; 00525 00526 bool mUseBaseKeyFrame; 00527 Real mBaseKeyFrameTime; 00528 String mBaseKeyFrameAnimationName; 00529 AnimationContainer* mContainer; 00530 00531 void optimiseNodeTracks(bool discardIdentityTracks); 00532 void optimiseVertexTracks(void); 00533 00535 void buildKeyFrameTimeList(void) const; 00536 }; 00537 00540 } 00541 00542 00543 #endif 00544
Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 23:36:23 2012