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 00039 00040 namespace Ogre { 00041 00052 class _OgreExport Animation 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 00217 void apply(Entity* entity, Real timePos, Real weight, bool software, 00218 bool hardware); 00219 00232 void setInterpolationMode(InterpolationMode im); 00233 00238 InterpolationMode getInterpolationMode(void) const; 00249 void setRotationInterpolationMode(RotationInterpolationMode im); 00250 00255 RotationInterpolationMode getRotationInterpolationMode(void) const; 00256 00257 // Methods for setting the defaults 00264 static void setDefaultInterpolationMode(InterpolationMode im); 00265 00267 static InterpolationMode getDefaultInterpolationMode(void); 00268 00275 static void setDefaultRotationInterpolationMode(RotationInterpolationMode im); 00276 00278 static RotationInterpolationMode getDefaultRotationInterpolationMode(void); 00279 00280 typedef std::map<unsigned short, NodeAnimationTrack*> NodeTrackList; 00281 typedef ConstMapIterator<NodeTrackList> NodeTrackIterator; 00282 00283 typedef std::map<unsigned short, NumericAnimationTrack*> NumericTrackList; 00284 typedef ConstMapIterator<NumericTrackList> NumericTrackIterator; 00285 00286 typedef std::map<unsigned short, VertexAnimationTrack*> VertexTrackList; 00287 typedef ConstMapIterator<VertexTrackList> VertexTrackIterator; 00288 00290 const NodeTrackList& _getNodeTrackList(void) const; 00291 00293 NodeTrackIterator getNodeTrackIterator(void) const 00294 { return NodeTrackIterator(mNodeTrackList.begin(), mNodeTrackList.end()); } 00295 00297 const NumericTrackList& _getNumericTrackList(void) const; 00298 00300 NumericTrackIterator getNumericTrackIterator(void) const 00301 { return NumericTrackIterator(mNumericTrackList.begin(), mNumericTrackList.end()); } 00302 00304 const VertexTrackList& _getVertexTrackList(void) const; 00305 00307 VertexTrackIterator getVertexTrackIterator(void) const 00308 { return VertexTrackIterator(mVertexTrackList.begin(), mVertexTrackList.end()); } 00309 00329 void optimise(bool discardIdentityNodeTracks = true); 00330 00332 typedef std::set<ushort> TrackHandleList; 00333 00341 void _collectIdentityNodeTracks(TrackHandleList& tracks) const; 00342 00345 void _destroyNodeTracks(const TrackHandleList& tracks); 00346 00353 Animation* clone(const String& newName) const; 00354 00357 void _keyFrameListChanged(void) { mKeyFrameTimesDirty = true; } 00358 00369 TimeIndex _getTimeIndex(Real timePos) const; 00370 00371 protected: 00373 NodeTrackList mNodeTrackList; 00375 NumericTrackList mNumericTrackList; 00377 VertexTrackList mVertexTrackList; 00378 String mName; 00379 00380 Real mLength; 00381 00382 InterpolationMode mInterpolationMode; 00383 RotationInterpolationMode mRotationInterpolationMode; 00384 00385 static InterpolationMode msDefaultInterpolationMode; 00386 static RotationInterpolationMode msDefaultRotationInterpolationMode; 00387 00389 typedef std::vector<Real> KeyFrameTimeList; 00390 mutable KeyFrameTimeList mKeyFrameTimes; 00392 mutable bool mKeyFrameTimesDirty; 00393 00394 void optimiseNodeTracks(bool discardIdentityTracks); 00395 void optimiseVertexTracks(void); 00396 00398 void buildKeyFrameTimeList(void) const; 00399 }; 00400 00401 00402 } 00403 00404 00405 #endif 00406
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Jul 8 15:20:06 2007