# 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-2009 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 {
    00058     class _OgreExport Animation : public AnimationAlloc
    00059     {
    00060
    00061     public:
    00063         enum InterpolationMode
    00064         {
    00066             IM_LINEAR,
    00068             IM_SPLINE
    00069         };
    00070
    00072         enum RotationInterpolationMode
    00073         {
    00077             RIM_LINEAR,
    00081             RIM_SPHERICAL
    00082         };
    00087         Animation(const String& name, Real length);
    00088         virtual ~Animation();
    00089
    00091         const String& getName(void) const;
    00092
    00094         Real getLength(void) const;
    00095
    00100         void setLength(Real len);
    00101
    00106         NodeAnimationTrack* createNodeTrack(unsigned short handle);
    00107
    00112         NumericAnimationTrack* createNumericTrack(unsigned short handle);
    00113
    00121         VertexAnimationTrack* createVertexTrack(unsigned short handle, VertexAnimationType animType);
    00122
    00131         NodeAnimationTrack* createNodeTrack(unsigned short handle, Node* node);
    00132
    00138         NumericAnimationTrack* createNumericTrack(unsigned short handle,
    00139             const AnimableValuePtr& anim);
    00140
    00147         VertexAnimationTrack* createVertexTrack(unsigned short handle,
    00148             VertexData* data, VertexAnimationType animType);
    00149
    00151         unsigned short getNumNodeTracks(void) const;
    00152
    00154         NodeAnimationTrack* getNodeTrack(unsigned short handle) const;
    00155
    00157         bool hasNodeTrack(unsigned short handle) const;
    00158
    00160         unsigned short getNumNumericTracks(void) const;
    00161
    00163         NumericAnimationTrack* getNumericTrack(unsigned short handle) const;
    00164
    00166         bool hasNumericTrack(unsigned short handle) const;
    00167
    00169         unsigned short getNumVertexTracks(void) const;
    00170
    00172         VertexAnimationTrack* getVertexTrack(unsigned short handle) const;
    00173
    00175         bool hasVertexTrack(unsigned short handle) const;
    00176
    00178         void destroyNodeTrack(unsigned short handle);
    00179
    00181         void destroyNumericTrack(unsigned short handle);
    00182
    00184         void destroyVertexTrack(unsigned short handle);
    00185
    00187         void destroyAllTracks(void);
    00188
    00190         void destroyAllNodeTracks(void);
    00192         void destroyAllNumericTracks(void);
    00194         void destroyAllVertexTracks(void);
    00195
    00206         void apply(Real timePos, Real weight = 1.0, Real scale = 1.0f);
    00207
    00218         void applyToNode(Node* node, Real timePos, Real weight = 1.0, Real scale = 1.0f);
    00219
    00230         void apply(Skeleton* skeleton, Real timePos, Real weight = 1.0, Real scale = 1.0f);
    00231
    00244         void apply(Skeleton* skeleton, Real timePos, float weight,
    00245           const AnimationState::BoneBlendMask* blendMask, Real scale);
    00246
    00256         void apply(Entity* entity, Real timePos, Real weight, bool software,
    00257             bool hardware);
    00258
    00268         void applyToAnimable(const AnimableValuePtr& anim, Real timePos, Real weight = 1.0, Real scale = 1.0f);
    00269
    00277         void applyToVertexData(VertexData* data, Real timePos, Real weight = 1.0);
    00278
    00291         void setInterpolationMode(InterpolationMode im);
    00292
    00297         InterpolationMode getInterpolationMode(void) const;
    00308         void setRotationInterpolationMode(RotationInterpolationMode im);
    00309
    00314         RotationInterpolationMode getRotationInterpolationMode(void) const;
    00315
    00316         // Methods for setting the defaults
    00323         static void setDefaultInterpolationMode(InterpolationMode im);
    00324
    00326         static InterpolationMode getDefaultInterpolationMode(void);
    00327
    00334         static void setDefaultRotationInterpolationMode(RotationInterpolationMode im);
    00335
    00337         static RotationInterpolationMode getDefaultRotationInterpolationMode(void);
    00338
    00339         typedef map<unsigned short, NodeAnimationTrack*>::type NodeTrackList;
    00340         typedef ConstMapIterator<NodeTrackList> NodeTrackIterator;
    00341
    00342         typedef map<unsigned short, NumericAnimationTrack*>::type NumericTrackList;
    00343         typedef ConstMapIterator<NumericTrackList> NumericTrackIterator;
    00344
    00345         typedef map<unsigned short, VertexAnimationTrack*>::type VertexTrackList;
    00346         typedef ConstMapIterator<VertexTrackList> VertexTrackIterator;
    00347
    00349         const NodeTrackList& _getNodeTrackList(void) const;
    00350
    00352         NodeTrackIterator getNodeTrackIterator(void) const
    00353         { return NodeTrackIterator(mNodeTrackList.begin(), mNodeTrackList.end()); }
    00354
    00356         const NumericTrackList& _getNumericTrackList(void) const;
    00357
    00359         NumericTrackIterator getNumericTrackIterator(void) const
    00360         { return NumericTrackIterator(mNumericTrackList.begin(), mNumericTrackList.end()); }
    00361
    00363         const VertexTrackList& _getVertexTrackList(void) const;
    00364
    00366         VertexTrackIterator getVertexTrackIterator(void) const
    00367         { return VertexTrackIterator(mVertexTrackList.begin(), mVertexTrackList.end()); }
    00368
    00388         void optimise(bool discardIdentityNodeTracks = true);
    00389
    00391         typedef set<ushort>::type TrackHandleList;
    00392
    00400         void _collectIdentityNodeTracks(TrackHandleList& tracks) const;
    00401
    00404         void _destroyNodeTracks(const TrackHandleList& tracks);
    00405
    00412         Animation* clone(const String& newName) const;
    00413
    00416         void _keyFrameListChanged(void) { mKeyFrameTimesDirty = true; }
    00417
    00428         TimeIndex _getTimeIndex(Real timePos) const;
    00429
    00430     protected:
    00432         NodeTrackList mNodeTrackList;
    00434         NumericTrackList mNumericTrackList;
    00436         VertexTrackList mVertexTrackList;
    00437         String mName;
    00438
    00439         Real mLength;
    00440
    00441         InterpolationMode mInterpolationMode;
    00442         RotationInterpolationMode mRotationInterpolationMode;
    00443
    00444         static InterpolationMode msDefaultInterpolationMode;
    00445         static RotationInterpolationMode msDefaultRotationInterpolationMode;
    00446
    00448         typedef vector<Real>::type KeyFrameTimeList;
    00449         mutable KeyFrameTimeList mKeyFrameTimes;
    00451         mutable bool mKeyFrameTimesDirty;
    00452
    00453         void optimiseNodeTracks(bool discardIdentityTracks);
    00454         void optimiseVertexTracks(void);
    00455
    00457         void buildKeyFrameTimeList(void) const;
    00458     };
    00459
    00462 }
    00463
    00464
    00465 #endif
    00466

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun May 8 2011 20:28:08