Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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-2005 The OGRE Team
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 */
00025 
00026 #ifndef __Animation_H__
00027 #define __Animation_H__
00028 
00029 #include "OgrePrerequisites.h"
00030 #include "OgreString.h"
00031 #include "OgreIteratorWrappers.h"
00032 #include "OgreAnimable.h"
00033 #include "OgreAnimationTrack.h"
00034 
00035 
00036 namespace Ogre {
00037 
00048     class _OgreExport Animation
00049     {
00050 
00051     public:
00053         enum InterpolationMode
00054         {
00056             IM_LINEAR,
00058             IM_SPLINE
00059         };
00060 
00062         enum RotationInterpolationMode
00063         {
00067             RIM_LINEAR,
00071             RIM_SPHERICAL
00072         };
00077         Animation(const String& name, Real length);
00078         virtual ~Animation();
00079 
00081         const String& getName(void) const;
00082 
00084         Real getLength(void) const;
00085 
00090         NodeAnimationTrack* createNodeTrack(unsigned short handle);
00091 
00096         NumericAnimationTrack* createNumericTrack(unsigned short handle);
00097 
00105         VertexAnimationTrack* createVertexTrack(unsigned short handle, VertexAnimationType animType);
00106 
00115         NodeAnimationTrack* createNodeTrack(unsigned short handle, Node* node);
00116 
00122         NumericAnimationTrack* createNumericTrack(unsigned short handle, 
00123             const AnimableValuePtr& anim);
00124 
00131         VertexAnimationTrack* createVertexTrack(unsigned short handle, 
00132             VertexData* data, VertexAnimationType animType);
00133 
00135         unsigned short getNumNodeTracks(void) const;
00136 
00138         NodeAnimationTrack* getNodeTrack(unsigned short handle) const;
00139 
00141         bool hasNodeTrack(unsigned short handle) const;
00142 
00144         unsigned short getNumNumericTracks(void) const;
00145 
00147         NumericAnimationTrack* getNumericTrack(unsigned short handle) const;
00148 
00150         bool hasNumericTrack(unsigned short handle) const;
00151 
00153         unsigned short getNumVertexTracks(void) const;
00154 
00156         VertexAnimationTrack* getVertexTrack(unsigned short handle) const;
00157 
00159         bool hasVertexTrack(unsigned short handle) const;
00160         
00162         void destroyNodeTrack(unsigned short handle);
00163 
00165         void destroyNumericTrack(unsigned short handle);
00166 
00168         void destroyVertexTrack(unsigned short handle);
00169 
00171         void destroyAllTracks(void);
00172 
00174         void destroyAllNodeTracks(void);
00176         void destroyAllNumericTracks(void);
00178         void destroyAllVertexTracks(void);
00179 
00190         void apply(Real timePos, Real weight = 1.0, bool accumulate = false, 
00191             Real scale = 1.0f);
00192 
00203         void apply(Skeleton* skeleton, Real timePos, Real weight = 1.0, 
00204             bool accumulate = false, Real scale = 1.0f);
00205 
00215         void apply(Entity* entity, Real timePos, Real weight, bool software, 
00216             bool hardware);
00217 
00230         void setInterpolationMode(InterpolationMode im);
00231 
00236         InterpolationMode getInterpolationMode(void) const;
00247         void setRotationInterpolationMode(RotationInterpolationMode im);
00248 
00253         RotationInterpolationMode getRotationInterpolationMode(void) const;
00254 
00255         // Methods for setting the defaults
00262         static void setDefaultInterpolationMode(InterpolationMode im);
00263 
00265         static InterpolationMode getDefaultInterpolationMode(void);
00266 
00273         static void setDefaultRotationInterpolationMode(RotationInterpolationMode im);
00274 
00276         static RotationInterpolationMode getDefaultRotationInterpolationMode(void);
00277 
00278         typedef std::map<unsigned short, NodeAnimationTrack*> NodeTrackList;
00279         typedef ConstMapIterator<NodeTrackList> NodeTrackIterator;
00280 
00281         typedef std::map<unsigned short, NumericAnimationTrack*> NumericTrackList;
00282         typedef ConstMapIterator<NumericTrackList> NumericTrackIterator;
00283 
00284         typedef std::map<unsigned short, VertexAnimationTrack*> VertexTrackList;
00285         typedef ConstMapIterator<VertexTrackList> VertexTrackIterator;
00286 
00288         const NodeTrackList& _getNodeTrackList(void) const;
00289 
00291         NodeTrackIterator getNodeTrackIterator(void) const
00292         { return NodeTrackIterator(mNodeTrackList.begin(), mNodeTrackList.end()); }
00293         
00295         const NumericTrackList& _getNumericTrackList(void) const;
00296 
00298         NumericTrackIterator getNumericTrackIterator(void) const
00299         { return NumericTrackIterator(mNumericTrackList.begin(), mNumericTrackList.end()); }
00300 
00302         const VertexTrackList& _getVertexTrackList(void) const;
00303 
00305         VertexTrackIterator getVertexTrackIterator(void) const
00306         { return VertexTrackIterator(mVertexTrackList.begin(), mVertexTrackList.end()); }
00307 
00317         void optimise(void);
00318         
00319 
00320 
00321     protected:
00323         NodeTrackList mNodeTrackList;
00325         NumericTrackList mNumericTrackList;
00327         VertexTrackList mVertexTrackList;
00328         String mName;
00329 
00330         Real mLength;
00331 
00332         InterpolationMode mInterpolationMode;
00333         RotationInterpolationMode mRotationInterpolationMode;
00334 
00335         static InterpolationMode msDefaultInterpolationMode;
00336         static RotationInterpolationMode msDefaultRotationInterpolationMode;
00337 
00338         void optimiseNodeTracks(void);
00339         void optimiseVertexTracks(void);
00340 
00341         
00342     };
00343 
00344 
00345 }
00346 
00347 
00348 #endif
00349 

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:36 2006