OgreAnimation.h

Go to the documentation of this file.
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         void setLength(Real len);
00095 
00100         NodeAnimationTrack* createNodeTrack(unsigned short handle);
00101 
00106         NumericAnimationTrack* createNumericTrack(unsigned short handle);
00107 
00115         VertexAnimationTrack* createVertexTrack(unsigned short handle, VertexAnimationType animType);
00116 
00125         NodeAnimationTrack* createNodeTrack(unsigned short handle, Node* node);
00126 
00132         NumericAnimationTrack* createNumericTrack(unsigned short handle, 
00133             const AnimableValuePtr& anim);
00134 
00141         VertexAnimationTrack* createVertexTrack(unsigned short handle, 
00142             VertexData* data, VertexAnimationType animType);
00143 
00145         unsigned short getNumNodeTracks(void) const;
00146 
00148         NodeAnimationTrack* getNodeTrack(unsigned short handle) const;
00149 
00151         bool hasNodeTrack(unsigned short handle) const;
00152 
00154         unsigned short getNumNumericTracks(void) const;
00155 
00157         NumericAnimationTrack* getNumericTrack(unsigned short handle) const;
00158 
00160         bool hasNumericTrack(unsigned short handle) const;
00161 
00163         unsigned short getNumVertexTracks(void) const;
00164 
00166         VertexAnimationTrack* getVertexTrack(unsigned short handle) const;
00167 
00169         bool hasVertexTrack(unsigned short handle) const;
00170         
00172         void destroyNodeTrack(unsigned short handle);
00173 
00175         void destroyNumericTrack(unsigned short handle);
00176 
00178         void destroyVertexTrack(unsigned short handle);
00179 
00181         void destroyAllTracks(void);
00182 
00184         void destroyAllNodeTracks(void);
00186         void destroyAllNumericTracks(void);
00188         void destroyAllVertexTracks(void);
00189 
00200         void apply(Real timePos, Real weight = 1.0, Real scale = 1.0f);
00201 
00212         void apply(Skeleton* skeleton, Real timePos, Real weight = 1.0, Real scale = 1.0f);
00213 
00226         void apply(Skeleton* skeleton, Real timePos, float weight,
00227           const AnimationState::BoneBlendMask* blendMask, Real scale);
00228 
00238         void apply(Entity* entity, Real timePos, Real weight, bool software, 
00239             bool hardware);
00240 
00253         void setInterpolationMode(InterpolationMode im);
00254 
00259         InterpolationMode getInterpolationMode(void) const;
00270         void setRotationInterpolationMode(RotationInterpolationMode im);
00271 
00276         RotationInterpolationMode getRotationInterpolationMode(void) const;
00277 
00278         // Methods for setting the defaults
00285         static void setDefaultInterpolationMode(InterpolationMode im);
00286 
00288         static InterpolationMode getDefaultInterpolationMode(void);
00289 
00296         static void setDefaultRotationInterpolationMode(RotationInterpolationMode im);
00297 
00299         static RotationInterpolationMode getDefaultRotationInterpolationMode(void);
00300 
00301         typedef std::map<unsigned short, NodeAnimationTrack*> NodeTrackList;
00302         typedef ConstMapIterator<NodeTrackList> NodeTrackIterator;
00303 
00304         typedef std::map<unsigned short, NumericAnimationTrack*> NumericTrackList;
00305         typedef ConstMapIterator<NumericTrackList> NumericTrackIterator;
00306 
00307         typedef std::map<unsigned short, VertexAnimationTrack*> VertexTrackList;
00308         typedef ConstMapIterator<VertexTrackList> VertexTrackIterator;
00309 
00311         const NodeTrackList& _getNodeTrackList(void) const;
00312 
00314         NodeTrackIterator getNodeTrackIterator(void) const
00315         { return NodeTrackIterator(mNodeTrackList.begin(), mNodeTrackList.end()); }
00316         
00318         const NumericTrackList& _getNumericTrackList(void) const;
00319 
00321         NumericTrackIterator getNumericTrackIterator(void) const
00322         { return NumericTrackIterator(mNumericTrackList.begin(), mNumericTrackList.end()); }
00323 
00325         const VertexTrackList& _getVertexTrackList(void) const;
00326 
00328         VertexTrackIterator getVertexTrackIterator(void) const
00329         { return VertexTrackIterator(mVertexTrackList.begin(), mVertexTrackList.end()); }
00330 
00350         void optimise(bool discardIdentityNodeTracks = true);
00351 
00353         typedef std::set<ushort> TrackHandleList;
00354 
00362         void _collectIdentityNodeTracks(TrackHandleList& tracks) const;
00363 
00366         void _destroyNodeTracks(const TrackHandleList& tracks);
00367 
00374         Animation* clone(const String& newName) const;
00375         
00378         void _keyFrameListChanged(void) { mKeyFrameTimesDirty = true; }
00379 
00390         TimeIndex _getTimeIndex(Real timePos) const;
00391 
00392     protected:
00394         NodeTrackList mNodeTrackList;
00396         NumericTrackList mNumericTrackList;
00398         VertexTrackList mVertexTrackList;
00399         String mName;
00400 
00401         Real mLength;
00402 
00403         InterpolationMode mInterpolationMode;
00404         RotationInterpolationMode mRotationInterpolationMode;
00405 
00406         static InterpolationMode msDefaultInterpolationMode;
00407         static RotationInterpolationMode msDefaultRotationInterpolationMode;
00408 
00410         typedef std::vector<Real> KeyFrameTimeList;
00411         mutable KeyFrameTimeList mKeyFrameTimes;
00413         mutable bool mKeyFrameTimesDirty;
00414 
00415         void optimiseNodeTracks(bool discardIdentityTracks);
00416         void optimiseVertexTracks(void);
00417 
00419         void buildKeyFrameTimeList(void) const;
00420     };
00421 
00422 
00423 }
00424 
00425 
00426 #endif
00427 

Copyright © 2008 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 27 22:02:22 2009