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-2006 Torus Knot Software Ltd 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 00024 You may alternatively use this source under the terms of a specific version of 00025 the OGRE Unrestricted License provided you have obtained such a license from 00026 Torus Knot Software Ltd. 00027 ----------------------------------------------------------------------------- 00028 */ 00029 00030 #ifndef __Animation_H__ 00031 #define __Animation_H__ 00032 00033 #include "OgrePrerequisites.h" 00034 #include "OgreString.h" 00035 #include "OgreIteratorWrappers.h" 00036 #include "OgreAnimable.h" 00037 #include "OgreAnimationTrack.h" 00038 #include "OgreAnimationState.h" 00039 00040 namespace Ogre { 00041 00052 class _OgreExport Animation : public AnimationAlloc 00053 { 00054 00055 public: 00057 enum InterpolationMode 00058 { 00060 IM_LINEAR, 00062 IM_SPLINE 00063 }; 00064 00066 enum RotationInterpolationMode 00067 { 00071 RIM_LINEAR, 00075 RIM_SPHERICAL 00076 }; 00081 Animation(const String& name, Real length); 00082 virtual ~Animation(); 00083 00085 const String& getName(void) const; 00086 00088 Real getLength(void) const; 00089 00094 NodeAnimationTrack* createNodeTrack(unsigned short handle); 00095 00100 NumericAnimationTrack* createNumericTrack(unsigned short handle); 00101 00109 VertexAnimationTrack* createVertexTrack(unsigned short handle, VertexAnimationType animType); 00110 00119 NodeAnimationTrack* createNodeTrack(unsigned short handle, Node* node); 00120 00126 NumericAnimationTrack* createNumericTrack(unsigned short handle, 00127 const AnimableValuePtr& anim); 00128 00135 VertexAnimationTrack* createVertexTrack(unsigned short handle, 00136 VertexData* data, VertexAnimationType animType); 00137 00139 unsigned short getNumNodeTracks(void) const; 00140 00142 NodeAnimationTrack* getNodeTrack(unsigned short handle) const; 00143 00145 bool hasNodeTrack(unsigned short handle) const; 00146 00148 unsigned short getNumNumericTracks(void) const; 00149 00151 NumericAnimationTrack* getNumericTrack(unsigned short handle) const; 00152 00154 bool hasNumericTrack(unsigned short handle) const; 00155 00157 unsigned short getNumVertexTracks(void) const; 00158 00160 VertexAnimationTrack* getVertexTrack(unsigned short handle) const; 00161 00163 bool hasVertexTrack(unsigned short handle) const; 00164 00166 void destroyNodeTrack(unsigned short handle); 00167 00169 void destroyNumericTrack(unsigned short handle); 00170 00172 void destroyVertexTrack(unsigned short handle); 00173 00175 void destroyAllTracks(void); 00176 00178 void destroyAllNodeTracks(void); 00180 void destroyAllNumericTracks(void); 00182 void destroyAllVertexTracks(void); 00183 00194 void apply(Real timePos, Real weight = 1.0, Real scale = 1.0f); 00195 00206 void apply(Skeleton* skeleton, Real timePos, Real weight = 1.0, Real scale = 1.0f); 00207 00220 void apply(Skeleton* skeleton, Real timePos, float weight, 00221 const AnimationState::BoneBlendMask* blendMask, Real scale); 00222 00232 void apply(Entity* entity, Real timePos, Real weight, bool software, 00233 bool hardware); 00234 00247 void setInterpolationMode(InterpolationMode im); 00248 00253 InterpolationMode getInterpolationMode(void) const; 00264 void setRotationInterpolationMode(RotationInterpolationMode im); 00265 00270 RotationInterpolationMode getRotationInterpolationMode(void) const; 00271 00272 // Methods for setting the defaults 00279 static void setDefaultInterpolationMode(InterpolationMode im); 00280 00282 static InterpolationMode getDefaultInterpolationMode(void); 00283 00290 static void setDefaultRotationInterpolationMode(RotationInterpolationMode im); 00291 00293 static RotationInterpolationMode getDefaultRotationInterpolationMode(void); 00294 00295 typedef std::map<unsigned short, NodeAnimationTrack*> NodeTrackList; 00296 typedef ConstMapIterator<NodeTrackList> NodeTrackIterator; 00297 00298 typedef std::map<unsigned short, NumericAnimationTrack*> NumericTrackList; 00299 typedef ConstMapIterator<NumericTrackList> NumericTrackIterator; 00300 00301 typedef std::map<unsigned short, VertexAnimationTrack*> VertexTrackList; 00302 typedef ConstMapIterator<VertexTrackList> VertexTrackIterator; 00303 00305 const NodeTrackList& _getNodeTrackList(void) const; 00306 00308 NodeTrackIterator getNodeTrackIterator(void) const 00309 { return NodeTrackIterator(mNodeTrackList.begin(), mNodeTrackList.end()); } 00310 00312 const NumericTrackList& _getNumericTrackList(void) const; 00313 00315 NumericTrackIterator getNumericTrackIterator(void) const 00316 { return NumericTrackIterator(mNumericTrackList.begin(), mNumericTrackList.end()); } 00317 00319 const VertexTrackList& _getVertexTrackList(void) const; 00320 00322 VertexTrackIterator getVertexTrackIterator(void) const 00323 { return VertexTrackIterator(mVertexTrackList.begin(), mVertexTrackList.end()); } 00324 00344 void optimise(bool discardIdentityNodeTracks = true); 00345 00347 typedef std::set<ushort> TrackHandleList; 00348 00356 void _collectIdentityNodeTracks(TrackHandleList& tracks) const; 00357 00360 void _destroyNodeTracks(const TrackHandleList& tracks); 00361 00368 Animation* clone(const String& newName) const; 00369 00372 void _keyFrameListChanged(void) { mKeyFrameTimesDirty = true; } 00373 00384 TimeIndex _getTimeIndex(Real timePos) const; 00385 00386 protected: 00388 NodeTrackList mNodeTrackList; 00390 NumericTrackList mNumericTrackList; 00392 VertexTrackList mVertexTrackList; 00393 String mName; 00394 00395 Real mLength; 00396 00397 InterpolationMode mInterpolationMode; 00398 RotationInterpolationMode mRotationInterpolationMode; 00399 00400 static InterpolationMode msDefaultInterpolationMode; 00401 static RotationInterpolationMode msDefaultRotationInterpolationMode; 00402 00404 typedef std::vector<Real> KeyFrameTimeList; 00405 mutable KeyFrameTimeList mKeyFrameTimes; 00407 mutable bool mKeyFrameTimesDirty; 00408 00409 void optimiseNodeTracks(bool discardIdentityTracks); 00410 void optimiseVertexTracks(void); 00411 00413 void buildKeyFrameTimeList(void) const; 00414 }; 00415 00416 00417 } 00418 00419 00420 #endif 00421
Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Thu Aug 28 20:53:44 2008